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 <[email protected]> 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: [email protected]
> > Date: Wed, 26 Aug 2015 09:12:29 +0900
> > To: [email protected]
> >
> > 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 <[email protected]> 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: [email protected]
> > >> To: [email protected]
> > >>
> > >> 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 <[email protected]>
> 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: [email protected]
> > >>>> To: [email protected]
> > >>>>
> > >>>> 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 <
> [email protected]
> > >>>>
> > >>>> 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 <[email protected]>
> 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: [email protected]
> > >>>>> For additional commands, e-mail:
> [email protected]
> > >>>>
> > >>>>
> > >>>> --
> > >>>> E-Mail: [email protected] | [email protected]
> > >>>> 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: [email protected]
> > For additional commands, e-mail: [email protected]
> >
>
>



-- 
E-Mail: [email protected] | [email protected]
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

Reply via email to