Reputation: 1003
I'm not able to print the slf4j log message. The controller is not loading logback.xml file. I searched on net I found that
static
{
System.setProperty("logback.configurationFile", "D:/RxBDataFeeder/RxBDataFeeder/config/logback.xml");
}
This code is also not working.
Upvotes: 1
Views: 9976
Reputation: 58
This will fix:
$javapath -jar $jarname --logging.config=/path/to/logback.xml
Upvotes: 0
Reputation: 5871
you can pass the logback config file as a param while starting the app as shown below.
java -Dlogback.configurationFile=path/logback.xml MyApp
if you want to automatically reconfigure it when you change something it your logback.xml then use the below in logback.xml
<configuration scan="true" scanPeriod="30 seconds" >
...
</configuration>
Upvotes: 3
Reputation: 32535
logback.xml
is ment to be loaded from external resources as a standalone file, so sysadmin can change logging settings without recompiling the code.
LoggerFactory automaticly picks up any logback.xml
file from the classpath, so in order to use external file, add its containing directory to a runtime classpath.
How to set runtime classpath is described here https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
Upvotes: 1