On 3/30/06, Tim Watts <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Does anyone have an idea why all my log entries are posted twice in the
> log?
It looks like you attached your appenders twice - once for the root logger
and once for a specific logger. Since you haven't turned off additivity in
any logger, every log event that happens at, say, com.inxight.* gets sent to
the Console and Logfile appenders, and THEN, since its additivity is on, the
same event gets relayed up the hierachy until it reaches the root logger.
Since the root logger has the appenders Console and Logfile appenders
attached, you see the log events twice. A way to fix this is to set
additivity in your loggers to false. The other one is to implement your
appenders with additivity in mind.
> The other weird thing is that although the log level is set for INFO, only
> warn or greater gets logged. I turned log4j.debug on and verified that
> it's
> finding the correct file. What's going on?
I see your test code sends warn level messages - have you tried it with
logger.info(), logger.debug()?
According to your config file, you should see Warn or higher at the console,
and all messages in the log file. Does this happen?
== begin cfg ===================================
> # Set root category priority to INFO and its only appender to CONSOLE.
> log4j.rootCategory=WARN, CONSOLE, LOGFILE
> #log4j.rootCategory=INFO, CONSOLE, LOGFILE
>
> log4j.logger.com.inxight=INFO, CONSOLE, LOGFILE
> log4j.logger.org.apache=WARN, CONSOLE, LOGFILE
> log4j.logger.servletunit=WARN, CONSOLE, LOGFILE
>
> # Set the enterprise logger category to FATAL and its only appender to
> CONSOLE.
> log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE
>
> # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
> log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
> log4j.appender.CONSOLE.Threshold=WARN
> log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
> log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
>
> # LOGFILE is set to be a File appender using a PatternLayout.
> log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
> log4j.appender.LOGFILE.File=${user.home}/sdxadminui.log
> log4j.appender.LOGFILE.Append=true
> log4j.appender.LOGFILE.MaxFileSize=5MB
> log4j.appender.LOGFILE.MaxBackupIndex=1
> log4j.appender.LOGFILE.Threshold=DEBUG
> log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
> log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
> == end cfg ===================================
>
> == begin pgm ===================================
> package com.inxight.sdx.adminui;
>
> import org.apache.log4j.Logger;
>
> public class LogTest {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> Logger logger = Logger.getLogger(LogTest.class);
> logger.warn("this is a test.");
> }
>
> }
> == end pgm===================================
>
> == begin classpath ===================================
> CLASSPATH=WebSite/WEB-INF/classes/
> CLASSPATH=$CLASSPATH:bin
> CLASSPATH=$CLASSPATH:WebSite/WEB-INF/lib/log4j-1.2.8.jar
> export CLASSPATH
> == end classpath ===================================
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Javier González Nicolini