David Filip
2018-10-08 18:27:41 UTC
Dear Tomcat Users,
Apologies if this is more of a log4j question, but I thought that I'd start here, in case Tomcat has any easy remedies.
I have a common webapp that I deploy to multiple, different contexts.
In log4j.properties, I have a few different log files defined, e.g., for logins:
log4j.appender.logins=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logins.file=${catalina.home}/logs/logins.log
log4j.appender.logins.datePattern='.'yyyy-MM-dd
log4j.appender.logins.append=true
log4j.appender.logins.layout=org.apache.log4j.PatternLayout
log4j.appender.logins.layout.ConversionPattern=[%d{MM/dd/yyyy HH:mm:ss}] [%p] [%C{1}]: %m%n
log4j.logger.com.colornet.CAP.Actions.LoginAction=info, logins
log4j.logger.com.colornet.CAP.Util.LoginTokenTag=info, logins
However, as you may have guessed, if I have the same log4j configuration file for each context, the contexts tend to over-write each other.
Is there any way to have the SAME log4j.properties deployed too multiple contexts play nicely and not overwrite each other, but merely append each other?
Extra credit question (although sounds even more like a log4j question, so apologies): If not, is there any way to define the file path, e.g.:
log4j.appender.logins.file=${catalina.home}/logs/logins.log
to include the specific context? I have found a few references on the 'Net, e.g., ${contextPath}, ${servletName}, etc., which don't seem to work.
My goal (desire?) is to have the same webapp and configuration and web.xml and log4j.properties, etc., deployed to every web context, but not have one context overwrite another content's entries.
Of course, as the Mick once said, "You can't always have what you want".
Please let me know if this is possible.
Thanks,
Dave.
Apologies if this is more of a log4j question, but I thought that I'd start here, in case Tomcat has any easy remedies.
I have a common webapp that I deploy to multiple, different contexts.
In log4j.properties, I have a few different log files defined, e.g., for logins:
log4j.appender.logins=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logins.file=${catalina.home}/logs/logins.log
log4j.appender.logins.datePattern='.'yyyy-MM-dd
log4j.appender.logins.append=true
log4j.appender.logins.layout=org.apache.log4j.PatternLayout
log4j.appender.logins.layout.ConversionPattern=[%d{MM/dd/yyyy HH:mm:ss}] [%p] [%C{1}]: %m%n
log4j.logger.com.colornet.CAP.Actions.LoginAction=info, logins
log4j.logger.com.colornet.CAP.Util.LoginTokenTag=info, logins
However, as you may have guessed, if I have the same log4j configuration file for each context, the contexts tend to over-write each other.
Is there any way to have the SAME log4j.properties deployed too multiple contexts play nicely and not overwrite each other, but merely append each other?
Extra credit question (although sounds even more like a log4j question, so apologies): If not, is there any way to define the file path, e.g.:
log4j.appender.logins.file=${catalina.home}/logs/logins.log
to include the specific context? I have found a few references on the 'Net, e.g., ${contextPath}, ${servletName}, etc., which don't seem to work.
My goal (desire?) is to have the same webapp and configuration and web.xml and log4j.properties, etc., deployed to every web context, but not have one context overwrite another content's entries.
Of course, as the Mick once said, "You can't always have what you want".
Please let me know if this is possible.
Thanks,
Dave.