On 11/10/2011 07:28, Dan Checkoway wrote: > Hello, > > I run several webapps under one instance of tomcat (7.0.21 currently, fwiw), > and each webapp uses JDK logging and needs to log to its own separate log > file. I accomplish this by placing logging.properties in WEB-INF/classes, > and an example of how it's set up is: > > handlers = org.apache.juli.FileHandler > > org.apache.juli.FileHandler.level = FINE > org.apache.juli.FileHandler.directory = ${catalina.base}/logs > org.apache.juli.FileHandler.prefix = my-webapp. > org.apache.juli.FileHandler.formatter = > com.mycompany.logging.MyCustomFormatter > > ...all of my logging levels...
You can configure the main logging.properties to output separate files per application, as per: http://tomcat.apache.org/tomcat-6.0-doc/logging.html The Manager application is configured like this. p > (and fwiw, my custom logging formatter lives in a jar that I place in > $TOMCAT_HOME/endorsed) > > It works great. The challenge I face, however, is that I deploy my webapps > as .war files, and I'd like to be able to deploy the same exact .war file to > different environments...dev, test, staging, production. And I'd like to be > able to use different logging level config in each of those environments. > As it stands right now, I'm sorta confined to that single instance of > logging.properties that gets "built into" my webapp. I want to > "externalize" this moving part if possible. > > I played around with omitting logging.properties from my webapp, and instead > using just $TOMCAT_HOME/conf/logging.properties, but (a) I wasn't able to > get it to work the same as it's working right now, and (b) that funnels me > into "sharing" logging level config across my webapps (in other words, > webapp 1 can't have a different logging level for package x.y.z than webapp > 2). Forget (b) for the time being, since I can live with shared logging > levels across webapps. The main issue I'm having with this approach is that > I can't seem to get *all* of my logging to go to my webapp-specific log > file. Some stuff still gets logged to catalina.out. > > So... > > 1. Is it currently possible to do what I'm trying to do? Per-webapp logging > control without using WEB-INF/classes/logging.properties? I could really > use a working example if this is doable. > > 2. Is there any other hook I can take advantage of (i.e. a context listener > or something), by which my code can get invoked prior to JULI initializing > for my webapp, where I might be able to override the > java.util.logging.config.file system property, or something like that? > > 3. If neither of those options is possible, how feasible would it be to add > a feature to tomcat, where you can configure a path to logging.properties > (in theory classpath: or file: style) on a per-webapp basis? i.e. in > conf/server.xml in the <Context>. > > Or if there's an easier way, shove me toward it... > > Thanks, > Dan >
signature.asc
Description: OpenPGP digital signature