You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Guy Marom <ma...@gmail.com> on 2016/12/06 19:59:39 UTC
Context-wide filter not working for me
Hello everyone,
I have a problem with activating a context-wide filter. I created my own
filter, made it inherit from *AbstractFilter* and then overridden the
method
public Result filter(LogEvent event)
This method was never called so I decided to try with an existing filter,
here's my config file:
<configuration monitorInterval="5">
<!--<MetricWritingFilter />-->
<ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
<appenders>
<console name="stdout" target="SYSTEM_OUT">
<patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
</console>
</appenders>
<loggers>
<logger name="com.outbrain.test" level="info" />
<root level="error">
<!--<appenderRef ref="wfePartitionedJobAppender"/>-->
<appenderRef ref="stdout"/>
</root>
</loggers>
</configuration>
The filter works but when I put a breakpoint inside the ThresholdFilter
class I see it doesn't stop in the method I mentioned earlier:
[image: Inline image 1]
Am I missing something here?
Thanks,
Guy Marom
Re: Context-wide filter not working for me
Posted by Guy Marom <ma...@gmail.com>.
Yes, you are right that a different method gets called but that method is
an appender filter method. I can see that from the stack trace...
I guess it's the only choice I have right?
On Dec 7, 2016 6:23 AM, "Remko Popma" <re...@gmail.com> wrote:
I think the docs are wrong. Try it.
Remko
On Wed, 7 Dec 2016 at 13:19 Guy Marom <ma...@gmail.com> wrote:
> The documentation of the *AbstractFilter* class says differently:
>
>
>
> /**
>
> * Context Filter method. The default returns NEUTRAL.
>
> * @param event The LogEvent.
>
> * @return The Result of filtering.
>
> */
>
> @Override
>
> public Result filter(final LogEvent event) {
>
> return Result.NEUTRAL;
>
> }
>
>
>
>
>
> All the other methods are marked as "Appender filter" methods, and my
needs
>
> are to intercept all messages before they reach any appender.
>
> So maybe that's the question I need to ask - how do I filter all messages
>
> before they reach any appender?
>
>
>
> Thanks,
>
> Guy
>
>
>
>
>
> On Wed, Dec 7, 2016 at 1:37 AM, Remko Popma <re...@gmail.com> wrote:
>
>
>
> > The Filter interface has several methods, which can get called at
>
> > different times.
>
> >
>
> > For context-wide filters, the methods _without_ LogEvent will be called.
>
> >
>
> > Sent from my iPhone
>
> >
>
> > > On 7 Dec 2016, at 5:18, Matt Sicker <bo...@gmail.com> wrote:
>
> > >
>
> > > Can you set status="debug" in your <configuration/> element? Also, did
>
> > you
>
> > > remember to add all the necessary annotations on your plugin along
with
>
> > > enabling annotation processing if needed?
>
> > >
>
> > >> On 6 December 2016 at 13:59, Guy Marom <ma...@gmail.com> wrote:
>
> > >>
>
> > >> Hello everyone,
>
> > >>
>
> > >> I have a problem with activating a context-wide filter. I created my
> own
>
> > >> filter, made it inherit from *AbstractFilter* and then overridden the
>
> > >> method
>
> > >>
>
> > >> public Result filter(LogEvent event)
>
> > >>
>
> > >> This method was never called so I decided to try with an existing
>
> > filter,
>
> > >> here's my config file:
>
> > >>
>
> > >> <configuration monitorInterval="5">
>
> > >> <!--<MetricWritingFilter />-->
>
> > >> <ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
>
> > >>
>
> > >> <appenders>
>
> > >> <console name="stdout" target="SYSTEM_OUT">
>
> > >> <patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
>
> > >> </console>
>
> > >> </appenders>
>
> > >>
>
> > >> <loggers>
>
> > >> <logger name="com.outbrain.test" level="info" />
>
> > >> <root level="error">
>
> > >> <!--<appenderRef ref="wfePartitionedJobAppender"/>-->
>
> > >> <appenderRef ref="stdout"/>
>
> > >> </root>
>
> > >> </loggers>
>
> > >> </configuration>
>
> > >>
>
> > >>
>
> > >> The filter works but when I put a breakpoint inside the
> ThresholdFilter
>
> > >> class I see it doesn't stop in the method I mentioned earlier:
>
> > >> [image: Inline image 1]
>
> > >>
>
> > >> Am I missing something here?
>
> > >>
>
> > >> Thanks,
>
> > >> Guy Marom
>
> > >>
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > > Matt Sicker <bo...@gmail.com>
>
> >
>
> > ---------------------------------------------------------------------
>
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
>
> >
>
> >
>
>
Re: Context-wide filter not working for me
Posted by Remko Popma <re...@gmail.com>.
I think the docs are wrong. Try it.
Remko
On Wed, 7 Dec 2016 at 13:19 Guy Marom <ma...@gmail.com> wrote:
> The documentation of the *AbstractFilter* class says differently:
>
>
>
> /**
>
> * Context Filter method. The default returns NEUTRAL.
>
> * @param event The LogEvent.
>
> * @return The Result of filtering.
>
> */
>
> @Override
>
> public Result filter(final LogEvent event) {
>
> return Result.NEUTRAL;
>
> }
>
>
>
>
>
> All the other methods are marked as "Appender filter" methods, and my needs
>
> are to intercept all messages before they reach any appender.
>
> So maybe that's the question I need to ask - how do I filter all messages
>
> before they reach any appender?
>
>
>
> Thanks,
>
> Guy
>
>
>
>
>
> On Wed, Dec 7, 2016 at 1:37 AM, Remko Popma <re...@gmail.com> wrote:
>
>
>
> > The Filter interface has several methods, which can get called at
>
> > different times.
>
> >
>
> > For context-wide filters, the methods _without_ LogEvent will be called.
>
> >
>
> > Sent from my iPhone
>
> >
>
> > > On 7 Dec 2016, at 5:18, Matt Sicker <bo...@gmail.com> wrote:
>
> > >
>
> > > Can you set status="debug" in your <configuration/> element? Also, did
>
> > you
>
> > > remember to add all the necessary annotations on your plugin along with
>
> > > enabling annotation processing if needed?
>
> > >
>
> > >> On 6 December 2016 at 13:59, Guy Marom <ma...@gmail.com> wrote:
>
> > >>
>
> > >> Hello everyone,
>
> > >>
>
> > >> I have a problem with activating a context-wide filter. I created my
> own
>
> > >> filter, made it inherit from *AbstractFilter* and then overridden the
>
> > >> method
>
> > >>
>
> > >> public Result filter(LogEvent event)
>
> > >>
>
> > >> This method was never called so I decided to try with an existing
>
> > filter,
>
> > >> here's my config file:
>
> > >>
>
> > >> <configuration monitorInterval="5">
>
> > >> <!--<MetricWritingFilter />-->
>
> > >> <ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
>
> > >>
>
> > >> <appenders>
>
> > >> <console name="stdout" target="SYSTEM_OUT">
>
> > >> <patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
>
> > >> </console>
>
> > >> </appenders>
>
> > >>
>
> > >> <loggers>
>
> > >> <logger name="com.outbrain.test" level="info" />
>
> > >> <root level="error">
>
> > >> <!--<appenderRef ref="wfePartitionedJobAppender"/>-->
>
> > >> <appenderRef ref="stdout"/>
>
> > >> </root>
>
> > >> </loggers>
>
> > >> </configuration>
>
> > >>
>
> > >>
>
> > >> The filter works but when I put a breakpoint inside the
> ThresholdFilter
>
> > >> class I see it doesn't stop in the method I mentioned earlier:
>
> > >> [image: Inline image 1]
>
> > >>
>
> > >> Am I missing something here?
>
> > >>
>
> > >> Thanks,
>
> > >> Guy Marom
>
> > >>
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > > Matt Sicker <bo...@gmail.com>
>
> >
>
> > ---------------------------------------------------------------------
>
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
>
> >
>
> >
>
>
Re: Context-wide filter not working for me
Posted by Guy Marom <ma...@gmail.com>.
The documentation of the *AbstractFilter* class says differently:
/**
* Context Filter method. The default returns NEUTRAL.
* @param event The LogEvent.
* @return The Result of filtering.
*/
@Override
public Result filter(final LogEvent event) {
return Result.NEUTRAL;
}
All the other methods are marked as "Appender filter" methods, and my needs
are to intercept all messages before they reach any appender.
So maybe that's the question I need to ask - how do I filter all messages
before they reach any appender?
Thanks,
Guy
On Wed, Dec 7, 2016 at 1:37 AM, Remko Popma <re...@gmail.com> wrote:
> The Filter interface has several methods, which can get called at
> different times.
>
> For context-wide filters, the methods _without_ LogEvent will be called.
>
> Sent from my iPhone
>
> > On 7 Dec 2016, at 5:18, Matt Sicker <bo...@gmail.com> wrote:
> >
> > Can you set status="debug" in your <configuration/> element? Also, did
> you
> > remember to add all the necessary annotations on your plugin along with
> > enabling annotation processing if needed?
> >
> >> On 6 December 2016 at 13:59, Guy Marom <ma...@gmail.com> wrote:
> >>
> >> Hello everyone,
> >>
> >> I have a problem with activating a context-wide filter. I created my own
> >> filter, made it inherit from *AbstractFilter* and then overridden the
> >> method
> >>
> >> public Result filter(LogEvent event)
> >>
> >> This method was never called so I decided to try with an existing
> filter,
> >> here's my config file:
> >>
> >> <configuration monitorInterval="5">
> >> <!--<MetricWritingFilter />-->
> >> <ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
> >>
> >> <appenders>
> >> <console name="stdout" target="SYSTEM_OUT">
> >> <patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
> >> </console>
> >> </appenders>
> >>
> >> <loggers>
> >> <logger name="com.outbrain.test" level="info" />
> >> <root level="error">
> >> <!--<appenderRef ref="wfePartitionedJobAppender"/>-->
> >> <appenderRef ref="stdout"/>
> >> </root>
> >> </loggers>
> >> </configuration>
> >>
> >>
> >> The filter works but when I put a breakpoint inside the ThresholdFilter
> >> class I see it doesn't stop in the method I mentioned earlier:
> >> [image: Inline image 1]
> >>
> >> Am I missing something here?
> >>
> >> Thanks,
> >> Guy Marom
> >>
> >
> >
> >
> > --
> > Matt Sicker <bo...@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
Re: Context-wide filter not working for me
Posted by Remko Popma <re...@gmail.com>.
The Filter interface has several methods, which can get called at different times.
For context-wide filters, the methods _without_ LogEvent will be called.
Sent from my iPhone
> On 7 Dec 2016, at 5:18, Matt Sicker <bo...@gmail.com> wrote:
>
> Can you set status="debug" in your <configuration/> element? Also, did you
> remember to add all the necessary annotations on your plugin along with
> enabling annotation processing if needed?
>
>> On 6 December 2016 at 13:59, Guy Marom <ma...@gmail.com> wrote:
>>
>> Hello everyone,
>>
>> I have a problem with activating a context-wide filter. I created my own
>> filter, made it inherit from *AbstractFilter* and then overridden the
>> method
>>
>> public Result filter(LogEvent event)
>>
>> This method was never called so I decided to try with an existing filter,
>> here's my config file:
>>
>> <configuration monitorInterval="5">
>> <!--<MetricWritingFilter />-->
>> <ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
>>
>> <appenders>
>> <console name="stdout" target="SYSTEM_OUT">
>> <patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
>> </console>
>> </appenders>
>>
>> <loggers>
>> <logger name="com.outbrain.test" level="info" />
>> <root level="error">
>> <!--<appenderRef ref="wfePartitionedJobAppender"/>-->
>> <appenderRef ref="stdout"/>
>> </root>
>> </loggers>
>> </configuration>
>>
>>
>> The filter works but when I put a breakpoint inside the ThresholdFilter
>> class I see it doesn't stop in the method I mentioned earlier:
>> [image: Inline image 1]
>>
>> Am I missing something here?
>>
>> Thanks,
>> Guy Marom
>>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Context-wide filter not working for me
Posted by Guy Marom <ma...@gmail.com>.
Attached the debug-level output.
Also - the annotations are not relevant since I'm currently not using my
filter but the ThresholdFilter which I assume is written correctly :)
Thanks,
Guy
On Tue, Dec 6, 2016 at 10:18 PM, Matt Sicker <bo...@gmail.com> wrote:
> Can you set status="debug" in your <configuration/> element? Also, did you
> remember to add all the necessary annotations on your plugin along with
> enabling annotation processing if needed?
>
> On 6 December 2016 at 13:59, Guy Marom <ma...@gmail.com> wrote:
>
> > Hello everyone,
> >
> > I have a problem with activating a context-wide filter. I created my own
> > filter, made it inherit from *AbstractFilter* and then overridden the
> > method
> >
> > public Result filter(LogEvent event)
> >
> > This method was never called so I decided to try with an existing filter,
> > here's my config file:
> >
> > <configuration monitorInterval="5">
> > <!--<MetricWritingFilter />-->
> > <ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
> >
> > <appenders>
> > <console name="stdout" target="SYSTEM_OUT">
> > <patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
> > </console>
> > </appenders>
> >
> > <loggers>
> > <logger name="com.outbrain.test" level="info" />
> > <root level="error">
> > <!--<appenderRef ref="wfePartitionedJobAppender"/>-->
> > <appenderRef ref="stdout"/>
> > </root>
> > </loggers>
> > </configuration>
> >
> >
> > The filter works but when I put a breakpoint inside the ThresholdFilter
> > class I see it doesn't stop in the method I mentioned earlier:
> > [image: Inline image 1]
> >
> > Am I missing something here?
> >
> > Thanks,
> > Guy Marom
> >
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>
Re: Context-wide filter not working for me
Posted by Matt Sicker <bo...@gmail.com>.
Can you set status="debug" in your <configuration/> element? Also, did you
remember to add all the necessary annotations on your plugin along with
enabling annotation processing if needed?
On 6 December 2016 at 13:59, Guy Marom <ma...@gmail.com> wrote:
> Hello everyone,
>
> I have a problem with activating a context-wide filter. I created my own
> filter, made it inherit from *AbstractFilter* and then overridden the
> method
>
> public Result filter(LogEvent event)
>
> This method was never called so I decided to try with an existing filter,
> here's my config file:
>
> <configuration monitorInterval="5">
> <!--<MetricWritingFilter />-->
> <ThresholdFilter level="TRACE" onMatch="DENY" onMismatch="DENY"/>
>
> <appenders>
> <console name="stdout" target="SYSTEM_OUT">
> <patternLayout pattern="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
> </console>
> </appenders>
>
> <loggers>
> <logger name="com.outbrain.test" level="info" />
> <root level="error">
> <!--<appenderRef ref="wfePartitionedJobAppender"/>-->
> <appenderRef ref="stdout"/>
> </root>
> </loggers>
> </configuration>
>
>
> The filter works but when I put a breakpoint inside the ThresholdFilter
> class I see it doesn't stop in the method I mentioned earlier:
> [image: Inline image 1]
>
> Am I missing something here?
>
> Thanks,
> Guy Marom
>
--
Matt Sicker <bo...@gmail.com>