I switched my properties file to an xml configuration file and I still cannot get it to work. I have tried both the LevelMatchFilter and the LevelRangeFilter.
Below is my current configuration file: No matter what I try, I seem to either get nothing in the lcd.log file, or all messages. I only want trace messages. I changed from a LevelMatchFilter b/c I found someone complaining that it did not work - that the other levels returned "neutral", so they too match (and indeed were logged to log file). Then I tried specifying the rest of the log levels - fatal, error, info, debug with a value of "false" for AcceptOnMatch. That didn't work either. There seems to be something fundamentally that I am missing, but I can't seem to figure it out. What is the trick to using either a LevelMatchFilter or a LevelRangeFilter? Thanks, Beth <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out"/> <param name="Threshold" value="INFO"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%d{MM/dd/yyyy HH:mm:ss}] %-p (%-F:%-L) - %m%n"/> </layout> </appender> <appender name="rolling" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="/data/logs/pdlg.log"/> <param name="Threshold" value="INFO"/> <param name="MaxFileSize" value="100KB"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%d{MM/dd/yyyy HH:mm:ss}] %-p (%-F:%-L) - %m%n"/> </layout> </appender> <appender name="errorCache" class="org.apache.log4j.FileAppender"> <param name="File" value="/data/logs/errorcache.log"/> <param name="Threshold" value="ERROR"/> <layout class="com.xxx.pdlg.businesslogic.logging.PdlgShortLayout" /> </appender> <appender name="lcd" class="org.apache.log4j.FileAppender"> <param name="File" value="/data/logs/lcd.log"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%d{MM/dd/yyyy HH:mm:ss}] %-p - %m%n"/> </layout> <filter class="org.apache.log4j.varia.LevelRangeFilter"> <param name="LevelMin" value="TRACE"/> <param name="LevelMax" value="TRACE"/> <param name="AcceptOnMatch" value="true" /> </filter> </appender> <logger name="com.xxx.pdlg" additivity="false"> <appender-ref ref="rolling" /> <appender-ref ref="errorCache" /> <appender-ref ref="lcd" /> </logger> <root> <appender-ref ref="console" /> </root> </log4j:configuration> -----Original Message----- From: James A. N. Stauffer [mailto:[EMAIL PROTECTED] Sent: Friday, February 01, 2008 7:10 PM To: Log4J Users List Subject: Re: logging only one level of messages With XML config you can use a LevelFilter and put a cap on the level. On Feb 1, 2008 8:23 PM, Beth Hechanova <[EMAIL PROTECTED]> wrote: > I have a log file that I would like only "trace" messages written to it. > However when I create my properties file such that the logger specifies > the trace level, I also get the debug, info, etc. messages in that log > file. Is there a way to enforce just trace messages? > > > > My properties file looks like: > > > > log4j.category.com.xxx.businesslogic =trace, lcdlog > > > > log4j.appender.lcdlog=org.apache.log4j.FileAppender > > log4j.appender.lcdlog.File=/data/logs/lcd.log > > log4j.appender.lcdlog.layout=org.apache.log4j.PatternLayout > > log4j.appender.lcdlog.layout.ConversionPattern=[%d{MM/dd/yyyy HH:mm:ss}] > %-p - %m%n > > > > And of course I have another appender to handle the other log messages. > > > > Is it possible to set things up in the properties file to only get the > trace messages? > > I'm using log4j 1.2.15 on a linux system. > > > > Thanks, > > Beth > > -- James A. N. Stauffer http://www.geocities.com/stauffer_james/ Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
