Override Slf4j logback.xml for a java application

The system property [logback.configurationFile] needs to be passed with the proper logback file path to override the default configuration.

  java -Dlogback.configurationFile=/opt/logback.xml -jar /opt/restApp1.0.jar

If you want the logback-classic to automatically refresh the changes, then the scan attribute should be passed as true. otherwise it would not be reloaded. We have to manually restart the server/application. This attribute is available in the root node[configuration]

<configuration scan="true"> 
 ...
 ...
 </configuration> 
By default logback-classic will scan the changes every one minute, but if we want to
 change this then we have to add another attribute scanPeriod with the time interval and the unit as below.
<configuration scan="true" scanPeriod="30 seconds"> 
 ...
 ...
 </configuration>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s