Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Config Tomcat for SLF4J on Windows  RSS feed

 
Ranch Hand
Posts: 54
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
 
Bartender
Posts: 20770
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!