[英]How to override log4j properties for all the imported Java libraries?
I am using Clojure but I think this is irrelevant to the question. 我正在使用Clojure,但我认为这与问题无关。 I would like to override the log4j properties for all the imported libraries and have the exact same format for all.
我想为所有导入的库覆盖log4j属性,并为所有具有完全相同的格式。 Right now it looks like this:
现在看起来像这样:
2014-11-26 19:37:19.399 INFO net.spy.memcached.auth.AuthThread: Authenticated to ae-couchbase10/10.52.61.37:11210
INFO: {:thread-name async-dispatch-2, :first_id batch::test::dev::934ebce6-b78d-4f7c-b297-f636cbfeca0c::8307a507-7deb-40dc-811a-b339148472e7, :time 171.587344, :perf 5.967806110455326}
What is the best way of doing that? 最好的方法是什么?
If you use XML-based configuration, ie the log4j.xml
file, this will have a higher priority over any log4j.properties
file that exists in any library. 如果您使用基于XML的配置,即
log4j.xml
文件,则它将比任何库中存在的任何log4j.properties
文件具有更高的优先级。
But if you require the properties file, add an argument to the Java Virtual Machine, eg: 但是,如果需要属性文件,请向Java虚拟机添加一个参数,例如:
java -Dlog4j.configuration=file:/tmp/log4j.properties KillerApp
Agree witht he use of log4j.xml. 同意使用log4j.xml。
The cloure Luminus framework has a nice default setup for using log4j. Cloure Luminus框架具有使用log4j的不错的默认设置。 Strongly encourage laziness and recommend ahving a look at that for one way of handling log4j setup in clojure projects.
强烈鼓励您懒惰,并建议您看一下它来处理clojure项目中的log4j设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.