Bug 43682 - JULI: web-inf/classes/logging.properties to support ${context} tag
JULI: web-inf/classes/logging.properties to support ${context} tag
Product: Tomcat 6
Classification: Unclassified
Component: Catalina
Other other
: P2 enhancement with 1 vote (vote)
: default
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2007-10-23 07:03 UTC by Mailmur
Modified: 2014-10-07 15:51 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Mailmur 2007-10-23 07:03:49 UTC
It would be a good to have "${context}" placeholder variable in JULI
logging.properties file. We could use it in a ".prefix" attribute to dynamically
use webapp's name as a file prefix.

Then if we have a web application, that can be installed 1...n copies to a same
Tomcat, we could use it out-of-the-box and each having separate log files.

  com.outerrim.catalina.logger.FileHandler.prefix = ${context}.

As it stands today, we must duplicate the webappname in a logging properties.

  handlers = com.outerrim.catalina.logger.FileHandler
  com.outerrim.catalina.logger.FileHandler.directory = ${catalina.base}/logs
  com.outerrim.catalina.logger.FileHandler.prefix = mywebapp.

  handlers = com.outerrim.catalina.logger.FileHandler
  com.outerrim.catalina.logger.FileHandler.directory = ${catalina.base}/logs  
  com.outerrim.catalina.logger.FileHandler.prefix = my2ndwebapp.
Comment 1 Jesse Barnum 2014-01-09 19:44:37 UTC
I need this feature as well. In my use case, I don't know what my users are going to name the application, and they could install multiple copies of the application with different names, so hard-coding the application name multiple times isn't a workaround.
Comment 2 Konstantin Kolinko 2014-01-09 20:11:11 UTC
I think a possible way to go is in two steps:

1. Allow ${jndi:...} properties in WEB-INF/classes/logging.properties file.

E.g. LogBack has similar feature. See 2013-03 thread "Register static JNDI env entry dynamically" on users@ for an example.

2. Allow ${catalina.context.xxx} substitutions in context.xml files, so that one could use it in an <Environment> element to configure a value for JNDI.

An open question to me is what kinds of '.xxx' are needed, to get something usable from a context name. Something like '.baseName', '.displayName', '.name', '.path', '.version'.


Another solution for this step can be a Listener, like shown in above mentioned thread.
Comment 3 Michael Osipov 2014-01-10 21:30:49 UTC
For what it's worth, I have writted a Listener for exactly that problem. It works flawlessly with Logback or anything else which is capable of using JNDI. See: http://mo-tomcat-ext.sourceforge.net/user-guide.html#LogbackContextNameListener

I did not write anything for JULI because that system is a dead end (imho).
Comment 4 Mark Thomas 2014-10-07 12:36:52 UTC
This has been fixed in 8.0.x for 8.0.15 onwards.

I do not intend to propose it for backport to 7.0.x or 6.0.x.
Comment 5 Jesse Barnum 2014-10-07 15:51:27 UTC
Thank you Mark! That's excellent news.