简体   繁体   中英

How to override log4j properties for all the imported Java libraries?

I am using Clojure but I think this is irrelevant to the question. I would like to override the log4j properties for all the imported libraries and have the exact same format for all. 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.

But if you require the properties file, add an argument to the Java Virtual Machine, eg:

java -Dlog4j.configuration=file:/tmp/log4j.properties KillerApp

Agree witht he use of log4j.xml.

The cloure Luminus framework has a nice default setup for using log4j. Strongly encourage laziness and recommend ahving a look at that for one way of handling log4j setup in clojure projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM