log config
java
SpringBoot的logback如何配置?1
The default strategy assumes that if you don't have a logback.xml (or one of the other standard file names) in the classpath then you must be happy with the defaults (see LogbackLoggingSystem for details). Spring Boot tries to unify the external configuration switches for common logging sytems, so it looks in logging.config (it didn't know about logback.configurationFile). You could use that instead (i.e. logging.config=file:./src/test/resources/logback.xml), or make sure your config file is on the classpath.
如果是log4j 1.x:
java -jar -Dlog4j.configuration=[file:/full_path/log4j.properties] final.jar
log4j 2.x:
java -Dlogback.configurationFile=logback-test.xml -cp . -jar target/benchmarks.jar StringConcat
- Logback tries to find a file called logback.groovy in the classpath.
- If no such file is found, logback tries to find a file called logback-test.xml in the classpath.
- If no such file is found, it checks for the file logback.xml in the classpath..
- If neither file is found, logback configures itself automatically using the BasicConfigurator which will cause logging output to be directed to the console.
Where should the configuration files such as logback.groovy, logback-test.xml or logback.xml be located on the classpath?
Configuration files such as logback.groovy, logback-test.xml or logback.xml can be located directly under any folder declared in the class path. For example, if the class path reads “c:/java/jdk15/lib/rt.jar;c:/mylibs/“ then the logback.xml file should be located directly under “c:/mylibs/“, that is as “c:/mylibs/logback.xml”. Placing it under a sub-folder of c:/mylibs/, say, c:/mylibs/other/, will not work.
For web-applications, configuration files can be placed directly under WEB-INF/classes/.
So you need to put logback.xml in the classpath. On one project we had a similar problem although logback.xml was in the right place. Renaming it to logback-test.xml helped.