Maybe there is a smarter way to do this in Log4J, but the low-tech approach
I have deployed in the past was to simply have 2 different xml configuration
files (we only had Prod Vs. Dev) and deploy the one that matched the
setting.

But these days, we unify everything and it's basically just a logging level
and structure our logging appropriately and use a lot of "if debuglevel=true
..." logic. That makes things simpler imho.

Laurent Hasson
Co-Founder and CTO
CapsicoHealth Inc.

-----Original Message-----
From: Mahler, Stefan [mailto:stefan.mah...@icongmbh.de] 
Sent: Monday, February 27, 2017 15:00
To: log4j-user@logging.apache.org
Subject: Profile controlled filtering

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



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

Reply via email to