RE: range filter?

2015-08-26 Thread Nicholas Duane
This is my main issue.  If someone, Remko maybe?, has a solution using 
composite and threshold please let me know as so far I have been unable to make 
it work using those.  My next step would be to write my own LevelRangeFilter.
 
Thanks,
Nick
 
 From: nic...@msn.com
 To: log4j-user@logging.apache.org
 Subject: RE: range filter?
 Date: Wed, 26 Aug 2015 10:41:27 -0400
 
 Thanks for clarifying.
 
 My effort to try to get the composite + threshold filter working such that I 
 can filter a single level so far has failed.  Here is my code:
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.Level;
 
 public class HelloWorld
 { 
 static Logger log = LogManager.getLogger(HelloWorld.class.getName());
 
 public static void main(String[] args)
 { 
   System.out.println(Hello, World);
   log.info(hello this is an INFO  message);
   log.warn(hello this is a WARN message);
   log.debug(hello this is a DEBUG message);
   Level level = Level.getLevel(INFOM1);
   if (level == null)
  System.out.println(Didn't find level INFOM1);
   else
 log.log(level, hello this is an INFOM1 message);
   level = Level.getLevel(INFOP1);
   if (level == null)
 System.out.println(Didn't find level INFOP1);
   else
 log.log(level, hello this is an INFOP1 message);
 }
 }
 
 Here is my configuration file:
 
 ?xml version=1.0 encoding=UTF-8?
 Configuration status=trace verbose=true
   CustomLevels
 CustomLevel name=INFOM1 intLevel=399/
 CustomLevel name=INFOP1 intLevel=401/
   /CustomLevels
   Appenders
 File name=info fileName=info.log
   PatternLayout
 Pattern%d %p %c{1.} [%t] %m%n/Pattern
   /PatternLayout
   Filters
 ThresholdFilter level=INFOM1 onMatch=DENY onMismatch=NEUTRAL/
 ThresholdFilter level=INFO onMatch=ACCEPT onMismatch=DENY/
   /Filters
 /File
   /Appenders
   Loggers
 Logger name=HelloWorld level=ALL
   AppenderRef ref=info/
 /Logger
 Root
 /Root
   /Loggers
 /Configuration
 
 NOTE: The custom levels are not being found by the code as I'm seeing my 
 messages to stdout that it couldn't find INFOM1 and INFOP1.
 
 Any suggestion on how to get filtering of a single level working with the 
 composite filter + threshold filter?
 
 Thanks,
 Nick
 
  Subject: Re: range filter?
  From: ralph.go...@dslextreme.com
  Date: Wed, 26 Aug 2015 07:05:35 -0700
  To: log4j-user@logging.apache.org
  
  I apologize, you are correct. The level values do decrease.
  
  Regardless, your point about wanting to filter on essentially a single 
  integer value makes sense.
  
  Ralph
  
   On Aug 26, 2015, at 6:12 AM, Nicholas Duane nic...@msn.com wrote:
   
   Hmmm, I thought for log4j the threshold was less than or equal to the 
   level.  For instance, if the threshold is INFO then INFO and less than, 
   eg more critical like WARN ERROR and FATAL would match.  It's opposite in 
   log4net.  Regardless, this is the issue I wanted to point out.  The 
   stackoverflow article doesn't filter only INFO level, it seems it filters 
   INFO and anything between INFO and WARN but not including WARN.
   
   If I want just a single level then I would like a way to specify that 
   without me having to potentially go back and edit the configuration if 
   someone decides to specify a custom level via configuration or code.  The 
   LevelRangeFilter provides an easy mechanism for me to do this by 
   specifying the same level for min and max.  I guess you're suggesting I 
   could accomplish this via the composite filter and the threshold filter, 
   however, I would have to define a custom level that is one less than or 
   one more than the level I'm looking to capture so that I ensure I'm only 
   getting that one level.  I will try this out, but it would be nice to 
   have something like the LevelRangeFilter.
   
   Thanks,
   Nick
   
   Subject: Re: range filter?
   From: ralph.go...@dslextreme.com
   Date: Tue, 25 Aug 2015 22:08:01 -0700
   To: log4j-user@logging.apache.org
   
   No. If the custom level was 1 greater than INFO, then yes. In that case 
   you would specify your custom level instead of WARN as the level on the 
   first ThresholdFilter.
   
   Ralph
   
   On Aug 25, 2015, at 9:39 PM, Nicholas Duane nic...@msn.com wrote:
   
   What if someone defined a custom level one less than INFO?  Wouldn't 
   that end up in the log also?
   Thanks,Nick
   
    Original message 
   From: Ralph Goers ralph.go...@dslextreme.com
   Date: 08/25/2015  10:28 PM  (GMT-07:00)
   To: Log4J Users List log4j-user@logging.apache.org
   Subject: Re: range filter?
   
   I just did.
   
   Ralph
   
   On Aug 25, 2015, at 9:12 PM, Nicholas Duane nic...@msn.com wrote:
   
   That's exactly the use case I'm looking for.  I'll have to study it 
   some more.  Can you give me an example which filters out everything 
   but INFO

Re: range filter?

2015-08-26 Thread Gary Gregory
On Wed, Aug 26, 2015 at 10:52 AM, Nicholas Duane nic...@msn.com wrote:

 This is my main issue.  If someone, Remko maybe?, has a solution using
 composite and threshold please let me know as so far I have been unable to
 make it work using those.  My next step would be to write my own
 LevelRangeFilter.


I think a LevelRangeFilter is a good idea anyway, so Log4j should provide
one. Writing one is easy, it's docs will take longer to write well.

Gary


 Thanks,
 Nick

  From: nic...@msn.com
  To: log4j-user@logging.apache.org
  Subject: RE: range filter?
  Date: Wed, 26 Aug 2015 10:41:27 -0400
 
  Thanks for clarifying.
 
  My effort to try to get the composite + threshold filter working such
 that I can filter a single level so far has failed.  Here is my code:
 
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
  import org.apache.logging.log4j.Level;
 
  public class HelloWorld
  {
  static Logger log = LogManager.getLogger(HelloWorld.class.getName());
 
  public static void main(String[] args)
  {
System.out.println(Hello, World);
log.info(hello this is an INFO  message);
log.warn(hello this is a WARN message);
log.debug(hello this is a DEBUG message);
Level level = Level.getLevel(INFOM1);
if (level == null)
   System.out.println(Didn't find level INFOM1);
else
  log.log(level, hello this is an INFOM1 message);
level = Level.getLevel(INFOP1);
if (level == null)
  System.out.println(Didn't find level INFOP1);
else
  log.log(level, hello this is an INFOP1 message);
  }
  }
 
  Here is my configuration file:
 
  ?xml version=1.0 encoding=UTF-8?
  Configuration status=trace verbose=true
CustomLevels
  CustomLevel name=INFOM1 intLevel=399/
  CustomLevel name=INFOP1 intLevel=401/
/CustomLevels
Appenders
  File name=info fileName=info.log
PatternLayout
  Pattern%d %p %c{1.} [%t] %m%n/Pattern
/PatternLayout
Filters
  ThresholdFilter level=INFOM1 onMatch=DENY onMismatch=NEUTRAL/
  ThresholdFilter level=INFO onMatch=ACCEPT onMismatch=DENY/
/Filters
  /File
/Appenders
Loggers
  Logger name=HelloWorld level=ALL
AppenderRef ref=info/
  /Logger
  Root
  /Root
/Loggers
  /Configuration
 
  NOTE: The custom levels are not being found by the code as I'm seeing my
 messages to stdout that it couldn't find INFOM1 and INFOP1.
 
  Any suggestion on how to get filtering of a single level working with
 the composite filter + threshold filter?
 
  Thanks,
  Nick
 
   Subject: Re: range filter?
   From: ralph.go...@dslextreme.com
   Date: Wed, 26 Aug 2015 07:05:35 -0700
   To: log4j-user@logging.apache.org
  
   I apologize, you are correct. The level values do decrease.
  
   Regardless, your point about wanting to filter on essentially a single
 integer value makes sense.
  
   Ralph
  
On Aug 26, 2015, at 6:12 AM, Nicholas Duane nic...@msn.com wrote:
   
Hmmm, I thought for log4j the threshold was less than or equal to
 the level.  For instance, if the threshold is INFO then INFO and less than,
 eg more critical like WARN ERROR and FATAL would match.  It's opposite in
 log4net.  Regardless, this is the issue I wanted to point out.  The
 stackoverflow article doesn't filter only INFO level, it seems it filters
 INFO and anything between INFO and WARN but not including WARN.
   
If I want just a single level then I would like a way to specify
 that without me having to potentially go back and edit the configuration if
 someone decides to specify a custom level via configuration or code.  The
 LevelRangeFilter provides an easy mechanism for me to do this by specifying
 the same level for min and max.  I guess you're suggesting I could
 accomplish this via the composite filter and the threshold filter, however,
 I would have to define a custom level that is one less than or one more
 than the level I'm looking to capture so that I ensure I'm only getting
 that one level.  I will try this out, but it would be nice to have
 something like the LevelRangeFilter.
   
Thanks,
Nick
   
Subject: Re: range filter?
From: ralph.go...@dslextreme.com
Date: Tue, 25 Aug 2015 22:08:01 -0700
To: log4j-user@logging.apache.org
   
No. If the custom level was 1 greater than INFO, then yes. In that
 case you would specify your custom level instead of WARN as the level on
 the first ThresholdFilter.
   
Ralph
   
On Aug 25, 2015, at 9:39 PM, Nicholas Duane nic...@msn.com
 wrote:
   
What if someone defined a custom level one less than INFO?
 Wouldn't that end up in the log also?
Thanks,Nick
   
 Original message 
From: Ralph Goers ralph.go...@dslextreme.com
Date: 08/25/2015  10:28 PM  (GMT-07:00)
To: Log4J Users List log4j-user@logging.apache.org
Subject: Re: range filter?
   
I just

RE: range filter?

2015-08-26 Thread Nicholas Duane
Thanks for clarifying.

My effort to try to get the composite + threshold filter working such that I 
can filter a single level so far has failed.  Here is my code:

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Level;

public class HelloWorld
{ 
static Logger log = LogManager.getLogger(HelloWorld.class.getName());

public static void main(String[] args)
{ 
  System.out.println(Hello, World);
  log.info(hello this is an INFO  message);
  log.warn(hello this is a WARN message);
  log.debug(hello this is a DEBUG message);
  Level level = Level.getLevel(INFOM1);
  if (level == null)
 System.out.println(Didn't find level INFOM1);
  else
log.log(level, hello this is an INFOM1 message);
  level = Level.getLevel(INFOP1);
  if (level == null)
System.out.println(Didn't find level INFOP1);
  else
log.log(level, hello this is an INFOP1 message);
}
}

Here is my configuration file:

?xml version=1.0 encoding=UTF-8?
Configuration status=trace verbose=true
  CustomLevels
CustomLevel name=INFOM1 intLevel=399/
CustomLevel name=INFOP1 intLevel=401/
  /CustomLevels
  Appenders
File name=info fileName=info.log
  PatternLayout
Pattern%d %p %c{1.} [%t] %m%n/Pattern
  /PatternLayout
  Filters
ThresholdFilter level=INFOM1 onMatch=DENY onMismatch=NEUTRAL/
ThresholdFilter level=INFO onMatch=ACCEPT onMismatch=DENY/
  /Filters
/File
  /Appenders
  Loggers
Logger name=HelloWorld level=ALL
  AppenderRef ref=info/
/Logger
Root
/Root
  /Loggers
/Configuration

NOTE: The custom levels are not being found by the code as I'm seeing my 
messages to stdout that it couldn't find INFOM1 and INFOP1.

Any suggestion on how to get filtering of a single level working with the 
composite filter + threshold filter?

Thanks,
Nick

 Subject: Re: range filter?
 From: ralph.go...@dslextreme.com
 Date: Wed, 26 Aug 2015 07:05:35 -0700
 To: log4j-user@logging.apache.org
 
 I apologize, you are correct. The level values do decrease.
 
 Regardless, your point about wanting to filter on essentially a single 
 integer value makes sense.
 
 Ralph
 
  On Aug 26, 2015, at 6:12 AM, Nicholas Duane nic...@msn.com wrote:
  
  Hmmm, I thought for log4j the threshold was less than or equal to the 
  level.  For instance, if the threshold is INFO then INFO and less than, eg 
  more critical like WARN ERROR and FATAL would match.  It's opposite in 
  log4net.  Regardless, this is the issue I wanted to point out.  The 
  stackoverflow article doesn't filter only INFO level, it seems it filters 
  INFO and anything between INFO and WARN but not including WARN.
  
  If I want just a single level then I would like a way to specify that 
  without me having to potentially go back and edit the configuration if 
  someone decides to specify a custom level via configuration or code.  The 
  LevelRangeFilter provides an easy mechanism for me to do this by specifying 
  the same level for min and max.  I guess you're suggesting I could 
  accomplish this via the composite filter and the threshold filter, however, 
  I would have to define a custom level that is one less than or one more 
  than the level I'm looking to capture so that I ensure I'm only getting 
  that one level.  I will try this out, but it would be nice to have 
  something like the LevelRangeFilter.
  
  Thanks,
  Nick
  
  Subject: Re: range filter?
  From: ralph.go...@dslextreme.com
  Date: Tue, 25 Aug 2015 22:08:01 -0700
  To: log4j-user@logging.apache.org
  
  No. If the custom level was 1 greater than INFO, then yes. In that case 
  you would specify your custom level instead of WARN as the level on the 
  first ThresholdFilter.
  
  Ralph
  
  On Aug 25, 2015, at 9:39 PM, Nicholas Duane nic...@msn.com wrote:
  
  What if someone defined a custom level one less than INFO?  Wouldn't that 
  end up in the log also?
  Thanks,Nick
  
   Original message 
  From: Ralph Goers ralph.go...@dslextreme.com
  Date: 08/25/2015  10:28 PM  (GMT-07:00)
  To: Log4J Users List log4j-user@logging.apache.org
  Subject: Re: range filter?
  
  I just did.
  
  Ralph
  
  On Aug 25, 2015, at 9:12 PM, Nicholas Duane nic...@msn.com wrote:
  
  That's exactly the use case I'm looking for.  I'll have to study it some 
  more.  Can you give me an example which filters out everything but INFO?
  Thanks,Nick
  
   Original message 
  From: Remko Popma remko.po...@gmail.com
  Date: 08/25/2015  9:06 PM  (GMT-07:00)
  To: Log4J Users List log4j-user@logging.apache.org
  Subject: Re: range filter?
  
  
  The StackOverflow link was an answer to the question how to send _only_ 
  INFO level events to an appender.
  
  
  
  I thought it would illustrate how filters combinations could be used to 
  achieve the original request: I might want all DEBUG, TRACE and VERBOSE 
  events going to one

RE: range filter?

2015-08-26 Thread Nicholas Duane
Hmmm, I thought for log4j the threshold was less than or equal to the level.  
For instance, if the threshold is INFO then INFO and less than, eg more 
critical like WARN ERROR and FATAL would match.  It's opposite in log4net.  
Regardless, this is the issue I wanted to point out.  The stackoverflow article 
doesn't filter only INFO level, it seems it filters INFO and anything between 
INFO and WARN but not including WARN.
 
If I want just a single level then I would like a way to specify that without 
me having to potentially go back and edit the configuration if someone decides 
to specify a custom level via configuration or code.  The LevelRangeFilter 
provides an easy mechanism for me to do this by specifying the same level for 
min and max.  I guess you're suggesting I could accomplish this via the 
composite filter and the threshold filter, however, I would have to define a 
custom level that is one less than or one more than the level I'm looking to 
capture so that I ensure I'm only getting that one level.  I will try this out, 
but it would be nice to have something like the LevelRangeFilter.
 
Thanks,
Nick
 
 Subject: Re: range filter?
 From: ralph.go...@dslextreme.com
 Date: Tue, 25 Aug 2015 22:08:01 -0700
 To: log4j-user@logging.apache.org
 
 No. If the custom level was 1 greater than INFO, then yes. In that case you 
 would specify your custom level instead of WARN as the level on the first 
 ThresholdFilter.
 
 Ralph
 
  On Aug 25, 2015, at 9:39 PM, Nicholas Duane nic...@msn.com wrote:
  
  What if someone defined a custom level one less than INFO?  Wouldn't that 
  end up in the log also?
  Thanks,Nick
  
   Original message 
  From: Ralph Goers ralph.go...@dslextreme.com
  Date: 08/25/2015  10:28 PM  (GMT-07:00)
  To: Log4J Users List log4j-user@logging.apache.org
  Subject: Re: range filter?
  
  I just did.
  
  Ralph
  
  On Aug 25, 2015, at 9:12 PM, Nicholas Duane nic...@msn.com wrote:
  
  That's exactly the use case I'm looking for.  I'll have to study it some 
  more.  Can you give me an example which filters out everything but INFO?
  Thanks,Nick
  
   Original message 
  From: Remko Popma remko.po...@gmail.com
  Date: 08/25/2015  9:06 PM  (GMT-07:00)
  To: Log4J Users List log4j-user@logging.apache.org
  Subject: Re: range filter?
  
  
  The StackOverflow link was an answer to the question how to send _only_ 
  INFO level events to an appender.
  
  
  
  I thought it would illustrate how filters combinations could be used to 
  achieve the original request: I might want all DEBUG, TRACE and VERBOSE 
  events going to one appender.  All INFO, ERROR and WARN events going to 
  another appender. All BUSINESS events (my custom) level, going to yet 
  another appender.
  
  
  
  Seemed to me to be a similar use case to the SO question.
  
  
  
  Sent from my iPhone
  
  
  
  On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:
  
  
  
  I am not sure why Remko advised you to do it this way.  The first filter 
  will deny Warn, error and fatal making the next two filters redundant. 
  The third filter will accept events at level info and deny trace and 
  debug.  So the end result is the only events that will get logged will be 
  those at INFO level.
  
  
  
  The composite filter really just wraps other filters and returns whatever 
  result they generate. For example, if the first filter returns accept or 
  deny then that value will be returned as the result without consulting 
  any other filters. If the result is neutral then the second filter will 
  be used to see if the event passes that.
  
  
  
  Ralph
  
  
  
  
  
  On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
  
  
  
  Maybe.  However, I'm having a hard time following what the configuration 
  is saying and thus have no idea what I would need to put in the 
  configuration.  Here is a snippet from that post:
  
  
  
   !-- Now deny warn, error and fatal messages --
  
  
  
  ThresholdFilter level=warn  onMatch=DENY   
  onMismatch=NEUTRAL/
  
  
  
   ThresholdFilter level=error onMatch=DENY   
  onMismatch=NEUTRAL/
  
   ThresholdFilter level=fatal onMatch=DENY   
  onMismatch=NEUTRAL/
  
  
  
!-- This filter accepts info, warn, error, fatal and denies 
  debug/trace --
  
  
  
ThresholdFilter level=info  onMatch=ACCEPT 
  onMismatch=DENY/
  
  
  
  
  
  The top three seem as if they would deny warn, error and fatal, yet the 
  third says it accepts info, warn, error and fatal.  And while I 
  understand those in isolation, I think, I have no idea how the filters 
  composite would handle this.  Why are the first three needed?  How does 
  the CompositeFilter work?  Does it try to match on each filter in the 
  list of stop as soon as it gets a DENY?
  
  
  
  What if I wanted to setup a filter which just accepted WARN?  And on top 
  of that ensure that if anyone

Re: range filter?

2015-08-26 Thread Ralph Goers
I apologize, you are correct. The level values do decrease.

Regardless, your point about wanting to filter on essentially a single integer 
value makes sense.

Ralph

 On Aug 26, 2015, at 6:12 AM, Nicholas Duane nic...@msn.com wrote:
 
 Hmmm, I thought for log4j the threshold was less than or equal to the level.  
 For instance, if the threshold is INFO then INFO and less than, eg more 
 critical like WARN ERROR and FATAL would match.  It's opposite in log4net.  
 Regardless, this is the issue I wanted to point out.  The stackoverflow 
 article doesn't filter only INFO level, it seems it filters INFO and anything 
 between INFO and WARN but not including WARN.
 
 If I want just a single level then I would like a way to specify that without 
 me having to potentially go back and edit the configuration if someone 
 decides to specify a custom level via configuration or code.  The 
 LevelRangeFilter provides an easy mechanism for me to do this by specifying 
 the same level for min and max.  I guess you're suggesting I could accomplish 
 this via the composite filter and the threshold filter, however, I would have 
 to define a custom level that is one less than or one more than the level I'm 
 looking to capture so that I ensure I'm only getting that one level.  I will 
 try this out, but it would be nice to have something like the 
 LevelRangeFilter.
 
 Thanks,
 Nick
 
 Subject: Re: range filter?
 From: ralph.go...@dslextreme.com
 Date: Tue, 25 Aug 2015 22:08:01 -0700
 To: log4j-user@logging.apache.org
 
 No. If the custom level was 1 greater than INFO, then yes. In that case you 
 would specify your custom level instead of WARN as the level on the first 
 ThresholdFilter.
 
 Ralph
 
 On Aug 25, 2015, at 9:39 PM, Nicholas Duane nic...@msn.com wrote:
 
 What if someone defined a custom level one less than INFO?  Wouldn't that 
 end up in the log also?
 Thanks,Nick
 
  Original message 
 From: Ralph Goers ralph.go...@dslextreme.com
 Date: 08/25/2015  10:28 PM  (GMT-07:00)
 To: Log4J Users List log4j-user@logging.apache.org
 Subject: Re: range filter?
 
 I just did.
 
 Ralph
 
 On Aug 25, 2015, at 9:12 PM, Nicholas Duane nic...@msn.com wrote:
 
 That's exactly the use case I'm looking for.  I'll have to study it some 
 more.  Can you give me an example which filters out everything but INFO?
 Thanks,Nick
 
  Original message 
 From: Remko Popma remko.po...@gmail.com
 Date: 08/25/2015  9:06 PM  (GMT-07:00)
 To: Log4J Users List log4j-user@logging.apache.org
 Subject: Re: range filter?
 
 
 The StackOverflow link was an answer to the question how to send _only_ 
 INFO level events to an appender.
 
 
 
 I thought it would illustrate how filters combinations could be used to 
 achieve the original request: I might want all DEBUG, TRACE and VERBOSE 
 events going to one appender.  All INFO, ERROR and WARN events going to 
 another appender. All BUSINESS events (my custom) level, going to yet 
 another appender.
 
 
 
 Seemed to me to be a similar use case to the SO question.
 
 
 
 Sent from my iPhone
 
 
 
 On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:
 
 
 
 I am not sure why Remko advised you to do it this way.  The first filter 
 will deny Warn, error and fatal making the next two filters redundant. 
 The third filter will accept events at level info and deny trace and 
 debug.  So the end result is the only events that will get logged will be 
 those at INFO level.
 
 
 
 The composite filter really just wraps other filters and returns whatever 
 result they generate. For example, if the first filter returns accept or 
 deny then that value will be returned as the result without consulting 
 any other filters. If the result is neutral then the second filter will 
 be used to see if the event passes that.
 
 
 
 Ralph
 
 
 
 
 
 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 
 
 Maybe.  However, I'm having a hard time following what the configuration 
 is saying and thus have no idea what I would need to put in the 
 configuration.  Here is a snippet from that post:
 
 
 
 !-- Now deny warn, error and fatal messages --
 
 
 
ThresholdFilter level=warn  onMatch=DENY   
 onMismatch=NEUTRAL/
 
 
 
 ThresholdFilter level=error onMatch=DENY   
 onMismatch=NEUTRAL/
 
 ThresholdFilter level=fatal onMatch=DENY   
 onMismatch=NEUTRAL/
 
 
 
  !-- This filter accepts info, warn, error, fatal and denies 
 debug/trace --
 
 
 
  ThresholdFilter level=info  onMatch=ACCEPT 
 onMismatch=DENY/
 
 
 
 
 
 The top three seem as if they would deny warn, error and fatal, yet the 
 third says it accepts info, warn, error and fatal.  And while I 
 understand those in isolation, I think, I have no idea how the filters 
 composite would handle this.  Why are the first three needed?  How does 
 the CompositeFilter work?  Does it try to match on each filter in the 
 list of stop as soon as it gets

Re: range filter?

2015-08-25 Thread Ralph Goers
I am not sure why Remko advised you to do it this way.  The first filter will 
deny Warn, error and fatal making the next two filters redundant. The third 
filter will accept events at level info and deny trace and debug.  So the end 
result is the only events that will get logged will be those at INFO level.

The composite filter really just wraps other filters and returns whatever 
result they generate. For example, if the first filter returns accept or deny 
then that value will be returned as the result without consulting any other 
filters. If the result is neutral then the second filter will be used to see if 
the event passes that.

Ralph


 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 Maybe.  However, I'm having a hard time following what the configuration is 
 saying and thus have no idea what I would need to put in the configuration.  
 Here is a snippet from that post:
 
   !-- Now deny warn, error and fatal messages --
 
  ThresholdFilter level=warn  onMatch=DENY   
 onMismatch=NEUTRAL/
 
   ThresholdFilter level=error onMatch=DENY   
 onMismatch=NEUTRAL/
   ThresholdFilter level=fatal onMatch=DENY   
 onMismatch=NEUTRAL/
 
!-- This filter accepts info, warn, error, fatal and denies 
 debug/trace --
 
ThresholdFilter level=info  onMatch=ACCEPT onMismatch=DENY/
 
 
 The top three seem as if they would deny warn, error and fatal, yet the third 
 says it accepts info, warn, error and fatal.  And while I understand those in 
 isolation, I think, I have no idea how the filters composite would handle 
 this.  Why are the first three needed?  How does the CompositeFilter work?  
 Does it try to match on each filter in the list of stop as soon as it gets a 
 DENY?
 
 What if I wanted to setup a filter which just accepted WARN?  And on top of 
 that ensure that if anyone defined any custom levels which are maybe just 1 
 away from WARN in either direction that those don't make it in the appender.  
 How would you do that?
 
 How I did this with the log4net LevelRangeFilter was to set the levelMin and 
 levelMax to the same value.
 
 Thanks,
 Nick
 
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 To: log4j-user@logging.apache.org
 
 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I 
 would edit my answer (which I did).  
 
 So the answer works and seems to apply to your use case, no? The question is 
 if it also works with custom levels. 
 
 Sent from my iPhone
 
 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do something 
 similar to me.  I see the last comment on that is that it doesn't work.
 
 There is another post afterwards which uses the ThresholdFilter.  However 
 the ThresholdFilter won't work as that allows, or denys, all levels greater 
 than or equal to or less than or equal to the level.  I need to filter a 
 specific range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
 I've tried a couple different combinations and so far no luck.  Here's
 the current configuration I tested with which doesn't work:
 
 File ...
 PatternLayout
 ...
  /PatternLayout
  Filters
 ThresholdFilter level=INFO onMatch=DENY/
 ThresholdFilter level=DEBUG onMatch=ACCEPT/
  /Filters
 /File
 
 The
 use case for why I want such a filter is to forward a range of events
 to an appender.  The threshold filter won't work because it will send
 all events matching a certain level and lower to the appender.  For
 instance, I might want all DEBUG, TRACE and VERBOSE events going to one
 appender.  All INFO, ERROR and WARN events going to another appender.
 All BUSINESS events (my custom) level, going to yet another appender.
 
 Thanks,
 Nick
 
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 When you get it working, it sounds like it would make a nice addition to
 the FAQ with a description of your use case.
 
 Gary
 
 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
 
 wrote:
 
 I believe two threshold filters inside a composite filter should should
 work provided you have the onMatch and onMismatch set appropriately.
 
 Ralph
 
 
 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
 
 I'm looking for a range filter in log4j2.  I see there is on in
 log4net
 and it appears there was one written by someone

Re: range filter?

2015-08-25 Thread Remko Popma
I see. I didn't know you could nest filters inside an AppenderRef. Nice!

Sent from my iPhone

 On 2015/08/26, at 12:21, Ralph Goers ralph.go...@dslextreme.com wrote:
 
 If you only want info events then you should do
 
 Filters
  ThresholdFilter level=“warn” onMatch=“DENY” onMisMatch=“NEUTRAL”/
  ThresholdFilter level=“info” onMatch=“ACCEPT” onMisMatch=“DENY”/
 /Filters
 
 If you want to illustrate the other use case you would need a configuration 
 like
 
 root level=“ALL”
  appenderRef ref=“appender1”
  ThresholdFilter level=“INFO” onMatch=“DENY” onMisMatch=“ACCEPT”/
  /appenderRef
  appenderRef ref=“appender2”
Filters
  ThresholdFilter level=“FATAL” onMatch=“DENY” onMisMatch=“NEUTRAL”/
  ThresholdFilter level=“INFO” onMatch=“ACCEPT” onMisMatch=“DENY”/
/Filters
  /appenderRef
 /root
 
 On Aug 25, 2015, at 8:06 PM, Remko Popma remko.po...@gmail.com wrote:
 
 The StackOverflow link was an answer to the question how to send _only_ 
 INFO level events to an appender. 
 
 I thought it would illustrate how filters combinations could be used to 
 achieve the original request: I might want all DEBUG, TRACE and VERBOSE 
 events going to one appender.  All INFO, ERROR and WARN events going to 
 another appender. All BUSINESS events (my custom) level, going to yet 
 another appender.
 
 Seemed to me to be a similar use case to the SO question.
 
 Sent from my iPhone
 
 On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:
 
 I am not sure why Remko advised you to do it this way.  The first filter 
 will deny Warn, error and fatal making the next two filters redundant. The 
 third filter will accept events at level info and deny trace and debug.  So 
 the end result is the only events that will get logged will be those at 
 INFO level.
 
 The composite filter really just wraps other filters and returns whatever 
 result they generate. For example, if the first filter returns accept or 
 deny then that value will be returned as the result without consulting any 
 other filters. If the result is neutral then the second filter will be used 
 to see if the event passes that.
 
 Ralph
 
 
 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 Maybe.  However, I'm having a hard time following what the configuration 
 is saying and thus have no idea what I would need to put in the 
 configuration.  Here is a snippet from that post:
 
!-- Now deny warn, error and fatal messages --
 
   ThresholdFilter level=warn  onMatch=DENY   
 onMismatch=NEUTRAL/
 
ThresholdFilter level=error onMatch=DENY   
 onMismatch=NEUTRAL/
ThresholdFilter level=fatal onMatch=DENY   
 onMismatch=NEUTRAL/
 
 !-- This filter accepts info, warn, error, fatal and denies 
 debug/trace --
 
 ThresholdFilter level=info  onMatch=ACCEPT onMismatch=DENY/
 
 
 The top three seem as if they would deny warn, error and fatal, yet the 
 third says it accepts info, warn, error and fatal.  And while I understand 
 those in isolation, I think, I have no idea how the filters composite 
 would handle this.  Why are the first three needed?  How does the 
 CompositeFilter work?  Does it try to match on each filter in the list of 
 stop as soon as it gets a DENY?
 
 What if I wanted to setup a filter which just accepted WARN?  And on top 
 of that ensure that if anyone defined any custom levels which are maybe 
 just 1 away from WARN in either direction that those don't make it in the 
 appender.  How would you do that?
 
 How I did this with the log4net LevelRangeFilter was to set the levelMin 
 and levelMax to the same value.
 
 Thanks,
 Nick
 
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 To: log4j-user@logging.apache.org
 
 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I 
 would edit my answer (which I did).  
 
 So the answer works and seems to apply to your use case, no? The question 
 is if it also works with custom levels. 
 
 Sent from my iPhone
 
 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do 
 something similar to me.  I see the last comment on that is that it 
 doesn't work.
 
 There is another post afterwards which uses the ThresholdFilter.  
 However the ThresholdFilter won't work as that allows, or denys, all 
 levels greater than or equal to or less than or equal to the level.  I 
 need to filter a specific range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic

Re: range filter?

2015-08-25 Thread Gary Gregory
I've got to say that I use MarkerFilters all the time, but I still need to
refresh my brain when I've not used them in a while.

If providing a LevelRangeFilter would be less confusing, then perhaps we
should write one.

Gary

On Tue, Aug 25, 2015 at 7:09 PM, Nicholas Duane nic...@msn.com wrote:

 Maybe.  However, I'm having a hard time following what the configuration
 is saying and thus have no idea what I would need to put in the
 configuration.  Here is a snippet from that post:

!-- Now deny warn, error and fatal messages --

   ThresholdFilter level=warn  onMatch=DENY
  onMismatch=NEUTRAL/

ThresholdFilter level=error onMatch=DENY
  onMismatch=NEUTRAL/
ThresholdFilter level=fatal onMatch=DENY
  onMismatch=NEUTRAL/

 !-- This filter accepts info, warn, error, fatal and denies
 debug/trace --

 ThresholdFilter level=info  onMatch=ACCEPT
 onMismatch=DENY/


 The top three seem as if they would deny warn, error and fatal, yet the
 third says it accepts info, warn, error and fatal.  And while I understand
 those in isolation, I think, I have no idea how the filters composite
 would handle this.  Why are the first three needed?  How does the
 CompositeFilter work?  Does it try to match on each filter in the list of
 stop as soon as it gets a DENY?

 What if I wanted to setup a filter which just accepted WARN?  And on top
 of that ensure that if anyone defined any custom levels which are maybe
 just 1 away from WARN in either direction that those don't make it in the
 appender.  How would you do that?

 How I did this with the log4net LevelRangeFilter was to set the levelMin
 and levelMax to the same value.

 Thanks,
 Nick

  Subject: Re: range filter?
  From: remko.po...@gmail.com
  Date: Wed, 26 Aug 2015 09:12:29 +0900
  To: log4j-user@logging.apache.org
 
  You misread the comment. The commentor basically told me the answer
 works with a minor change, and that he would mark the question as done if
 I would edit my answer (which I did).
 
  So the answer works and seems to apply to your use case, no? The
 question is if it also works with custom levels.
 
  Sent from my iPhone
 
   On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
  
   Thanks.  I checked out the link.  It seems they were trying to do
 something similar to me.  I see the last comment on that is that it doesn't
 work.
  
   There is another post afterwards which uses the ThresholdFilter.
 However the ThresholdFilter won't work as that allows, or denys, all levels
 greater than or equal to or less than or equal to the level.  I need to
 filter a specific range of levels.
  
   Thanks,
   Nick
  
   Date: Wed, 26 Aug 2015 08:27:04 +0900
   Subject: Re: range filter?
   From: remko.po...@gmail.com
   To: log4j-user@logging.apache.org
  
   Can you try something similar to this
  
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
   and see if that works with custom levels as well?
  
   On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com
 wrote:
  
   I've tried a couple different combinations and so far no luck.
 Here's
   the current configuration I tested with which doesn't work:
  
   File ...
PatternLayout
...
 /PatternLayout
 Filters
ThresholdFilter level=INFO onMatch=DENY/
ThresholdFilter level=DEBUG onMatch=ACCEPT/
 /Filters
   /File
  
   The
   use case for why I want such a filter is to forward a range of events
   to an appender.  The threshold filter won't work because it will send
   all events matching a certain level and lower to the appender.  For
   instance, I might want all DEBUG, TRACE and VERBOSE events going to
 one
   appender.  All INFO, ERROR and WARN events going to another appender.
   All BUSINESS events (my custom) level, going to yet another appender.
  
   Thanks,
   Nick
  
   Date: Tue, 25 Aug 2015 13:17:44 -0700
   Subject: Re: range filter?
   From: garydgreg...@gmail.com
   To: log4j-user@logging.apache.org
  
   When you get it working, it sounds like it would make a nice
 addition to
   the FAQ with a description of your use case.
  
   Gary
  
   On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers 
 ralph.go...@dslextreme.com
  
   wrote:
  
   I believe two threshold filters inside a composite filter should
 should
   work provided you have the onMatch and onMismatch set
 appropriately.
  
   Ralph
  
  
   On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com
 wrote:
  
   I'm looking for a range filter in log4j2.  I see there is on in
   log4net
   and it appears there was one written by someone for log4j 1.  Just
   wondering if there is something 'out of the box' in log4j2 that
 will
   accomplish the same?  I was wondering whether this could be
   accomplished
   with the CompositeFilter with two ThresholdFilter?
  
   Thanks,
   Nick

Re: range filter?

2015-08-25 Thread Ralph Goers
I just did.

Ralph

 On Aug 25, 2015, at 9:12 PM, Nicholas Duane nic...@msn.com wrote:
 
 That's exactly the use case I'm looking for.  I'll have to study it some 
 more.  Can you give me an example which filters out everything but INFO?
 Thanks,Nick
 
  Original message 
 From: Remko Popma remko.po...@gmail.com 
 Date: 08/25/2015  9:06 PM  (GMT-07:00) 
 To: Log4J Users List log4j-user@logging.apache.org 
 Subject: Re: range filter? 
 
 
 The StackOverflow link was an answer to the question how to send _only_ INFO 
 level events to an appender. 
 
 
 
 I thought it would illustrate how filters combinations could be used to 
 achieve the original request: I might want all DEBUG, TRACE and VERBOSE 
 events going to one appender.  All INFO, ERROR and WARN events going to 
 another appender. All BUSINESS events (my custom) level, going to yet another 
 appender.
 
 
 
 Seemed to me to be a similar use case to the SO question.
 
 
 
 Sent from my iPhone
 
 
 
 On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:
 
 
 
 I am not sure why Remko advised you to do it this way.  The first filter 
 will deny Warn, error and fatal making the next two filters redundant. The 
 third filter will accept events at level info and deny trace and debug.  So 
 the end result is the only events that will get logged will be those at INFO 
 level.
 
 
 
 The composite filter really just wraps other filters and returns whatever 
 result they generate. For example, if the first filter returns accept or 
 deny then that value will be returned as the result without consulting any 
 other filters. If the result is neutral then the second filter will be used 
 to see if the event passes that.
 
 
 
 Ralph
 
 
 
 
 
 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 
 
 Maybe.  However, I'm having a hard time following what the configuration is 
 saying and thus have no idea what I would need to put in the configuration. 
  Here is a snippet from that post:
 
 
 
   !-- Now deny warn, error and fatal messages --
 
 
 
  ThresholdFilter level=warn  onMatch=DENY   
 onMismatch=NEUTRAL/
 
 
 
   ThresholdFilter level=error onMatch=DENY   
 onMismatch=NEUTRAL/
 
   ThresholdFilter level=fatal onMatch=DENY   
 onMismatch=NEUTRAL/
 
 
 
!-- This filter accepts info, warn, error, fatal and denies 
 debug/trace --
 
 
 
ThresholdFilter level=info  onMatch=ACCEPT 
 onMismatch=DENY/
 
 
 
 
 
 The top three seem as if they would deny warn, error and fatal, yet the 
 third says it accepts info, warn, error and fatal.  And while I understand 
 those in isolation, I think, I have no idea how the filters composite 
 would handle this.  Why are the first three needed?  How does the 
 CompositeFilter work?  Does it try to match on each filter in the list of 
 stop as soon as it gets a DENY?
 
 
 
 What if I wanted to setup a filter which just accepted WARN?  And on top of 
 that ensure that if anyone defined any custom levels which are maybe just 1 
 away from WARN in either direction that those don't make it in the 
 appender.  How would you do that?
 
 
 
 How I did this with the log4net LevelRangeFilter was to set the levelMin 
 and levelMax to the same value.
 
 
 
 Thanks,
 
 Nick
 
 
 
 Subject: Re: range filter?
 
 From: remko.po...@gmail.com
 
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 
 To: log4j-user@logging.apache.org
 
 
 
 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I 
 would edit my answer (which I did).  
 
 
 
 So the answer works and seems to apply to your use case, no? The question 
 is if it also works with custom levels. 
 
 
 
 Sent from my iPhone
 
 
 
 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 
 
 Thanks.  I checked out the link.  It seems they were trying to do 
 something similar to me.  I see the last comment on that is that it 
 doesn't work.
 
 
 
 There is another post afterwards which uses the ThresholdFilter.  However 
 the ThresholdFilter won't work as that allows, or denys, all levels 
 greater than or equal to or less than or equal to the level.  I need to 
 filter a specific range of levels.
 
 
 
 Thanks,
 
 Nick
 
 
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 
 Subject: Re: range filter?
 
 From: remko.po...@gmail.com
 
 To: log4j-user@logging.apache.org
 
 
 
 Can you try something similar to this
 
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 
 and see if that works with custom levels as well?
 
 
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
 
 
 I've tried a couple different combinations and so far no luck.  Here's
 
 the current configuration I tested with which doesn't work:
 
 
 
 File ...
 
 PatternLayout
 
 ...
 
 /PatternLayout
 
 Filters
 
 ThresholdFilter level=INFO onMatch

RE: range filter?

2015-08-25 Thread Nicholas Duane
That's exactly the use case I'm looking for.  I'll have to study it some more.  
Can you give me an example which filters out everything but INFO?
Thanks,Nick

 Original message 
From: Remko Popma remko.po...@gmail.com 
Date: 08/25/2015  9:06 PM  (GMT-07:00) 
To: Log4J Users List log4j-user@logging.apache.org 
Subject: Re: range filter? 


The StackOverflow link was an answer to the question how to send _only_ INFO 
level events to an appender. 



I thought it would illustrate how filters combinations could be used to achieve 
the original request: I might want all DEBUG, TRACE and VERBOSE events going 
to one appender.  All INFO, ERROR and WARN events going to another appender. 
All BUSINESS events (my custom) level, going to yet another appender.



Seemed to me to be a similar use case to the SO question.



Sent from my iPhone



 On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:

 

 I am not sure why Remko advised you to do it this way.  The first filter will 
 deny Warn, error and fatal making the next two filters redundant. The third 
 filter will accept events at level info and deny trace and debug.  So the end 
 result is the only events that will get logged will be those at INFO level.

 

 The composite filter really just wraps other filters and returns whatever 
 result they generate. For example, if the first filter returns accept or deny 
 then that value will be returned as the result without consulting any other 
 filters. If the result is neutral then the second filter will be used to see 
 if the event passes that.

 

 Ralph

 

 

 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:

 

 Maybe.  However, I'm having a hard time following what the configuration is 
 saying and thus have no idea what I would need to put in the configuration.  
 Here is a snippet from that post:

 

  !-- Now deny warn, error and fatal messages --

 

 ThresholdFilter level=warn  onMatch=DENY   
onMismatch=NEUTRAL/

 

  ThresholdFilter level=error onMatch=DENY   
onMismatch=NEUTRAL/

  ThresholdFilter level=fatal onMatch=DENY   
onMismatch=NEUTRAL/

 

   !-- This filter accepts info, warn, error, fatal and denies 
debug/trace --

 

   ThresholdFilter level=info  onMatch=ACCEPT onMismatch=DENY/

 

 

 The top three seem as if they would deny warn, error and fatal, yet the 
 third says it accepts info, warn, error and fatal.  And while I understand 
 those in isolation, I think, I have no idea how the filters composite 
 would handle this.  Why are the first three needed?  How does the 
 CompositeFilter work?  Does it try to match on each filter in the list of 
 stop as soon as it gets a DENY?

 

 What if I wanted to setup a filter which just accepted WARN?  And on top of 
 that ensure that if anyone defined any custom levels which are maybe just 1 
 away from WARN in either direction that those don't make it in the appender. 
  How would you do that?

 

 How I did this with the log4net LevelRangeFilter was to set the levelMin and 
 levelMax to the same value.

 

 Thanks,

 Nick

 

 Subject: Re: range filter?

 From: remko.po...@gmail.com

 Date: Wed, 26 Aug 2015 09:12:29 +0900

 To: log4j-user@logging.apache.org

 

 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I 
 would edit my answer (which I did).  

 

 So the answer works and seems to apply to your use case, no? The question 
 is if it also works with custom levels. 

 

 Sent from my iPhone

 

 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:

 

 Thanks.  I checked out the link.  It seems they were trying to do 
 something similar to me.  I see the last comment on that is that it 
 doesn't work.

 

 There is another post afterwards which uses the ThresholdFilter.  However 
 the ThresholdFilter won't work as that allows, or denys, all levels 
 greater than or equal to or less than or equal to the level.  I need to 
 filter a specific range of levels.

 

 Thanks,

 Nick

 

 Date: Wed, 26 Aug 2015 08:27:04 +0900

 Subject: Re: range filter?

 From: remko.po...@gmail.com

 To: log4j-user@logging.apache.org

 

 Can you try something similar to this

 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002

 and see if that works with custom levels as well?

 

 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:

 

 I've tried a couple different combinations and so far no luck.  Here's

 the current configuration I tested with which doesn't work:

 

 File ...

 PatternLayout

    ...

 /PatternLayout

 Filters

    ThresholdFilter level=INFO onMatch=DENY/

    ThresholdFilter level=DEBUG onMatch=ACCEPT/

 /Filters

 /File

 

 The

 use case for why I want such a filter is to forward a range of events

 to an appender.  The threshold filter won't work

Re: range filter?

2015-08-25 Thread Ralph Goers
If you only want info events then you should do

Filters
  ThresholdFilter level=“warn” onMatch=“DENY” onMisMatch=“NEUTRAL”/
  ThresholdFilter level=“info” onMatch=“ACCEPT” onMisMatch=“DENY”/
/Filters

If you want to illustrate the other use case you would need a configuration like

root level=“ALL”
  appenderRef ref=“appender1”
  ThresholdFilter level=“INFO” onMatch=“DENY” onMisMatch=“ACCEPT”/
  /appenderRef
  appenderRef ref=“appender2”
Filters
  ThresholdFilter level=“FATAL” onMatch=“DENY” onMisMatch=“NEUTRAL”/
  ThresholdFilter level=“INFO” onMatch=“ACCEPT” onMisMatch=“DENY”/
/Filters
  /appenderRef
/root

 On Aug 25, 2015, at 8:06 PM, Remko Popma remko.po...@gmail.com wrote:
 
 The StackOverflow link was an answer to the question how to send _only_ INFO 
 level events to an appender. 
 
 I thought it would illustrate how filters combinations could be used to 
 achieve the original request: I might want all DEBUG, TRACE and VERBOSE 
 events going to one appender.  All INFO, ERROR and WARN events going to 
 another appender. All BUSINESS events (my custom) level, going to yet another 
 appender.
 
 Seemed to me to be a similar use case to the SO question.
 
 Sent from my iPhone
 
 On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:
 
 I am not sure why Remko advised you to do it this way.  The first filter 
 will deny Warn, error and fatal making the next two filters redundant. The 
 third filter will accept events at level info and deny trace and debug.  So 
 the end result is the only events that will get logged will be those at INFO 
 level.
 
 The composite filter really just wraps other filters and returns whatever 
 result they generate. For example, if the first filter returns accept or 
 deny then that value will be returned as the result without consulting any 
 other filters. If the result is neutral then the second filter will be used 
 to see if the event passes that.
 
 Ralph
 
 
 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 Maybe.  However, I'm having a hard time following what the configuration is 
 saying and thus have no idea what I would need to put in the configuration. 
  Here is a snippet from that post:
 
 !-- Now deny warn, error and fatal messages --
 
ThresholdFilter level=warn  onMatch=DENY   
 onMismatch=NEUTRAL/
 
 ThresholdFilter level=error onMatch=DENY   
 onMismatch=NEUTRAL/
 ThresholdFilter level=fatal onMatch=DENY   
 onMismatch=NEUTRAL/
 
  !-- This filter accepts info, warn, error, fatal and denies 
 debug/trace --
 
  ThresholdFilter level=info  onMatch=ACCEPT onMismatch=DENY/
 
 
 The top three seem as if they would deny warn, error and fatal, yet the 
 third says it accepts info, warn, error and fatal.  And while I understand 
 those in isolation, I think, I have no idea how the filters composite 
 would handle this.  Why are the first three needed?  How does the 
 CompositeFilter work?  Does it try to match on each filter in the list of 
 stop as soon as it gets a DENY?
 
 What if I wanted to setup a filter which just accepted WARN?  And on top of 
 that ensure that if anyone defined any custom levels which are maybe just 1 
 away from WARN in either direction that those don't make it in the 
 appender.  How would you do that?
 
 How I did this with the log4net LevelRangeFilter was to set the levelMin 
 and levelMax to the same value.
 
 Thanks,
 Nick
 
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 To: log4j-user@logging.apache.org
 
 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I 
 would edit my answer (which I did).  
 
 So the answer works and seems to apply to your use case, no? The question 
 is if it also works with custom levels. 
 
 Sent from my iPhone
 
 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do 
 something similar to me.  I see the last comment on that is that it 
 doesn't work.
 
 There is another post afterwards which uses the ThresholdFilter.  However 
 the ThresholdFilter won't work as that allows, or denys, all levels 
 greater than or equal to or less than or equal to the level.  I need to 
 filter a specific range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
 I've tried a couple different combinations and so far no luck.  Here's
 the current configuration I tested with which doesn't work:
 
 File

Re: range filter?

2015-08-25 Thread Remko Popma
The StackOverflow link was an answer to the question how to send _only_ INFO 
level events to an appender. 

I thought it would illustrate how filters combinations could be used to achieve 
the original request: I might want all DEBUG, TRACE and VERBOSE events going 
to one appender.  All INFO, ERROR and WARN events going to another appender. 
All BUSINESS events (my custom) level, going to yet another appender.

Seemed to me to be a similar use case to the SO question.

Sent from my iPhone

 On 2015/08/26, at 11:44, Ralph Goers ralph.go...@dslextreme.com wrote:
 
 I am not sure why Remko advised you to do it this way.  The first filter will 
 deny Warn, error and fatal making the next two filters redundant. The third 
 filter will accept events at level info and deny trace and debug.  So the end 
 result is the only events that will get logged will be those at INFO level.
 
 The composite filter really just wraps other filters and returns whatever 
 result they generate. For example, if the first filter returns accept or deny 
 then that value will be returned as the result without consulting any other 
 filters. If the result is neutral then the second filter will be used to see 
 if the event passes that.
 
 Ralph
 
 
 On Aug 25, 2015, at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 Maybe.  However, I'm having a hard time following what the configuration is 
 saying and thus have no idea what I would need to put in the configuration.  
 Here is a snippet from that post:
 
  !-- Now deny warn, error and fatal messages --
 
 ThresholdFilter level=warn  onMatch=DENY   
 onMismatch=NEUTRAL/
 
  ThresholdFilter level=error onMatch=DENY   
 onMismatch=NEUTRAL/
  ThresholdFilter level=fatal onMatch=DENY   
 onMismatch=NEUTRAL/
 
   !-- This filter accepts info, warn, error, fatal and denies 
 debug/trace --
 
   ThresholdFilter level=info  onMatch=ACCEPT onMismatch=DENY/
 
 
 The top three seem as if they would deny warn, error and fatal, yet the 
 third says it accepts info, warn, error and fatal.  And while I understand 
 those in isolation, I think, I have no idea how the filters composite 
 would handle this.  Why are the first three needed?  How does the 
 CompositeFilter work?  Does it try to match on each filter in the list of 
 stop as soon as it gets a DENY?
 
 What if I wanted to setup a filter which just accepted WARN?  And on top of 
 that ensure that if anyone defined any custom levels which are maybe just 1 
 away from WARN in either direction that those don't make it in the appender. 
  How would you do that?
 
 How I did this with the log4net LevelRangeFilter was to set the levelMin and 
 levelMax to the same value.
 
 Thanks,
 Nick
 
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 To: log4j-user@logging.apache.org
 
 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I 
 would edit my answer (which I did).  
 
 So the answer works and seems to apply to your use case, no? The question 
 is if it also works with custom levels. 
 
 Sent from my iPhone
 
 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do 
 something similar to me.  I see the last comment on that is that it 
 doesn't work.
 
 There is another post afterwards which uses the ThresholdFilter.  However 
 the ThresholdFilter won't work as that allows, or denys, all levels 
 greater than or equal to or less than or equal to the level.  I need to 
 filter a specific range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
 I've tried a couple different combinations and so far no luck.  Here's
 the current configuration I tested with which doesn't work:
 
 File ...
 PatternLayout
...
 /PatternLayout
 Filters
ThresholdFilter level=INFO onMatch=DENY/
ThresholdFilter level=DEBUG onMatch=ACCEPT/
 /Filters
 /File
 
 The
 use case for why I want such a filter is to forward a range of events
 to an appender.  The threshold filter won't work because it will send
 all events matching a certain level and lower to the appender.  For
 instance, I might want all DEBUG, TRACE and VERBOSE events going to one
 appender.  All INFO, ERROR and WARN events going to another appender.
 All BUSINESS events (my custom) level, going to yet another appender.
 
 Thanks,
 Nick
 
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user

Re: range filter?

2015-08-25 Thread Gary Gregory
Right, the hard part is explaining how to use it, combine it, and how put all 
the puzzle pieces together. 
Gary 

 Original message 
From: Ralph Goers ralph.go...@dslextreme.com 
Date: 08/25/2015  21:28  (GMT-08:00) 
To: Log4J Users List log4j-user@logging.apache.org 
Subject: Re: range filter? 

Why not? It would take about 10 minutes to implement. In fact, I am sure it 
would take more time to document it than to implement it.

Ralph

 On Aug 25, 2015, at 8:42 PM, Gary Gregory garydgreg...@gmail.com wrote:
 
 I've got to say that I use MarkerFilters all the time, but I still need to
 refresh my brain when I've not used them in a while.
 
 If providing a LevelRangeFilter would be less confusing, then perhaps we
 should write one.
 
 Gary
 
 On Tue, Aug 25, 2015 at 7:09 PM, Nicholas Duane nic...@msn.com wrote:
 
 Maybe.  However, I'm having a hard time following what the configuration
 is saying and thus have no idea what I would need to put in the
 configuration.  Here is a snippet from that post:
 
   !-- Now deny warn, error and fatal messages --
 
  ThresholdFilter level=warn  onMatch=DENY
 onMismatch=NEUTRAL/
 
   ThresholdFilter level=error onMatch=DENY
 onMismatch=NEUTRAL/
   ThresholdFilter level=fatal onMatch=DENY
 onMismatch=NEUTRAL/
 
    !-- This filter accepts info, warn, error, fatal and denies
 debug/trace --
 
    ThresholdFilter level=info  onMatch=ACCEPT
 onMismatch=DENY/
 
 
 The top three seem as if they would deny warn, error and fatal, yet the
 third says it accepts info, warn, error and fatal.  And while I understand
 those in isolation, I think, I have no idea how the filters composite
 would handle this.  Why are the first three needed?  How does the
 CompositeFilter work?  Does it try to match on each filter in the list of
 stop as soon as it gets a DENY?
 
 What if I wanted to setup a filter which just accepted WARN?  And on top
 of that ensure that if anyone defined any custom levels which are maybe
 just 1 away from WARN in either direction that those don't make it in the
 appender.  How would you do that?
 
 How I did this with the log4net LevelRangeFilter was to set the levelMin
 and levelMax to the same value.
 
 Thanks,
 Nick
 
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 To: log4j-user@logging.apache.org
 
 You misread the comment. The commentor basically told me the answer
 works with a minor change, and that he would mark the question as done if
 I would edit my answer (which I did).
 
 So the answer works and seems to apply to your use case, no? The
 question is if it also works with custom levels.
 
 Sent from my iPhone
 
 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do
 something similar to me.  I see the last comment on that is that it doesn't
 work.
 
 There is another post afterwards which uses the ThresholdFilter.
 However the ThresholdFilter won't work as that allows, or denys, all levels
 greater than or equal to or less than or equal to the level.  I need to
 filter a specific range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com
 wrote:
 
 I've tried a couple different combinations and so far no luck.
 Here's
 the current configuration I tested with which doesn't work:
 
 File ...
 PatternLayout
 ...
  /PatternLayout
  Filters
 ThresholdFilter level=INFO onMatch=DENY/
 ThresholdFilter level=DEBUG onMatch=ACCEPT/
  /Filters
 /File
 
 The
 use case for why I want such a filter is to forward a range of events
 to an appender.  The threshold filter won't work because it will send
 all events matching a certain level and lower to the appender.  For
 instance, I might want all DEBUG, TRACE and VERBOSE events going to
 one
 appender.  All INFO, ERROR and WARN events going to another appender.
 All BUSINESS events (my custom) level, going to yet another appender.
 
 Thanks,
 Nick
 
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 When you get it working, it sounds like it would make a nice
 addition to
 the FAQ with a description of your use case.
 
 Gary
 
 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers 
 ralph.go...@dslextreme.com
 
 wrote:
 
 I believe two threshold filters inside a composite filter should
 should
 work provided you have the onMatch and onMismatch set
 appropriately.
 
 Ralph
 
 
 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com
 wrote:
 
 I'm looking for a range

Re: range filter?

2015-08-25 Thread Ralph Goers
I believe two threshold filters inside a composite filter should should work 
provided you have the onMatch and onMismatch set appropriately.

Ralph


 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
 
 I'm looking for a range filter in log4j2.  I see there is on in log4net and 
 it appears there was one written by someone for log4j 1.  Just wondering if 
 there is something 'out of the box' in log4j2 that will accomplish the same?  
 I was wondering whether this could be accomplished with the CompositeFilter 
 with two ThresholdFilter?
 
 Thanks,
 Nick
 



-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: range filter?

2015-08-25 Thread Gary Gregory
On Tue, Aug 25, 2015 at 4:52 PM, Nicholas Duane nic...@msn.com wrote:

 Basically I need the same functionality of the LevelRangeFilter in
 log4net, but of course in log4j2.


Patches welcome is something I often say ;-)

Gary


 Thanks,
 Nick

  From: nic...@msn.com
  To: log4j-user@logging.apache.org
  Subject: RE: range filter?
  Date: Tue, 25 Aug 2015 19:49:48 -0400
 
  Thanks.  I checked out the link.  It seems they were trying to do
 something similar to me.  I see the last comment on that is that it doesn't
 work.
 
  There is another post afterwards which uses the ThresholdFilter.
 However the ThresholdFilter won't work as that allows, or denys, all levels
 greater than or equal to or less than or equal to the level.  I need to
 filter a specific range of levels.
 
  Thanks,
  Nick
 
   Date: Wed, 26 Aug 2015 08:27:04 +0900
   Subject: Re: range filter?
   From: remko.po...@gmail.com
   To: log4j-user@logging.apache.org
  
   Can you try something similar to this
  
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
   and see if that works with custom levels as well?
  
   On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com
 wrote:
  
I've tried a couple different combinations and so far no luck.
 Here's
the current configuration I tested with which doesn't work:
   
File ...
  PatternLayout
  ...
   /PatternLayout
   Filters
  ThresholdFilter level=INFO onMatch=DENY/
  ThresholdFilter level=DEBUG onMatch=ACCEPT/
   /Filters
/File
   
The
 use case for why I want such a filter is to forward a range of
 events
to an appender.  The threshold filter won't work because it will send
all events matching a certain level and lower to the appender.  For
instance, I might want all DEBUG, TRACE and VERBOSE events going to
 one
appender.  All INFO, ERROR and WARN events going to another appender.
All BUSINESS events (my custom) level, going to yet another appender.
   
Thanks,
Nick
   
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org

 When you get it working, it sounds like it would make a nice
 addition to
 the FAQ with a description of your use case.

 Gary

 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers 
 ralph.go...@dslextreme.com

 wrote:

  I believe two threshold filters inside a composite filter should
 should
  work provided you have the onMatch and onMismatch set
 appropriately.
 
  Ralph
 
 
   On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com
 wrote:
  
   I'm looking for a range filter in log4j2.  I see there is on in
log4net
  and it appears there was one written by someone for log4j 1.
 Just
  wondering if there is something 'out of the box' in log4j2 that
 will
  accomplish the same?  I was wondering whether this could be
accomplished
  with the CompositeFilter with two ThresholdFilter?
  
   Thanks,
   Nick
  
 
 
 
 
 -
  To unsubscribe, e-mail:
 log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail:
 log4j-user-h...@logging.apache.org
 
 


 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory
   
   
 





-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition
http://www.manning.com/bauer3/
JUnit in Action, Second Edition http://www.manning.com/tahchiev/
Spring Batch in Action http://www.manning.com/templier/
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory


Re: range filter?

2015-08-25 Thread Gary Gregory
Hm... maybe we need
a org.apache.logging.log4j.Level.isInRange(Level, Level) method to help
implement this filter...

Gary

On Tue, Aug 25, 2015 at 5:02 PM, Gary Gregory garydgreg...@gmail.com
wrote:

 On Tue, Aug 25, 2015 at 4:52 PM, Nicholas Duane nic...@msn.com wrote:

 Basically I need the same functionality of the LevelRangeFilter in
 log4net, but of course in log4j2.


 Patches welcome is something I often say ;-)

 Gary


 Thanks,
 Nick

  From: nic...@msn.com
  To: log4j-user@logging.apache.org
  Subject: RE: range filter?
  Date: Tue, 25 Aug 2015 19:49:48 -0400
 
  Thanks.  I checked out the link.  It seems they were trying to do
 something similar to me.  I see the last comment on that is that it doesn't
 work.
 
  There is another post afterwards which uses the ThresholdFilter.
 However the ThresholdFilter won't work as that allows, or denys, all levels
 greater than or equal to or less than or equal to the level.  I need to
 filter a specific range of levels.
 
  Thanks,
  Nick
 
   Date: Wed, 26 Aug 2015 08:27:04 +0900
   Subject: Re: range filter?
   From: remko.po...@gmail.com
   To: log4j-user@logging.apache.org
  
   Can you try something similar to this
  
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
   and see if that works with custom levels as well?
  
   On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com
 wrote:
  
I've tried a couple different combinations and so far no luck.
 Here's
the current configuration I tested with which doesn't work:
   
File ...
  PatternLayout
  ...
   /PatternLayout
   Filters
  ThresholdFilter level=INFO onMatch=DENY/
  ThresholdFilter level=DEBUG onMatch=ACCEPT/
   /Filters
/File
   
The
 use case for why I want such a filter is to forward a range of
 events
to an appender.  The threshold filter won't work because it will
 send
all events matching a certain level and lower to the appender.  For
instance, I might want all DEBUG, TRACE and VERBOSE events going to
 one
appender.  All INFO, ERROR and WARN events going to another
 appender.
All BUSINESS events (my custom) level, going to yet another
 appender.
   
Thanks,
Nick
   
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org

 When you get it working, it sounds like it would make a nice
 addition to
 the FAQ with a description of your use case.

 Gary

 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers 
 ralph.go...@dslextreme.com

 wrote:

  I believe two threshold filters inside a composite filter
 should should
  work provided you have the onMatch and onMismatch set
 appropriately.
 
  Ralph
 
 
   On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com
 wrote:
  
   I'm looking for a range filter in log4j2.  I see there is on
 in
log4net
  and it appears there was one written by someone for log4j 1.
 Just
  wondering if there is something 'out of the box' in log4j2 that
 will
  accomplish the same?  I was wondering whether this could be
accomplished
  with the CompositeFilter with two ThresholdFilter?
  
   Thanks,
   Nick
  
 
 
 
 
 -
  To unsubscribe, e-mail:
 log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail:
 log4j-user-h...@logging.apache.org
 
 


 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory
   
   
 





 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory




-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition
http://www.manning.com/bauer3/
JUnit in Action, Second Edition http://www.manning.com/tahchiev/
Spring Batch in Action http://www.manning.com/templier/
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory


Re: range filter?

2015-08-25 Thread Remko Popma
You misread the comment. The commentor basically told me the answer works with 
a minor change, and that he would mark the question as done if I would edit 
my answer (which I did).  

So the answer works and seems to apply to your use case, no? The question is if 
it also works with custom levels. 

Sent from my iPhone

 On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do something 
 similar to me.  I see the last comment on that is that it doesn't work.
 
 There is another post afterwards which uses the ThresholdFilter.  However the 
 ThresholdFilter won't work as that allows, or denys, all levels greater than 
 or equal to or less than or equal to the level.  I need to filter a specific 
 range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
 I've tried a couple different combinations and so far no luck.  Here's
 the current configuration I tested with which doesn't work:
 
 File ...
  PatternLayout
  ...
   /PatternLayout
   Filters
  ThresholdFilter level=INFO onMatch=DENY/
  ThresholdFilter level=DEBUG onMatch=ACCEPT/
   /Filters
 /File
 
 The
 use case for why I want such a filter is to forward a range of events
 to an appender.  The threshold filter won't work because it will send
 all events matching a certain level and lower to the appender.  For
 instance, I might want all DEBUG, TRACE and VERBOSE events going to one
 appender.  All INFO, ERROR and WARN events going to another appender.
 All BUSINESS events (my custom) level, going to yet another appender.
 
 Thanks,
 Nick
 
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 When you get it working, it sounds like it would make a nice addition to
 the FAQ with a description of your use case.
 
 Gary
 
 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
 
 wrote:
 
 I believe two threshold filters inside a composite filter should should
 work provided you have the onMatch and onMismatch set appropriately.
 
 Ralph
 
 
 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
 
 I'm looking for a range filter in log4j2.  I see there is on in
 log4net
 and it appears there was one written by someone for log4j 1.  Just
 wondering if there is something 'out of the box' in log4j2 that will
 accomplish the same?  I was wondering whether this could be
 accomplished
 with the CompositeFilter with two ThresholdFilter?
 
 Thanks,
 Nick
 
 
 
 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory
 

-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: range filter?

2015-08-25 Thread Ralph Goers
From the manual - This filter returns the onMatch result if the level in the 
LogEvent is the same or more specific than the configured level and the 
onMismatch value otherwise.”

So if you have 

Filters
  ThresholdFilter level=“DEBUG” onMatch=“NEUTRAL” onMisMatch=“DENY”
  ThresholdFilter level=“WARN” onMatch=“DENY” onMisMatch=“NEUTRAL”
Filters

Then the first filter should allow Debug, Info, Warn, Error, and Fatal through, 
discarding Trace events.  The second filter will deny Warn, Error and Fatal 
events, allowing Debug and Info to continue to be filtered. If you want them to 
be unconditionally processed regardless of other filters then set the 
onMisMatch to ACCEPT.

Ralph



 On Aug 25, 2015, at 4:49 PM, Nicholas Duane nic...@msn.com wrote:
 
 Thanks.  I checked out the link.  It seems they were trying to do something 
 similar to me.  I see the last comment on that is that it doesn't work.
 
 There is another post afterwards which uses the ThresholdFilter.  However the 
 ThresholdFilter won't work as that allows, or denys, all levels greater than 
 or equal to or less than or equal to the level.  I need to filter a specific 
 range of levels.
 
 Thanks,
 Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
 I've tried a couple different combinations and so far no luck.  Here's
 the current configuration I tested with which doesn't work:
 
 File ...
  PatternLayout
  ...
   /PatternLayout
   Filters
  ThresholdFilter level=INFO onMatch=DENY/
  ThresholdFilter level=DEBUG onMatch=ACCEPT/
   /Filters
 /File
 
 The
 use case for why I want such a filter is to forward a range of events
 to an appender.  The threshold filter won't work because it will send
 all events matching a certain level and lower to the appender.  For
 instance, I might want all DEBUG, TRACE and VERBOSE events going to one
 appender.  All INFO, ERROR and WARN events going to another appender.
 All BUSINESS events (my custom) level, going to yet another appender.
 
 Thanks,
 Nick
 
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 When you get it working, it sounds like it would make a nice addition to
 the FAQ with a description of your use case.
 
 Gary
 
 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
 
 wrote:
 
 I believe two threshold filters inside a composite filter should should
 work provided you have the onMatch and onMismatch set appropriately.
 
 Ralph
 
 
 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
 
 I'm looking for a range filter in log4j2.  I see there is on in
 log4net
 and it appears there was one written by someone for log4j 1.  Just
 wondering if there is something 'out of the box' in log4j2 that will
 accomplish the same?  I was wondering whether this could be
 accomplished
 with the CompositeFilter with two ThresholdFilter?
 
 Thanks,
 Nick
 
 
 
 
 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 
 --
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory
 
 
 



Re: range filter?

2015-08-25 Thread Ralph Goers
I should also point out that if you look at the documentation you will see that 
the default value for onMisMatch is “Deny”. So your first filter tests the log 
level and no matter what the level is it will discard the event.

Ralph

 On Aug 25, 2015, at 2:04 PM, Nicholas Duane nic...@msn.com wrote:
 
 I've tried a couple different combinations and so far no luck.  Here's 
 the current configuration I tested with which doesn't work:
 
 File ...
  PatternLayout
  ...
   /PatternLayout
   Filters
  ThresholdFilter level=INFO onMatch=DENY/
  ThresholdFilter level=DEBUG onMatch=ACCEPT/
   /Filters
 /File
 
 The
 use case for why I want such a filter is to forward a range of events 
 to an appender.  The threshold filter won't work because it will send 
 all events matching a certain level and lower to the appender.  For 
 instance, I might want all DEBUG, TRACE and VERBOSE events going to one 
 appender.  All INFO, ERROR and WARN events going to another appender.  
 All BUSINESS events (my custom) level, going to yet another appender.
 
 Thanks,
 Nick
 
 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 When you get it working, it sounds like it would make a nice addition to
 the FAQ with a description of your use case.
 
 Gary
 
 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
 wrote:
 
 I believe two threshold filters inside a composite filter should should
 work provided you have the onMatch and onMismatch set appropriately.
 
 Ralph
 
 
 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
 
 I'm looking for a range filter in log4j2.  I see there is on in log4net
 and it appears there was one written by someone for log4j 1.  Just
 wondering if there is something 'out of the box' in log4j2 that will
 accomplish the same?  I was wondering whether this could be accomplished
 with the CompositeFilter with two ThresholdFilter?
 
 Thanks,
 Nick
 
 
 
 
 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 
 -- 
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory
 



-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org



Re: range filter?

2015-08-25 Thread Remko Popma
Can you try something similar to this
http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
and see if that works with custom levels as well?

On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:

 I've tried a couple different combinations and so far no luck.  Here's
 the current configuration I tested with which doesn't work:

 File ...
   PatternLayout
   ...
/PatternLayout
Filters
   ThresholdFilter level=INFO onMatch=DENY/
   ThresholdFilter level=DEBUG onMatch=ACCEPT/
/Filters
 /File

 The
  use case for why I want such a filter is to forward a range of events
 to an appender.  The threshold filter won't work because it will send
 all events matching a certain level and lower to the appender.  For
 instance, I might want all DEBUG, TRACE and VERBOSE events going to one
 appender.  All INFO, ERROR and WARN events going to another appender.
 All BUSINESS events (my custom) level, going to yet another appender.

 Thanks,
 Nick

  Date: Tue, 25 Aug 2015 13:17:44 -0700
  Subject: Re: range filter?
  From: garydgreg...@gmail.com
  To: log4j-user@logging.apache.org
 
  When you get it working, it sounds like it would make a nice addition to
  the FAQ with a description of your use case.
 
  Gary
 
  On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
 
  wrote:
 
   I believe two threshold filters inside a composite filter should should
   work provided you have the onMatch and onMismatch set appropriately.
  
   Ralph
  
  
On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
   
I'm looking for a range filter in log4j2.  I see there is on in
 log4net
   and it appears there was one written by someone for log4j 1.  Just
   wondering if there is something 'out of the box' in log4j2 that will
   accomplish the same?  I was wondering whether this could be
 accomplished
   with the CompositeFilter with two ThresholdFilter?
   
Thanks,
Nick
   
  
  
  
   -
   To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
   For additional commands, e-mail: log4j-user-h...@logging.apache.org
  
  
 
 
  --
  E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
  Java Persistence with Hibernate, Second Edition
  http://www.manning.com/bauer3/
  JUnit in Action, Second Edition http://www.manning.com/tahchiev/
  Spring Batch in Action http://www.manning.com/templier/
  Blog: http://garygregory.wordpress.com
  Home: http://garygregory.com/
  Tweet! http://twitter.com/GaryGregory




RE: range filter?

2015-08-25 Thread Nicholas Duane
Thanks.  I checked out the link.  It seems they were trying to do something 
similar to me.  I see the last comment on that is that it doesn't work.
 
There is another post afterwards which uses the ThresholdFilter.  However the 
ThresholdFilter won't work as that allows, or denys, all levels greater than or 
equal to or less than or equal to the level.  I need to filter a specific range 
of levels.
 
Thanks,
Nick
 
 Date: Wed, 26 Aug 2015 08:27:04 +0900
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 To: log4j-user@logging.apache.org
 
 Can you try something similar to this
 http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
 and see if that works with custom levels as well?
 
 On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
 
  I've tried a couple different combinations and so far no luck.  Here's
  the current configuration I tested with which doesn't work:
 
  File ...
PatternLayout
...
 /PatternLayout
 Filters
ThresholdFilter level=INFO onMatch=DENY/
ThresholdFilter level=DEBUG onMatch=ACCEPT/
 /Filters
  /File
 
  The
   use case for why I want such a filter is to forward a range of events
  to an appender.  The threshold filter won't work because it will send
  all events matching a certain level and lower to the appender.  For
  instance, I might want all DEBUG, TRACE and VERBOSE events going to one
  appender.  All INFO, ERROR and WARN events going to another appender.
  All BUSINESS events (my custom) level, going to yet another appender.
 
  Thanks,
  Nick
 
   Date: Tue, 25 Aug 2015 13:17:44 -0700
   Subject: Re: range filter?
   From: garydgreg...@gmail.com
   To: log4j-user@logging.apache.org
  
   When you get it working, it sounds like it would make a nice addition to
   the FAQ with a description of your use case.
  
   Gary
  
   On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
  
   wrote:
  
I believe two threshold filters inside a composite filter should should
work provided you have the onMatch and onMismatch set appropriately.
   
Ralph
   
   
 On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:

 I'm looking for a range filter in log4j2.  I see there is on in
  log4net
and it appears there was one written by someone for log4j 1.  Just
wondering if there is something 'out of the box' in log4j2 that will
accomplish the same?  I was wondering whether this could be
  accomplished
with the CompositeFilter with two ThresholdFilter?

 Thanks,
 Nick

   
   
   
-
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org
   
   
  
  
   --
   E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
   Java Persistence with Hibernate, Second Edition
   http://www.manning.com/bauer3/
   JUnit in Action, Second Edition http://www.manning.com/tahchiev/
   Spring Batch in Action http://www.manning.com/templier/
   Blog: http://garygregory.wordpress.com
   Home: http://garygregory.com/
   Tweet! http://twitter.com/GaryGregory
 
 
  

RE: range filter?

2015-08-25 Thread Nicholas Duane
Basically I need the same functionality of the LevelRangeFilter in log4net, but 
of course in log4j2.
 
Thanks,
Nick
 
 From: nic...@msn.com
 To: log4j-user@logging.apache.org
 Subject: RE: range filter?
 Date: Tue, 25 Aug 2015 19:49:48 -0400
 
 Thanks.  I checked out the link.  It seems they were trying to do something 
 similar to me.  I see the last comment on that is that it doesn't work.
  
 There is another post afterwards which uses the ThresholdFilter.  However the 
 ThresholdFilter won't work as that allows, or denys, all levels greater than 
 or equal to or less than or equal to the level.  I need to filter a specific 
 range of levels.
  
 Thanks,
 Nick
  
  Date: Wed, 26 Aug 2015 08:27:04 +0900
  Subject: Re: range filter?
  From: remko.po...@gmail.com
  To: log4j-user@logging.apache.org
  
  Can you try something similar to this
  http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
  and see if that works with custom levels as well?
  
  On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
  
   I've tried a couple different combinations and so far no luck.  Here's
   the current configuration I tested with which doesn't work:
  
   File ...
 PatternLayout
 ...
  /PatternLayout
  Filters
 ThresholdFilter level=INFO onMatch=DENY/
 ThresholdFilter level=DEBUG onMatch=ACCEPT/
  /Filters
   /File
  
   The
use case for why I want such a filter is to forward a range of events
   to an appender.  The threshold filter won't work because it will send
   all events matching a certain level and lower to the appender.  For
   instance, I might want all DEBUG, TRACE and VERBOSE events going to one
   appender.  All INFO, ERROR and WARN events going to another appender.
   All BUSINESS events (my custom) level, going to yet another appender.
  
   Thanks,
   Nick
  
Date: Tue, 25 Aug 2015 13:17:44 -0700
Subject: Re: range filter?
From: garydgreg...@gmail.com
To: log4j-user@logging.apache.org
   
When you get it working, it sounds like it would make a nice addition to
the FAQ with a description of your use case.
   
Gary
   
On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
   
wrote:
   
 I believe two threshold filters inside a composite filter should 
 should
 work provided you have the onMatch and onMismatch set appropriately.

 Ralph


  On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
 
  I'm looking for a range filter in log4j2.  I see there is on in
   log4net
 and it appears there was one written by someone for log4j 1.  Just
 wondering if there is something 'out of the box' in log4j2 that will
 accomplish the same?  I was wondering whether this could be
   accomplished
 with the CompositeFilter with two ThresholdFilter?
 
  Thanks,
  Nick
 



 -
 To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
 For additional commands, e-mail: log4j-user-h...@logging.apache.org


   
   
--
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
Java Persistence with Hibernate, Second Edition
http://www.manning.com/bauer3/
JUnit in Action, Second Edition http://www.manning.com/tahchiev/
Spring Batch in Action http://www.manning.com/templier/
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
  
  
 
  

RE: range filter?

2015-08-25 Thread Nicholas Duane
I've tried a couple different combinations and so far no luck.  Here's 
the current configuration I tested with which doesn't work:

File ...
  PatternLayout
  ...
   /PatternLayout
   Filters
  ThresholdFilter level=INFO onMatch=DENY/
  ThresholdFilter level=DEBUG onMatch=ACCEPT/
   /Filters
/File

The
 use case for why I want such a filter is to forward a range of events 
to an appender.  The threshold filter won't work because it will send 
all events matching a certain level and lower to the appender.  For 
instance, I might want all DEBUG, TRACE and VERBOSE events going to one 
appender.  All INFO, ERROR and WARN events going to another appender.  
All BUSINESS events (my custom) level, going to yet another appender.

Thanks,
Nick

 Date: Tue, 25 Aug 2015 13:17:44 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 When you get it working, it sounds like it would make a nice addition to
 the FAQ with a description of your use case.
 
 Gary
 
 On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
 wrote:
 
  I believe two threshold filters inside a composite filter should should
  work provided you have the onMatch and onMismatch set appropriately.
 
  Ralph
 
 
   On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
  
   I'm looking for a range filter in log4j2.  I see there is on in log4net
  and it appears there was one written by someone for log4j 1.  Just
  wondering if there is something 'out of the box' in log4j2 that will
  accomplish the same?  I was wondering whether this could be accomplished
  with the CompositeFilter with two ThresholdFilter?
  
   Thanks,
   Nick
  
 
 
 
  -
  To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 
 -- 
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http://garygregory.wordpress.com
 Home: http://garygregory.com/
 Tweet! http://twitter.com/GaryGregory
  

RE: range filter?

2015-08-25 Thread Nicholas Duane
By the way, let me say that I'm surprisingly delighted by the quickness of 
responses and level of interest in solving these issues.  THANK YOU.  I guess 
after posting a few messages on the log4net mailing list and getting no 
responses I wasn't too hopeful about getting responses to my log4j questions.  
I guess there is a big difference in support between the two products?
 
Thanks,
Nick
 
 Date: Tue, 25 Aug 2015 17:37:18 -0700
 Subject: Re: range filter?
 From: garydgreg...@gmail.com
 To: log4j-user@logging.apache.org
 
 Ah, yes, sorry, I had not read it in detail. It would be nice to expand the
 unit test I just committed with a more complex scenario.
 
 Could this use better docs or a FAQ entry?
 
 Gary
 
 On Tue, Aug 25, 2015 at 5:12 PM, Remko Popma remko.po...@gmail.com wrote:
 
  You misread the comment. The commentor basically told me the answer works
  with a minor change, and that he would mark the question as done if I
  would edit my answer (which I did).
 
  So the answer works and seems to apply to your use case, no? The question
  is if it also works with custom levels.
 
  Sent from my iPhone
 
   On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
  
   Thanks.  I checked out the link.  It seems they were trying to do
  something similar to me.  I see the last comment on that is that it doesn't
  work.
  
   There is another post afterwards which uses the ThresholdFilter.
  However the ThresholdFilter won't work as that allows, or denys, all levels
  greater than or equal to or less than or equal to the level.  I need to
  filter a specific range of levels.
  
   Thanks,
   Nick
  
   Date: Wed, 26 Aug 2015 08:27:04 +0900
   Subject: Re: range filter?
   From: remko.po...@gmail.com
   To: log4j-user@logging.apache.org
  
   Can you try something similar to this
  
  http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
   and see if that works with custom levels as well?
  
   On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com
  wrote:
  
   I've tried a couple different combinations and so far no luck.  Here's
   the current configuration I tested with which doesn't work:
  
   File ...
PatternLayout
...
 /PatternLayout
 Filters
ThresholdFilter level=INFO onMatch=DENY/
ThresholdFilter level=DEBUG onMatch=ACCEPT/
 /Filters
   /File
  
   The
   use case for why I want such a filter is to forward a range of events
   to an appender.  The threshold filter won't work because it will send
   all events matching a certain level and lower to the appender.  For
   instance, I might want all DEBUG, TRACE and VERBOSE events going to one
   appender.  All INFO, ERROR and WARN events going to another appender.
   All BUSINESS events (my custom) level, going to yet another appender.
  
   Thanks,
   Nick
  
   Date: Tue, 25 Aug 2015 13:17:44 -0700
   Subject: Re: range filter?
   From: garydgreg...@gmail.com
   To: log4j-user@logging.apache.org
  
   When you get it working, it sounds like it would make a nice addition
  to
   the FAQ with a description of your use case.
  
   Gary
  
   On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers 
  ralph.go...@dslextreme.com
  
   wrote:
  
   I believe two threshold filters inside a composite filter should
  should
   work provided you have the onMatch and onMismatch set appropriately.
  
   Ralph
  
  
   On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com
  wrote:
  
   I'm looking for a range filter in log4j2.  I see there is on in
   log4net
   and it appears there was one written by someone for log4j 1.  Just
   wondering if there is something 'out of the box' in log4j2 that will
   accomplish the same?  I was wondering whether this could be
   accomplished
   with the CompositeFilter with two ThresholdFilter?
  
   Thanks,
   Nick
  
  
  
   -
   To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
   For additional commands, e-mail: log4j-user-h...@logging.apache.org
  
  
   --
   E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
   Java Persistence with Hibernate, Second Edition
   http://www.manning.com/bauer3/
   JUnit in Action, Second Edition http://www.manning.com/tahchiev/
   Spring Batch in Action http://www.manning.com/templier/
   Blog: http://garygregory.wordpress.com
   Home: http://garygregory.com/
   Tweet! http://twitter.com/GaryGregory
  
 
  -
  To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail: log4j-user-h...@logging.apache.org
 
 
 
 
 -- 
 E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
 Java Persistence with Hibernate, Second Edition
 http://www.manning.com/bauer3/
 JUnit in Action, Second Edition http://www.manning.com/tahchiev/
 Spring Batch in Action http://www.manning.com/templier/
 Blog: http

RE: range filter?

2015-08-25 Thread Nicholas Duane
Maybe.  However, I'm having a hard time following what the configuration is 
saying and thus have no idea what I would need to put in the configuration.  
Here is a snippet from that post:
 
   !-- Now deny warn, error and fatal messages --

  ThresholdFilter level=warn  onMatch=DENY   
onMismatch=NEUTRAL/

   ThresholdFilter level=error onMatch=DENY   
onMismatch=NEUTRAL/
   ThresholdFilter level=fatal onMatch=DENY   
onMismatch=NEUTRAL/
   
!-- This filter accepts info, warn, error, fatal and denies 
debug/trace --

ThresholdFilter level=info  onMatch=ACCEPT onMismatch=DENY/


The top three seem as if they would deny warn, error and fatal, yet the third 
says it accepts info, warn, error and fatal.  And while I understand those in 
isolation, I think, I have no idea how the filters composite would handle 
this.  Why are the first three needed?  How does the CompositeFilter work?  
Does it try to match on each filter in the list of stop as soon as it gets a 
DENY?
 
What if I wanted to setup a filter which just accepted WARN?  And on top of 
that ensure that if anyone defined any custom levels which are maybe just 1 
away from WARN in either direction that those don't make it in the appender.  
How would you do that?
 
How I did this with the log4net LevelRangeFilter was to set the levelMin and 
levelMax to the same value.
 
Thanks,
Nick
 
 Subject: Re: range filter?
 From: remko.po...@gmail.com
 Date: Wed, 26 Aug 2015 09:12:29 +0900
 To: log4j-user@logging.apache.org
 
 You misread the comment. The commentor basically told me the answer works 
 with a minor change, and that he would mark the question as done if I would 
 edit my answer (which I did).  
 
 So the answer works and seems to apply to your use case, no? The question is 
 if it also works with custom levels. 
 
 Sent from my iPhone
 
  On 2015/08/26, at 8:49, Nicholas Duane nic...@msn.com wrote:
  
  Thanks.  I checked out the link.  It seems they were trying to do something 
  similar to me.  I see the last comment on that is that it doesn't work.
  
  There is another post afterwards which uses the ThresholdFilter.  However 
  the ThresholdFilter won't work as that allows, or denys, all levels greater 
  than or equal to or less than or equal to the level.  I need to filter a 
  specific range of levels.
  
  Thanks,
  Nick
  
  Date: Wed, 26 Aug 2015 08:27:04 +0900
  Subject: Re: range filter?
  From: remko.po...@gmail.com
  To: log4j-user@logging.apache.org
  
  Can you try something similar to this
  http://stackoverflow.com/questions/24695133/log4j2-filter-particular-level-in-apender/24697002#24697002
  and see if that works with custom levels as well?
  
  On Wed, Aug 26, 2015 at 6:04 AM, Nicholas Duane nic...@msn.com wrote:
  
  I've tried a couple different combinations and so far no luck.  Here's
  the current configuration I tested with which doesn't work:
  
  File ...
   PatternLayout
   ...
/PatternLayout
Filters
   ThresholdFilter level=INFO onMatch=DENY/
   ThresholdFilter level=DEBUG onMatch=ACCEPT/
/Filters
  /File
  
  The
  use case for why I want such a filter is to forward a range of events
  to an appender.  The threshold filter won't work because it will send
  all events matching a certain level and lower to the appender.  For
  instance, I might want all DEBUG, TRACE and VERBOSE events going to one
  appender.  All INFO, ERROR and WARN events going to another appender.
  All BUSINESS events (my custom) level, going to yet another appender.
  
  Thanks,
  Nick
  
  Date: Tue, 25 Aug 2015 13:17:44 -0700
  Subject: Re: range filter?
  From: garydgreg...@gmail.com
  To: log4j-user@logging.apache.org
  
  When you get it working, it sounds like it would make a nice addition to
  the FAQ with a description of your use case.
  
  Gary
  
  On Tue, Aug 25, 2015 at 1:11 PM, Ralph Goers ralph.go...@dslextreme.com
  
  wrote:
  
  I believe two threshold filters inside a composite filter should should
  work provided you have the onMatch and onMismatch set appropriately.
  
  Ralph
  
  
  On Aug 25, 2015, at 12:36 PM, Nicholas Duane nic...@msn.com wrote:
  
  I'm looking for a range filter in log4j2.  I see there is on in
  log4net
  and it appears there was one written by someone for log4j 1.  Just
  wondering if there is something 'out of the box' in log4j2 that will
  accomplish the same?  I was wondering whether this could be
  accomplished
  with the CompositeFilter with two ThresholdFilter?
  
  Thanks,
  Nick
  
  
  
  -
  To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
  For additional commands, e-mail: log4j-user-h...@logging.apache.org
  
  
  --
  E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
  Java Persistence with Hibernate, Second Edition
  http://www.manning.com/bauer3/
  JUnit in Action, Second Edition http