
I'm successfully using logback with Tomcat and have a small suggestion that will help people with complex deployments: look for logback-access.xml in system property catalina.base rather than catalina.home. Tomcat is intentionally setup such that multiple instances (java VMs) can be running off the same copy of the tomcat distribution and set up private CATALINA_BASE directories for server config, logs, temp space, etc. Such setups will naturally want to configure logback in CATALINA_BASE, not in the (potentially read-only) CATALINA_HOME. In cases where the user does *not* set CATALINA_BASE, it takes the same value as CATALINA_HOME (which is generally the same as TOMCAT_HOME). I've patched the source of LogbackValve.java to do this and it works well. The change of "catalina.home" to "catalina.base" is to trivial for a formal patch... On a related note, I've also configured tomcat to use log4j/logback for internal logging, which also works quite well. I noticed in a previous post you "don't recommend this at this time" and would like to know the reason(s). Routing *all* logging through one logger/one config, which in turn can separate "live" logs from rotated out "archive" logs in a separate directory is a godsend. I'm assuming it is because doing this requires mucking around with the tomcat startup scripts to replace ACL from the very beginning of the tomcat boot process. I'd already created a "boot" directory with a dynamic set of jar's and classes (for unrelated reasons) so switching ACL to log4j/logback was pretty trivial for me. Is there more to the reluctance than the fact that there is no "drop in" way to do it? If there's interest, I can tidy up my tomcat patch and post the details. -- View this message in context: http://www.nabble.com/Using-logback-in-tomcat-tf2890321.html#a8074672 Sent from the Logback User mailing list archive at Nabble.com.

Hello Michael, Comments inline. At 02:26 PM 12/28/2006, Michael Abato wrote:
I'm successfully using logback with Tomcat and have a small suggestion that will help people with complex deployments: look for logback-access.xml in system property catalina.base rather than catalina.home.
Excellent news. Thank you for letting us know.
Tomcat is intentionally setup such that multiple instances (java VMs) can be running off the same copy of the tomcat distribution and set up private CATALINA_BASE directories for server config, logs, temp space, etc. Such setups will naturally want to configure logback in CATALINA_BASE, not in the (potentially read-only) CATALINA_HOME.
In cases where the user does *not* set CATALINA_BASE, it takes the same value as CATALINA_HOME (which is generally the same as TOMCAT_HOME).
I've patched the source of LogbackValve.java to do this and it works well. The change of "catalina.home" to "catalina.base" is to trivial for a formal patch...
Sounds reasonable. I'll let Sebastien make the change.
On a related note, I've also configured tomcat to use log4j/logback for internal logging, which also works quite well. I noticed in a previous post you "don't recommend this at this time" and would like to know the reason(s). Routing *all* logging through one logger/one config, which in turn can separate "live" logs from rotated out "archive" logs in a separate directory is a godsend.
I'm assuming it is because doing this requires mucking around with the tomcat startup scripts to replace ACL from the very beginning of the tomcat boot process. I'd already created a "boot" directory with a dynamic set of jar's and classes (for unrelated reasons) so switching ACL to log4j/logback was pretty trivial for me. Is there more to the reluctance than the fact that there is no "drop in" way to do it?
What is ACL? We made a quick and unsuccessful attempt at directing tomcat's internal logs to logback. So, we could not decently recommend a solution which does not work for us.
If there's interest, I can tidy up my tomcat patch and post the details.
Yes, we are definitely interested. Happy new year, -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

This change (which is pretty importantant in an "enterprise" style environment) never got into the code base: $ svn diff Index: logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java =================================================================== --- logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java (revision 1509) +++ logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java (working copy) @@ -103,7 +103,7 @@ public void start() { if (filename == null) { - String tomcatHomeProperty = System.getProperty("catalina.home"); + String tomcatHomeProperty = System.getProperty("catalina.base"); filename = tomcatHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE; I also can't find the post regarding bootstrapping tomcat with logback intercepting all logging - did that ever get through? I've been running that way for some time and have not seen any problems. The resulting control, consolidation and archiving of logs is fantastic! - mike -- View this message in context: http://www.nabble.com/Using-logback-in-tomcat-tf2890321.html#a10035474 Sent from the Logback User mailing list archive at Nabble.com.
participants (2)
-
Ceki Gülcü
-
Michael Abato