commons-logging and log4j properties file

守給你的承諾、 提交于 2019-12-03 05:56:01

The file commons-logging.properties is only read from commons logging while log4j will look for log4j.configuration in the system properties.

So you must either specify them with -Dlog4j.configuration=log4j-test.properties on the command line as a JVM option or you must call System.setProperty() before the first call to any logging method (which is usually pretty hard to achieve).

Note: If you can, use the XML config log4j.xml; it's much more simple and powerful for configuring log4j.

aerobiotic

You need to add the protocol to the front of System property value like so: -Dlog4j.configuration=file://log4j-test.properties

Without the protocol it will look in the classpath.

zg_spring

jul - commons-logging, it likes your situation.

org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

set log4j.properties, before instance of Log.

System.setProperty("log4j.configuration", "log4j.properties");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!