I am trying to send an email in case error occurs in our project. For this we are using Log4j's SMTPAppender
. I am running my project in the development mode and trying to get the full stack trace of the error by using following ConversionPattern
in SMTPAppender
:
<param name="ConversionPattern"
value="[%d{ISO8601}] [%t] [%5p] [%c ] %n %m %l %X{config}"/>
I am throwing error as follows:
try {
throw new Exception(" To get the MDC values !!!");
} catch (Exception e)
{
LOGGER.error(" To get the MDC values !!!", e);
}
%m
is replaced by the text To get the MDC values !!!
but %l
(lower-case L
) is printing the fully qualified class name of the caller issuing the logging request with line number (just like %c do, with one difference that %c never prints the line number while %l does).
What could be the correct way to get the stack trace and why %l
is not getting the whole stack trace ?
%l is used to output location information of the caller which generated the logging event. it si snot print whole stacktrace. you can add these lines of code in your catch block.