Thanks - looks like I had my mins and maxs mixed up - I thought Fatal was the min and Debug was the max, but now I can see it's the other way around. Your help is appreciated.
Matt -----Original Message----- From: Paul Smith [mailto:[EMAIL PROTECTED] Sent: Sunday, September 07, 2003 4:55 PM To: Log4J Users List Subject: RE: LevelRangeFilter not working Ok, if that is the case, then you definately want a LevelRangeFilter, and you want to set the MinLevel to ERROR, and the MaxLevel to FATAL (or don't have a Max). Here is the source code the relevant method inside LevelRangeFilter, you can see how it works: public int decide(LoggingEvent event) { if(this.levelMin != null) { if (event.getLevel().isGreaterOrEqual(levelMin) == false) { // level of event is less than minimum return Filter.DENY; } } if(this.levelMax != null) { if (event.getLevel().toInt() > levelMax.toInt()) { // level of event is greater than maximum // Alas, there is no Level.isGreater method. and using // a combo of isGreaterOrEqual && !Equal seems worse than // checking the int values of the level objects.. return Filter.DENY; } } if (acceptOnMatch) { // this filter set up to bypass later filters and always return // accept if level in range return Filter.ACCEPT; } else { // event is ok for this filter; allow later filters to have a look.. return Filter.NEUTRAL; } } Hope this helps, Paul On Mon, 2003-09-08 at 08:45, Matt Raible wrote: > Yep - I only want ERROR and FATAL to go to my file appender and all > messages (fatal -> debug) to go to the console. > > -----Original Message----- > From: Paul Smith [mailto:[EMAIL PROTECTED] > Sent: Sunday, September 07, 2003 4:18 PM > To: Log4J Users List > Subject: RE: LevelRangeFilter not working > > > Sorry, I got confused when you said "<=Error" in your original post, > was that a typo, did you mean >=Error? > > Ok, to confirm, you only want ERROR and FATAL to go to your file > appender, and allow all errors to go to the console? > > cheers, > > Paul > > On Mon, 2003-09-08 at 08:12, Matt Raible wrote: > > I believe I have it configured correctly. I want to log messages > > that > > > are FATAL or ERROR - nothing above error. > > > > Matt > > > > -----Original Message----- > > From: Paul Smith [mailto:[EMAIL PROTECTED] > > Sent: Sunday, September 07, 2003 4:05 PM > > To: Log4J Users List > > Subject: Re: LevelRangeFilter not working > > > > > > Hi Matt, > > > > I think you might have 2 filters confused. LevelRangeFilter needs a > > range of Levels to accept/deny. In your case you have said that the > > Maximum is Error, but have no Minimum set and therefore only logs with > > > levels greater than error will get denied. > > > > You are probably wanting the LevelMatchFilter which takes a single > > level to match, and only accepts those, denies all others. > > > > Otherwise you could set the LevelMin of the LevelRangeFilter to > > ERROR > > and that should work too, I think. > > > > cheers, > > > > Paul Smith > > > > On Sat, 2003-09-06 at 07:55, Matt Raible wrote: > > > I two appenders - a console and a file. I want all messages to go > > > to > > > the console and only <= error to go to the file. > > > > > > In my file appender, I have a filter to only get the error > > > messages: > > > > > > <filter class="org.apache.log4j.varia.LevelRangeFilter"> > > > <param name="LevelMax" value="ERROR" /> > > > </filter> > > > > > > Then in <root> I have: > > > > > > <root> > > > <level value="DEBUG"/> > > > <appender-ref ref="CONSOLE"/> > > > <appender-ref ref="FILE"/> > > > </root> > > > > > > From the documentation I've read (i.e. http://tinyurl.com/meef), > > > this > > > *should* work. However, all messages get logged to both the console > > > > appender and the file appender. > > > > > > Help is appreciated. > > > > > > Matt > > > > > > My full log4j.xml file: > > > > > > <?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"> > > > <layout class="org.apache.log4j.PatternLayout"> > > > <param name="ConversionPattern" value="%p - %C{1}.%M(%L) | > > %m%n"/> > > > </layout> > > > </appender> > > > > > > <appender name="ERROR_LOG" > > > class="org.apache.log4j.RollingFileAppender"> > > > <param name="File" > > > value="${catalina.home}[EMAIL PROTECTED]@/error.log"/> > > > <param name="Append" value="false"/> > > > <param name="MaxFileSize" value="333KB"/> > > > <param name="MaxBackupIndex" value="3"/> > > > <layout class="org.apache.log4j.PatternLayout"> > > > <param name="ConversionPattern" value="%d [%t] %-5p %c{2} - > > > %m%n"/> > > > </layout> > > > <filter class="org.apache.log4j.varia.LevelRangeFilter"> > > > <param name="LevelMax" value="ERROR" /> > > > </filter> > > > </appender> > > > > > > <logger name="org.apache"> > > > <level value="WARN"/> > > > <appender-ref ref="CONSOLE"/> > > > </logger> > > > > > > <root> > > > <level value="DEBUG"/> > > > <appender-ref ref="CONSOLE"/> > > > <appender-ref ref="ERROR_LOG"/> > > > </root> > > > > > > </log4j:configuration> > > > > > > > > > > > > ------------------------------------------------------------------ > > > -- > > > - > > > 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] > > > --------------------------------------------------------------------- > 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]