tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Logging makes a grown man cry
Date Wed, 04 Dec 2013 17:38:49 GMT
Hash: SHA256


On 12/3/13, 1:12 PM, Tomcat Random wrote:
> I'm trying to implement log4j as per the instructions here
> (skipping step 5): 
> Since I'm not using the Manager, I've removed the relevant logging
> lines from CATALINA_HOME/lib/, so it looks like
> this:
> _____________________________ log4j.rootLogger=INFO, CATALINA
> # Define all the appenders 
> log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender 
> log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.

This appender creates the "catalina." file, so you are doing this to

> log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'

This will move "catalina." to "catalina..yyyy-MM-dd.log" every time
the date rolls over (actually, when the first log from the following
day is written). So, you are creating "catalina..yyyy-MM-dd.log" yourself.

"catalina.out" is impossible to avoid, because stdout *must* go
somewhere. If you want, you can set CATALINA_OUT to /dev/null but then
you might miss crucial log messages.

> log4j.appender.LOCALHOST=org.apache.log4j.DailyRollingFileAppender 
> log4j.appender.LOCALHOST.File=${catalina.base}/logs/localhost.

You are creating this file. If you don't send any log messages to it,
that's your fault. If you don't want it, don't configure it.

> _____________________________
> On restart, my (deleted-beforehand) logs directory looks like
> this:
> /logs/catalina. /logs/catalina.2013-12-03.log /logs/catalina.out 
> /logs/cluster.2013-12-03.log /logs/localhost. 
> /logs/localhost_access_log.2013-12-03.txt 
> _____________________________

I would have expected your filenames to contain two sequential dots
before the dates because your ".File" property ends with a dot and
your ".DatePattern" begins with a dot.

> "catalina.out" has spymemcached logging info (I haven't changed
> the spymemcached  system property yet to log4j so that might be
> why).

It's also possible that spymemcached is writing directly to System.out
(or System.err). You might want to check on that. Or it may be logging
to ServletContext.log().

> "cluster.2013-12-03.log" is behaving normally. "localhost." is
> empty. And the daily access log is good.

Odd... as you have not configured such a log about. That must be
happening elsewhere.

> So, all I want is to have:
> 1. one log file that rolls daily (a new file each day), with the
> date appended, that catches my own logging code in the app, based
> on a global logging level value that I can change (DEBUG, or INFO,
> or ERROR etc) as needed.

You cannot avoid catalina.out unless you do something dumb like
sending stdout to /dev/null.

> 2. Another log file that rolls daily and consolidates any other
> output of the server and app (or two separate files) and also has a
> logging level value that can be changed globally.

No problem. What you have above should work for that.

> 3. Get rid of the empty localhost. file.

Just remove the configuration for the LOCALHOST appender and that will
solve this problem.

As Konstantin suggested, you should read the documentation for log4j.
What is in the Tomcat documentation is just a suggestion to get you

- -chris
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Thunderbird -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message