-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

David,

On 10/8/18 14:27, David Filip wrote:
> 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.

I'm not sure it's really a great idea to have all these separate
context logging to the same log file(s), but here is a way to do this:

1. Move (*move!*) your log4j.jar file from WEB-INF/lib to Tomcat's
lib/ directory

2. Move (*move!) your log4j.properties file from WEB-INF/classes to
Tomcat's lib/ directory. You may have to wrap it in a JAR file.

This ought to allow log4j to initialize a single time, and each
application will use that singly-initialized log4j instance.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlu+EwQACgkQHPApP6U8
pFjKIA//UL0KHt11kczm28Yv9Ab9WbdHXxnG3dqC25q+HTA1Eq5wu/pTfCGPoa03
R4Sc5r3HpapyeMtZR1XFCPVFPAgbiHQeCD7Bkduw0bCKV8ZOvRJJOgqiXHYiW0cF
RuThsq/txShzRZ1KLqGOuZvfA6MsjIEXdWNdnbSH5g5lDT1mRsabzEpdqbkWXc8W
wru1VWZBNHQwU1k1wZ7ts1jVKZQzJhcO1scs/RWXIHNs8R+dADNsWcsqWzYyeuAm
nWYfhsN03/ilQwBjpAqDBsSnt7a3TvLW4Zh9XrcJylHenOdewj53MdL4AnjS7zUS
+TL3xHB+y8GEIUEsxuuAZy0sKVoPfApEHVovp6cTXzSUi+4fn+gBG2E0zL2o87GD
dfoBsgN3gpMw3oGqB2C67El/ECLIVdo6gU/kw1Pq/asMJPwFMK9OPWk06ScXec7n
ff52KuNt9Oedsm12J7d/GkfMb/8KtvTvzRI30FVf5phCvdkZrOPA0Nsuy40z+jcI
vOwIVcqONUDuG1rkD6Qnm5KwoBDJfkkNTy7BxJS5qtQmCV3dUDm3vvcm5cNzFXlK
b5yvp7UvAPyg13AdjGQd6C0rtG8p+RtTmwJvEZU4bQ16ZYWyQUDhVdLAnvgjb9Iv
jJxF2gAvcLxoqMnEh2AdWCSJjfrQkrZi/4vAYaFYK60EMnElh4w=
=5bwl
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to