1. Define a Marker

public static final Marker EXCEPTION_MESSAGE = 
MarkerManager.getMarker(“EXCEPTION_MESSAGE”);

2. Use the Marker

logger.info(EXCEPTION_MESSAGE, execution);

3. Use the MarkerPatternSelector

<Console name="Console" target="SYSTEM_OUT">
    <PatternLayout>
        <MarkerPatternSelector defaultPattern="[%-5level] %msg%n">
            <PatternMatch key=“EXCEPTION_MESSAGE" pattern="[%-5level] - %msg 
%throwable{short.message}%n"/>
        </MarkerPatternSelector>
    </PatternLayout>
</Console>

Ralph


> On Aug 12, 2018, at 8:47 AM, Gary Gregory <garydgreg...@gmail.com> wrote:
> 
> Hi All:
> 
> In our server, there are certain kinds of exceptions that are caught that I
> want processed in a special manner. One example of this is for various
> kinds of time outs that surface as exceptions. Sometimes comms time out,
> requests may be resubmitted, and in general all is well.
> 
> For day-to-day logging, I only want to show the _message_ of exception as
> an informative log event (INFO). I do not want to log the stack trace in
> this mode, as this alarms users to no end.
> 
> When I am in trouble shooting mode, I do want to see the exception's stack
> trace logged, say, at the DEBUG (or TRACE) level.
> 
> Currently, I have some selective call sites with ugly logic to handle this
> kind of logging. The simplest way to handle this is with some double
> logging:
> 
> logger.info("foo: {}}, exception.toString());
> logger.debug(exception);
> 
> This is obviously ugly and a pain to maintain.
> 
> Can you all think of how this could be addressed, either at the API site or
> at the _pattern_ definition site? Maybe with a new option in the pattern?
> 
> Gary


Reply via email to