David, As our unit tests show, markers work, unless you've found a bug!
Can you create a unit test with configuration file that demonstrate your issue? Which version of Log4j are you using? Note that we have a lot of unit tests for you to use as inspiration and debugging help. Gary On Mon, Jun 22, 2015 at 5:22 AM, David KOCH <[email protected]> wrote: > Hello, > > 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" > additivity="false"> > <MarkerFilter marker="bid_req_proto" onMatch="DENY" onMismatch="DENY"/> > <AppenderRef ref="Console"/> > <AppenderRef ref="KafkaBidRequest" level="info"/> > <AppenderRef ref="KafkaBidResponse" level="off"/> > </Logger> > > but logger.isInfoEnabled(MarkerManager.getMarker("bid_req_proto")) > evaluates to to "true" whatever way I set up the MarkerFilter. > > Regards, > > /David > -- 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
