log4j properties
I am not a Java guy, just a humble integrator trying to get a couple of canned java applications to run together in harmony.
I have two apps that say my log4j.properties file should be in common/classes and that my rootlogger be:
log4j.rootLogger=INFO, R
For one of these to sets of properties, can I change "R" to some other value, or is this explicit because the app that's logging will be looking for "R"?
Here's the whole bit:
# Default log4j.properties for SASH Server
#
log4j.rootLogger=INFO, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.base}/logs/sash-server.log
log4j.appender.R.MaxFileSize=10MB
log4j.appender.R.MaxBackupIndex=5
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{ISO8601} [%t] %c - %m%n
# Settings for Hyperic monitoring agents
#log4j.rootLogger=INFO, R
#log4j.appender.R.File=/usr/local/hyperichq/server-4.0.2/hq-engine/server/default/log/tomcat.log
#log4j.appender.R.MaxBackupIndex=1
#log4j.appender.R.MaxFileSize=5000KB
#log4j.appender.R.layout.ConversionPattern=%d %-5p [%c{1}] %m%n
#log4j.appender.R.layout=org.apache.log4j.PatternLayout
#log4j.appender.R=org.apache.log4j.RollingFileAppender
- Login to post comments


The significance of the "R"
The significance of the "R" is that it is the name of the appender. With the log4j.rootLogger property, you specify a logging level (INFO in your case), and a list of appenders. The appender is configured later on in your log4j.properties file with all of the lines that say "log4j.appender.R ..."
You could change all the "R" to "Steve" and it would still work. But the fact that you have two separate apps with the same appender named "R" should in no way be a problem. In fact, in IDD, all our apps have an appender name "F1", they are are just configured to go to different files. So, probably, you have no need to change anything, just if you want the logging to show up in different files, make the "log4j.appender.R.File" property different. Is there some other reason you'd want to change the appender name?
because knowing is half the battle
I figured that if the appenders had names that told me what the were for, the whole rig would be more self documenting. In this case, one set of log4j properties is for sashserver logging (maybe INFO, SASH) and the other is for the Hyperic performance monitor (maybe INFO, Hyperic).
I am dealing with canned applications here, not applications built here at MIT. So I can't change the apps. But you're saying that the java application doesn't have to know about the appender name. So all I'm doing is piping whatever any app sends to log4j to two different places? That's fine.
Yep, the appender names don't
Yep, the appender names don't really have much significance outside of the log4j.properties file itself.