Is there something specific to using the TRACE level logging and the filters? What I have now is my lcd.log set to deny ERROR and INFO messages (there are no FATAL or WARN messages logged anywhere) and to accept DEBUG and TRACE messages. I see debug messages in the lcd.log, but no trace messages, even though there are places in the application logging via trace().
For completeness, here is my xml config file: (I have also tried setting the threshold to TRACE in the lcd.log, but that had no effect). 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.LevelMatchFilter"> <param name="LevelToMatch" value="INFO"/> <param name="AcceptOnMatch" value="false" /> </filter> <filter class="org.apache.log4j.varia.LevelMatchFilter"> <param name="LevelToMatch" value="ERROR"/> <param name="AcceptOnMatch" value="false" /> </filter> <filter class="org.apache.log4j.varia.LevelMatchFilter"> <param name="LevelToMatch" value="DEBUG"/> <param name="AcceptOnMatch" value="true" /> </filter> <filter class="org.apache.log4j.varia.LevelMatchFilter"> <param name="LevelToMatch" value="TRACE"/> <param name="AcceptOnMatch" value="true" /> </filter> <filter class="org.apache.log4j.filter.DenyAllFilter"/> </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: Beth Hechanova [mailto:[EMAIL PROTECTED] Sent: Monday, February 04, 2008 11:41 AM To: Log4J Users List Subject: RE: logging only one level of messages I had tried adding a DenyAllFilter at one time and I still didn't get the behavior I was looking for. Just to be sure, I tried again today several scenarios: 1) The original scenario, using LevelRangeFilter for just TRACE messages - no output in lcd.log 2) Same, but add DenyAllFilter as suggested. Again, no output in lcd.log 3) Change to LevelMatchFilter: LevelToMatch = TRACE; AcceptOnMatch = true; with DenyAllFilter. Now I get everything BUT TRACE messages in lcd.log 4) Same as #3, but remove DenyAllFilter. Same result 5) Same as #4: LevelToMatch = TRACE; but change AcceptOnMatch to false. Same result, everything but TRACE in lcd.log 6) Just to be sure there is nothing specifc to TRACE messages, change LevelTomatch = INFO, AcceptOnMatch to true; include DenyAllFilter. Again, I get DEBUG messages into lcd.log (as well as the expected INFO messages), but no TRACE messages. Any other ideas on what I have set up incorrectly? Or does this feature have some problems? Thanks again, Beth -----Original Message----- From: Curt Arnold [mailto:[EMAIL PROTECTED] Sent: Sunday, February 03, 2008 8:57 AM To: Log4J Users List Subject: Re: logging only one level of messages On Feb 2, 2008, at 4:14 PM, Beth Hechanova wrote: > 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 > > You need to throw a DenyAllFilter at the end to reject any logging events that remained neutral. > > ... > > <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> > +<filter class="org.apache.log4j.filter.DenyAllFilter"/> > </appender> > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
