Mavlarn
Mavlarn

Reputation: 3883

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

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

Upvotes: 6

Views: 7999

Answers (3)

Jilles van Gurp
Jilles van Gurp

Reputation: 8284

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

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

basically you need to make sure that you have jcl-over-slf4j.jar and log4j-over-slf4j on the classpath and remove any copies of commons-logging.jar and log4j.jar. If you use maven, you'll probably want to add a lot of exclusions for this on libraries that pull these in.

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

Upvotes: 1

Ceki
Ceki

Reputation: 27450

There exists a log4j.properties to logback.xml migrator available online: http://logback.qos.ch/translator/

For log4j.xml files, there structure of logback.xml files is very similar. Thus, it should not be hard to migrate your log4j.xml to logback.xml manually. If you run into trouble please post on the logback-user mailing list.

Upvotes: 3

Jean-Philippe Briend
Jean-Philippe Briend

Reputation: 3515

If you change the logger implementation to logback, you should use a logback.xml config file (and its associated format).

Upvotes: 3

Related Questions