[logback-user] Migrating LogBack with JUL and Log4j
anton.tagunov at umail.ru
Thu Sep 11 03:02:14 CEST 2008
Kim> My group is considering using LogBack for our project, and I'm trying to
Kim> figure out there's a painless way to migrate both JUL logs and Log4j to
Kim> LogBack? We are currently using some Log4j, but we also use EclipseLink
Kim> which uses JUL. Any help is appreciated.
Ceki> Use slf4j-migrator  to migrate the source code of your applications to SLF4J.
Ceki> Use log4j-over-slf4j and/or jul-to-slf4j to redirect log4j, respectively JUL
Ceki> logs to SLF4J. See http:// slf4j.org/legacy.html for more information.
Kim> Another question, do you loose any functionality when you use these "migrators"?
Kim> Are you still able to print out method names and/or line numbers?
I understand "migrator" is an automated source code rewriting tool.
I guess it will change import statements and perhaps lines of code related to logging.
After you've successfully used a migrator you'll get (I guess again) an application that will only need slf4j and logback on the classpath.
This won't work with 3rd party libraries of course.
For them you either don't have source code or you don't want to maintain your own version.
Alternatively you can replace log4j.jar with log4j-over-slf4j.jar
Similarly replace java commons logging jar with jul-to-slf4j.jar
I suggest that you download source code for these packages and see for yourself what they're doing.
In this case no code modification will be necessary.
Both in case 1 and case 2 you can still use full power of logback configuration. Yes, method names can be part of log message regardless of doing (1), (2) or writing your code to use slf4j from scrach.
More information about the Logback-user