0

We have a large existing app that has several HttpServlets. These are currently written using log4j logging - except a few of the libs that were written with Java.util.logging uses.

I'd REALLY REALLY like to get them all going through the log4j handling and output formatting.

It looks like I should be able to use slf4j to do this - but I can't find any actual documentation on HOW. Just lots of "yeah, it can things like that". I've added slf4j-api.jar, slf4j-log4j12.jar and jul-to=slf4j.jar to my class path.

Since this doesn't seem to be handling the JUL logging (still coming out in it's own format), there must be something specific that needs to be done to get things hooked up/started - but I haven't been able to find the docs on exactly WHAT is needed.

CasaDelGato
  • 1,263
  • 1
  • 12
  • 29
  • Sorry, I haven't actually tried it myself, so I'm not 100% sure that it works. Assuming that you are talking about log4j2, have you seen the FAQ page where it details which jars you need? If the problem persists, could you raise this in the log4j2 issue tracker? Thanks! – Remko Popma Dec 04 '13 at 22:57

1 Answers1

3

for your problem, you can use the JUL to SLF4J bridge documented in http://www.slf4j.org/legacy.html

Don't forget to call once SLF4JBridgeHandler.install()

If you have the possibility, instead of bridging, I suggest that you use the migrator, resulting code will be cleaner with better performances!

foch
  • 1,039
  • 10
  • 21
  • 2
    This was actually pretty close to the changes needed. I actually had to add 2 lines. (and no, can't use migrator on this code.) "SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install();" – CasaDelGato Dec 10 '13 at 18:43