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 William Mok <wm...@memotrax.com> on 2005/08/16 19:35:07 UTC

Log4j Configuration

Hi,

I have the following log4j.properties file:

---------------------------------------------------------------------------------------------------------------
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE
#log4j.rootCategory=INFO, 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=INFO
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.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=INFO
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
------------------------------------------------------------------------------------------------------------------------------------

At the same time, I also have the following lines in my java servlet

------------------------------------------------------------------------------------------------------------------------------------
           Logger logger = Logger.getLogger(EchoService.class);
                BasicConfigurator.configure();

                SimpleLayout layout = new SimpleLayout();

                FileAppender appender = null;

                try
                {
                        appender = new FileAppender(layout,"connectionlog.txt",true);
                }
----------------------------------------------------------------------------------------------------------------------------------------

Questions:

1. So how does this configuration work, does the java code override the configuration on properties file?
2. What does BasicConfigurator do?
3. In propertes file, log4j.appender.LOGFILE.File=axis.log, but I cannot find this axis.log anywhere after running the servlet.
In the java servlet, I have the line "appender = new FileAppender(layout,"connectionlog.txt",true);", but I cannot find the connectionlog.txt file anywhere. 

Thanks.

William