• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Config Tomcat for SLF4J on Windows

 
Ranch Hand
Posts: 57
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Folks,

I want to use SLF4J on my Windows Apache Tomcatserver but I have no idea how I have to make the Setup to use the logging as well.
There is only a description http://hwellmann.blogspot.de/2012/11/logging-with-slf4j-and-logback-in.html for Linux Systems catalina.sh and not for catalina.bat...

can anybody help me where I have to Change the catalina.bat at wich line and where I have to watchout...

thanks

cheers

Chris
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, in case you were confused (and the Tomcat docs can be confusing here), there are 2 different sets of loggers in effect in a Tomcat server.

The first one is the logger for Tomcat itself, and that's the one that the Tomcat documentation on logging refers to. The second one is the logger for a deployed webapp.

So this is important: Every webapp is totally responsible for its own logging. Webapps do not share loggers with each other or with Tomcat itself.

A quick skim on the URL you provided makes me wonder if the author realized that. It sort of sounds like he was "logging" his webapps via System.out/System.err calls instead of having true logging in the apps and expected Tomcat to do their logging via its own facilities. That is extremely bad practice. A more charitable explanation would be that he's trying to funnel all of the webapp loggers into the Tomcat logger to make it the central log control point. If so, that would be more acceptable.

SLF4J - The Simple Logging Facade for Java - is a framework that allows the construction of applications from multiple components which use different loggers. For example I like to use log4j, but I routinely pull in libraries built on java.util.logging (juli) and Apache Commons logging. SLF4J normalizes all that, translating the logs entries coming from the loggers in my libraries to the common preferred log system for that particular app (in my case, log4j).

Tomcat does not need such a thing under normal circumstances, since Tomcat was designed and implemented as a unit within the Apache Universe. So everyone uses the same logger and there's no need to bridge.

Actually, Logback is the successor for log4j, so what the docs on Tomcat logback really are are an updated version of the instructions provided by Tomcat for replacing the default juli logger with log4j.

So in other words, I'm doubtful that the original projects on which your reference URL refers to were actually about setting up Tomcat for SLF4J, it's just that logback has SLF4J support integrated into it. You had to include a separate external slflog4j component in the older stuff.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic