The %m%n pattern is just the formatted message and a new line. The %M
pattern is for method names. And the current algorithm for finding it is
about the same: <
https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jLogEvent.java#L632>,
though we're looking at the JDK9 APIs for this that make it a bit faster in
9+ as well.

On 29 March 2017 at 05:42, Pietro Galassi <pietro.gala...@gmail.com> wrote:

> Hi,
>
> sorry for boothering you all.  I'm in the need to have a logging
> optimization and i whould like to ask you all about the use of %m%n.
>
> Due to the fact i need optimization should i use :
>
> %m%n
>
> or should implement my own Class/Method name finder with:
>
>
> private static String getLoggingMethod() {
> StackTraceElement stackTraceElements[] = Thread.currentThread().
> getStackTrace();
> StackTraceElement caller = stackTraceElements[3];
> return caller.getMethodName();
> }
>
> and
>
>
> private String getLoggingMethodClassNameIfDebug(int deep) {
> if (logger.isDebugEnabled()) {
> StackTraceElement stackTraceElements[] = Thread.currentThread().
> getStackTrace();
> StackTraceElement caller = stackTraceElements[deep];
> return buildMehodNameClassNameByStackTrace(caller);
> } else {
> return EMPTY;
> }
> }
>
>
> ?
>
> Thanks a lot in advice.
>
> Best regards,
> Pietro
>



-- 
Matt Sicker <boa...@gmail.com>

Reply via email to