[logback-user] How to output short exception when Marker is present, but full otherwise?

te at spudsoft.co.uk te at spudsoft.co.uk
Wed Oct 23 09:13:44 CEST 2019


I want this:

     logger.debug("Test logging: ", new IllegalStateException("Wibble"));

to give me a full stack trace, and this:

     logger.debug(MarkerFactory.getMarker("MINIMAL_EXCEPTION"), "Test 
logging: ", new IllegalStateException("Wibble"));

to just output the class and message.

I don't have Janino, and I'm trying to keep it all as small as possible 
(also not sure I could pay the price of expression evaluation for each 

The closest I've got is this:

   <evaluator name="DISPLAY_EX_EVAL" 

   <appender name="STDOUTPUT" class="ch.qos.logback.core.ConsoleAppender">
       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} %line - 
%msg%ex{full, DISPLAY_EX_EVAL}%n</pattern>
class="ch.qos.logback.classic.jul.LevelChangePropagator" />

But that doesn't output exception at all when the Marker is present.

Is there any way to get what I want without a more complex expression?



More information about the logback-user mailing list