How can I configure logging separately for Tomcat, application and logged library?

I am trying to essentially set up logging in three places, regardless. Ideally, every component that registers is completely unaware of the others. I would like to use logback for this as it seems to have some decent features and performance.

Here are the places I would like to register from and:

  • Tomcat (7) should register with $ {catalina_home} /logs/catalina.out and should only log Tomcat events (deployments, server startup, etc.).
  • A web application hosted in Tomcat should log in $ {catalina_home} /logs/application.log and should only log applications such as validation results or query errors.
  • A library included in a web application should log into $ {catalina_home} /logs/library.log and should only log events related to that library, such as the time it takes to interact with some other web service or library - specific mistakes

I know this is probably not how it will work, but I think I need to have a logback.xml file for every problem. In fact, I created them and added them to the classpath in such a way that I get the error "logback.xml occurs multiple times on a classpath error."

I can understand why I would need to consolidate my application and log configuration into a single logback.xml file, but how can I keep the container logging configuration separate from the application and library logging configuration? Adding a log config file to my application as well as a log enabling Tomcat as described here still results in a "multiple logback.xml" error. And Chapter 9 of the log user guide, which talks about splitting the log, doesn't really show how to split the container and apps (just multiple apps) unless I'm missing something there.

+3


source to share





All Articles