Chris,
-----Original Message-----
From: Christopher Schultz [mailto:[email protected]]
Sent: Tuesday, March 08, 2016 10:44 AM
To: Tomcat Users List
Subject: Re: Understanding how to controlling what data is written to log4j
appenders
[SNIP]
>> # stdout is set to be a ConsoleAppender.
>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>
> This is what is killing you, plus everything that looks like this:
>
> log4j.logger.com.proginet.sift.struts=${cfi.struts.logging.level}, stdou t
>
> Everything that says log4j.logger.[something]=[level], stdout
>
> Is going to send those log messages to the "stdout" appender, which is tied
> to System.out. You'll need to do one of two things to dig yourself out:
>
> 1. Use swallowOutput="true" on your <Context>, which performs some magic to
> take
> System.out from applications' calls and redirect it elsewhere else (to the
> tomcat-
> defined loggers that can be configured in Tomcat's log4j.properties file).
>
> 2. Change the "stdout" appender to be something other than ConsoleAppender,
> and
> point it at a file on the disk.
>
> I'm not a fan of the first option, but it's sometimes the quickest way to
> handle
> everything all at once, and usually doesn't require any changes to the
> application's
> configuration.
[SNIP]
>> # Set root logger level to ERROR and its only appender to stdout.
>> log4j.rootLogger=ERROR, CFCC
>>
>> log4j.appender.CFCC = org.apache.log4j.DailyRollingFileAppender
>
> That should probably work.
>
> But if you removed log4j.jar from the application, only the global
> log4j.properties
> file will be read. It's okay to have log4j.jar in the bin/ directory as well
> as your
> webapp's WEB-INF/lib directory. The former will run/configure Tomcat's
> logging, and
> the latter will run/configure the application's logging. In fact, if the
> application
> initializes log4j itself (usually by creating a new PropertyConfigurator
> object), then
> weird things can happen with the application re-defining the global
> configuration for
> Tomcat.
>
> I'd recommend having two .jar files and two .properties files, just to be
> safe.
Thanks for taking the time to explain these 2 concepts. It has helped me, and
hopefully the question's originator, understand the interaction between Tomcat
and log4j a little better.
--
Cris Berneburg, Lead Software Engineer, CACI