Definitely don't recommend implementing the interfaces directly as they're
not guaranteed to be backwards compatible, but the abstract classes
generally are.

On 27 February 2017 at 14:43, Remko Popma <remko.po...@gmail.com> wrote:

> One option is to create a custom Log4j2 Filter. Your custom Filter would
> only be "active" if it detects it's in the correct environment, otherwise
> it would return NEUTRAL from all `filter(...)` methods.
>
> CompositeFilter is final so you can't subclass it but perhaps you can
> create a wrapper instead.
>
> Here is a link to the manual page that explains how to implement Log4j2
> plugins: http://logging.apache.org/log4j/2.x/manual/plugins.html
> This section is specifically about implementing custom filters:
> http://logging.apache.org/log4j/2.x/manual/extending.html#Filters
>
> You probably want to subclass AbstractFilter rather than implementing the
> Filter interface from scratch:
> https://github.com/apache/logging-log4j2/blob/master/
> log4j-core/src/main/java/org/apache/logging/log4j/core/
> filter/AbstractFilter.java
>
>
> Sent from my iPhone
>
> > On Feb 27, 2017, at 21:00, Mahler, Stefan <stefan.mah...@icongmbh.de>
> wrote:
> >
> > Hello,
> >
> > we want replace our legacy proprietary logging framework.
> >
> > One important feature of our current logging framework is the so called
> 'profile controlled filtering'.
> > There exist different filtering profiles like 'production', 'test' or
> 'development'. The profile to use
> > is selected by a system property named 'STAGE'.
> > Each filtering profile has its filter combination:
> > * production: Log level is ERROR or higher, except, if marker is
> HEARTBEAT, then the log level should be INFO or higher.
> > * test: Log level is WARNING or higher, except if marker is one of
> [HEARTBEAT, DB], then the log level is DEBUG or higher.
> > * development: Log level is INFO, except if marker is one of [HEARTBEAT,
> DB, ENTRY].
> > Additionally there is a default filter combination. Default filter
> combination is used if STAGE is unknown or no STAGE is defined.
> >
> > A single filter combination can be defined with CompositeFilter. E.g.
> for the production profile the follow CompositeFilter can be used:
> >      <Filters>
> >        <ThresholdFilter level="INFO" onMatch="NEUTRAL" onMismatch="DENY"
> />
> >        <ThresholdFilter level="ERROR" onMatch="ACCEPT"
> onMismatch="NEUTRAL" />
> >        <MarkerFilter marker="HEARTBEAT" onMatch="ACCEPT"
> onMismatch="DENY" />
> >      </Filters>
> >
> >
> > But how can I select the profile (this means here the CompositeFilter)
> by System-Lookup?
> > Is there any recommended way for profile controlling?
> >
> > For all profiles the same appenders are used. The only difference is the
> filter combination.
> >
> > Thanks a lot!
> > Stefan Mahler
> >
> >
> >
> > --
> > Stefan Mahler                           http://www.icongmbh.de
> > Application Development
> > icon Systemhaus GmbH            Tel. +49 711 806098-167
> > Hauptstätter Straße 70
> > 70178 Stuttgart                         Fax. +49 711 806098-299
> >
> >
> > Geschäftsführer: Uwe Seltmann, Andreas Schwegler
> > HRB Stuttgart 17655
> > USt-IdNr.: DE 811944121
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
> > For additional commands, e-mail: log4j-user-h...@logging.apache.org
> >
>



-- 
Matt Sicker <boa...@gmail.com>

Reply via email to