logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David KOCH <dk...@ezakus.com>
Subject Checking if logger is enabled for a specific marker
Date Mon, 22 Jun 2015 12:22:56 GMT

Is there any way to programatically determine if a logger is enabled for a
specific log level and marker? If so how? There is a Logger#isEnabled(Level
level, Marker marker) method but it seems it ignores the marker argument.

I would like to avoid carrying out relatively expensive operations required
for preparing the log message when it's not required. The alternative,
implementing Message#getFormattedMessage would be quite clumsy in this case
so I'd like to be able to pre-check based on marker and log level instead.

I did like this in the log4j.xml:

<Logger name="com.xxxxx.rtb.log.LoggingBidInterceptor" level="info"
    <MarkerFilter marker="bid_req_proto" onMatch="DENY" onMismatch="DENY"/>
  <AppenderRef ref="Console"/>
  <AppenderRef ref="KafkaBidRequest" level="info"/>
  <AppenderRef ref="KafkaBidResponse" level="off"/>

but logger.isInfoEnabled(MarkerManager.getMarker("bid_req_proto"))
evaluates to to "true" whatever way I set up the MarkerFilter.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message