[logback-user] How to reload logback configuration ?

praveen patil iampraveenpatil at gmail.com
Wed Jul 10 06:35:11 CEST 2013


Hi kirti,

As per http://logback.qos.ch/manual/configuration.html#autoScan document
the logback configuration loads automatically on modifications.Even though
if you want it to load manually look around joran configurator.

HTH

Kind Regards,

Praveen Patil
HotWax Media Pvt. Ltd.
pravin.patil at hotwaxmedia.com
Direct - +91 9039689196



On Tue, Jul 9, 2013 at 5:51 PM, Kriti Wadhwa <kriti.wadhwa at tcs.com> wrote:

> Hi,
>
>
>
> I am using external properties file(*process_settings.properties*) for
> variable substitution to programmatically configure the following logger
> parameters:******
>
> BACKUP_COUNT (backup history)****
>
> FILE_SIZE****
>
> *LOG_LEVEL*****
>
> ** **
>
> From my application, after I set the above mentioned params in properties
> file, I want the logback configuration(and hence the new properties file)
> to be reloaded and restarted again.****
>
> ** **
>
> For that I am doing:****
>
> LoggerContext loggerContext = (LoggerContext) LoggerFactory.*
> getILoggerFactory*();****
>
> loggerContext.reset();****
>
> ContextInitializer ci = *new* ContextInitializer(loggerContext);****
>
> ci.autoConfig();****
>
> ** **
>
> On restart, logback.xml is not using the updated properties file, instead
> it is still substituting values which were set previously. ****
>
> ** **
>
> Please suggest how to restart logback such that the updated properties
> file is picked up.****
>
> (Properties file is being correctly updated – this has been verified)  ***
> *
>
> ** **
>
> *Logback.xml*
>
> <?xml version=*"1.0"* encoding=*"UTF-8"*?>****
>
> <configuration>****
>
>        *<**property** resource="process_settings.properties" />*
>
>        ****
>
>        <appender name=*"STDOUT"* class=*
> "ch.qos.logback.core.ConsoleAppender"*>****
>
>               encoders are by default assigned the type
> ch.qos.logback.classic.encoder.PatternLayoutEncoder****
>
>               <encoder>****
>
>                      <pattern>%d [%thread] %-5level %class{0} %*msg*%n</
> pattern>****
>
>               </encoder>****
>
>        </appender>****
>
> ** **
>
>        <appender name=*"FILE"*****
>
>               class=*"ch.qos.logback.core.rolling.RollingFileAppender"*>**
> **
>
>               <file>C:/cpm.log</file>****
>
>               <rollingPolicy class=*
> "ch.qos.logback.core.rolling.FixedWindowRollingPolicy"*>
> ****
>
>                      <!-- <fileNamePattern>/*var*/log/*cloudprovider*-*mgr
> */*cpm*.%i.log</fileNamePattern> -->****
>
>                      <fileNamePattern>C:/*cpm*.%i.log</fileNamePattern>***
> *
>
>                      <minIndex>1</minIndex>****
>
>                      <maxIndex>${BACKUP_COUNT}</maxIndex>
> ****
>
>               </rollingPolicy>****
>
>               ****
>
>               <triggeringPolicy class=*
> "ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"*>****
>
>               <maxFileSize>${FILE_SIZE}</maxFileSize>****
>
>               </triggeringPolicy>****
>
>               ****
>
>               <encoder>****
>
>                      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level
> %class{0} %*msg*%n</pattern>****
>
>               </encoder>****
>
>        </appender>****
>
> ** **
>
>        <root level=*"DEBUG"*>****
>
>               <appender-ref ref=*"STDOUT"* />****
>
>               <appender-ref ref=*"FILE"* />****
>
>        </root>****
>
> <logger name=*"com.xyz"*>****
>
>               <level value=*"${LOG_LEVEL}"* />****
>
>        </logger>****
>
> </configuration>****
>
> ** **
>
> ** **
>
> Thanks,****
>
> Kriti****
>
>
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://mailman.qos.ch/mailman/listinfo/logback-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130710/61b398ee/attachment-0001.html>


More information about the Logback-user mailing list