I want to have more control over what data is written to the various
appenders in the log4j.properties files. I have played around with the
various configurations in the log4j.properties file but I am not
understanding how they are working in order to grasp how to have more
control. I don't know if it would be a matter of turning off the INFO
setting for the log4j.rootLogger and somehow setting individual logging for
each appender.

Below is my environment details:
1) The tomcat version that is running is v8.0.26.0
2) The OS is a Centos v7 UNIX VM
3) Java JDK I have installed that Tomcat is using is 1.8.0_60
4) Due to the catalina.out file growing too large with the default
juli.AsyncFileHandler using the logging.properties file that was found in
the $CATALINA_HOME/conf directory. I changed the settings on a vendors
software to use the log4j logging instead. (So this is NOT my web
application or product written by me.)
5) I set the swallowOutput="true" in the vendors <context>.xml file to stop
messages for stdout and stderr from going to the catalina.out files.
6) Most messages are now going to the catalina (no extention) and/or the
localhost files which are rolled over daily when there is activity.
7) The vendors web application uses the context of cfcc. The Connector
details are found in the
<CATALINA_HOME>\server\conf\Catalina\localhost\cfcc.xml
8) I have A LOT of duplication in the log files. I would like to change
that if I can.
9) Below are my log4j.properties settings:

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.CFCC=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CFCC.File=${catalina.base}/logs/cfcc
log4j.appender.CFCC.Append=true
log4j.appender.CFCC.Encoding=UTF-8
log4j.appender.CFCC.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CFCC.layout = org.apache.log4j.PatternLayout
log4j.appender.CFCC.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.MANAGER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.MANAGER.File=${catalina.base}/logs/manager.
log4j.appender.MANAGER.Append=true
log4j.appender.MANAGER.Encoding=UTF-8
log4j.appender.MANAGER.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.MANAGER.layout = org.apache.log4j.PatternLayout
log4j.appender.MANAGER.layout.ConversionPattern = %d [%t] %-5p %c- %m%n

log4j.appender.HOST-MANAGER=org.apache.log4j.DailyRollingFileAppender
log4j.appender.HOST-MANAGER.File=${catalina.base}/logs/host-manager.
log4j.appender.HOST-MANAGER.Append=true
log4j.appender.HOST-MANAGER.Encoding=UTF-8
log4j.appender.HOST-MANAGER.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.HOST-MANAGER.layout = org.apache.log4j.PatternLayout
log4j.appender.HOST-MANAGER.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].[/cfcc]=INFO,
CFCC

log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=OFF,
LOCALHOST
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]=\
  INFO, MANAGER
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]=\
  INFO, HOST-MANAGER

At this time ALL the same messages are written to the cfcc and the
localhost log files. Absolutely no difference. All the messagse that
are written to these two logs are also in the catalina log alongs with
the tomcat startup messages. I would like to separate the tomcat
startup messages from the web application messages that are written to
both the localhost and cfcc logs.

Thank you for your help in advance.

-Joleen

Reply via email to