Can I use Log4j.xml configuration for SLF4J and Logback?

I have a project using common-logging and log4j , I want to change the use of SLF4J + Logback. Is there a way to use existing log4j.xml for a log?

+6
source share
3 answers

If you change the log implementation to logback, you must use the logback.xml configuration file (and its associated format).

+3
source

There is log4j.properties for logback.xml migrator available over the Internet: http://logback.qos.ch/translator/

For log4j.xml files, the structure of the logback.xml files is very similar. Thus, porting your log4j.xml to logback.xml manually should not be difficult. If you encounter difficulties, post a message to the user-user mailing list.

+3
source

You need to use slf4j api compatible replacements for commons-logging and log4j.

http://www.slf4j.org/legacy.html

basically you need to make sure you have jcl-over-slf4j.jar and log4j-over-slf4j in the classpath and delete all copies of commons-logging.jar and log4j.jar. If you are using maven, you probably want to add a lot of exceptions to this in libraries that pull them in.

I have no experience with the magazine, so see the comment above from polypiel for the log4j translator.

+1
source

Source: https://habr.com/ru/post/904304/


All Articles