Environment is RHEL6, Tomcat 7.0.42. There is only one webapp.

I'm trying to implement log4j as per the instructions here (skipping step
5):
http://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j

Since I'm not using the Manager, I've removed the relevant logging lines
from CATALINA_HOME/lib/log4j.properties, 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.
log4j.appender.CATALINA.Append=true
log4j.appender.CATALINA.Encoding=UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n

log4j.appender.LOCALHOST=org.apache.log4j.DailyRollingFileAppender
log4j.appender.LOCALHOST.File=${catalina.base}/logs/localhost.
log4j.appender.LOCALHOST.Append=true
log4j.appender.LOCALHOST.Encoding=UTF-8
log4j.appender.LOCALHOST.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.LOCALHOST.layout = org.apache.log4j.PatternLayout
log4j.appender.LOCALHOST.layout.ConversionPattern = %d [%t] %-5p %c- %m%n

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Encoding=UTF-8
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern = %d [%t] %-5p %c- %m%n

# Configure which loggers log to which appenders
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO,
LOCALHOST
_____________________________

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
_____________________________

Ok, so this isn't what I want. First there are three "catalina*" files.
Each has different aspects of my app and/or server.

The "catalina." file has info about NIO, the deltamanager, as well as my
application logging code (e.g.,logger.warn("hello world");).

"catalina.2013-12-03.log" has a few lines about starting and stopping the
server like:
"A valid shutdown command was received via the shutdown port. Stopping the
Server instance."

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

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

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.

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.

3. Get rid of the empty localhost. file.

MTIA,
Alec

Reply via email to