You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Michael Schaefer <st...@yahoo.com> on 2003/06/12 15:58:06 UTC

Using a specific appender at runtime and calling it by name?

I'm reposting this question since I wasn't a member of the mailing 
list when I posted this on Yahoo so I don't think it showed up.

I have the following settings in my log4j.properties file:

log4j.rootLogger=DEBUG, stdout, normal
log4j.logger.SomeUniqueString=DEBUG, requestLog

# Setup stdout appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{dd/MM/yy HH:mm} [%-
5p] %c{1} - %m%n

# Setup Default Appender
log4j.appender.normal=org.apache.log4j.RollingFileAppender
log4j.appender.normal.File=normal.log

# Setup requestLog Appender
log4j.appender.requestLog=org.apache.log4j.RollingFileAppender
log4j.appender.requestLog.File=requests.log


When I try and access the logger and log a test message with the 
following code the message never appears:

Logger.getLogger("SomeUniqueString").info("This is a test.");

My expectation, given the reading I've done, is that the line of code 
above would give me access to a logger using the "requestLog" 
appender. Invoking that should put an [INFO] entry into 
the "requests.log" logfile. However, the logfile is always a zero 
byte file. All the other logging in the application outputs 
to "normal.log" just fine. I need to be able to log requests to our 
system in a separate logfile with a separate format. Can someone 
please give me a nudge in the right direction on how to solve this 
problem? Thanks,


Michael




---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org