logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remko Popma (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-784) AsyncLoggers and PatternLayout with class/method/line
Date Mon, 18 Aug 2014 23:17:21 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-784?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Remko Popma updated LOG4J2-784:
-------------------------------

    Description: 
Using slf4j binding.

VM options:
{{-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector}}

Appender:
{code}
<Console name="Console" target="SYSTEM_OUT">
	<PatternLayout pattern="%highlight{%p | %d{DEFAULT} | %t | %C{1}.%M(%L) | %m%n}{STYLE=Logback}"/>
</Console>
{code}
Log message:
DEBUG | 2014-08-18 19:05:13,795 | main | ?.() | HashSet: [A, B]

Log message without the VM option "Log4jContextSelector":
DEBUG | 2014-08-18 19:09:43,608 | main | Main.main(32) | HashSet: [A, B]

  was:
Using slf4j binding.

VM options:
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector

Appender:
<Console name="Console" target="SYSTEM_OUT">
	<PatternLayout pattern="%highlight{%p | %d{DEFAULT} | %t | %C{1}.%M(%L) | %m%n}{STYLE=Logback}"/>
</Console>

Log message:
DEBUG | 2014-08-18 19:05:13,795 | main | ?.() | HashSet: [A, B]

Log message without the VM option "Log4jContextSelector":
DEBUG | 2014-08-18 19:09:43,608 | main | Main.main(32) | HashSet: [A, B]


You need to specify {{includeLocation="true"}} to force the logger to take a snapshot of the
stacktrace for every log message before passing it on to the background thread. (See [async
loggers manual|http://logging.apache.org/log4j/2.x/manual/async.html#Location].)

For example:
{code}
<Loggers>
    <Logger name="com.foo.Bar" level="trace" includeLocation="true">
      <AppenderRef ref="Console"/>
    </Logger>
    <Root level="info" includeLocation="true">
      <AppenderRef ref="Console"/>
    </Root>
</Loggers>
{code}

> AsyncLoggers and PatternLayout with class/method/line
> -----------------------------------------------------
>
>                 Key: LOG4J2-784
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-784
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Layouts
>    Affects Versions: 2.0.1
>         Environment: OSX/Win7 64b, Java7/8, Eclipse/IDEA
>            Reporter: Martin Vehovsk√Ĺ
>
> Using slf4j binding.
> VM options:
> {{-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector}}
> Appender:
> {code}
> <Console name="Console" target="SYSTEM_OUT">
> 	<PatternLayout pattern="%highlight{%p | %d{DEFAULT} | %t | %C{1}.%M(%L) | %m%n}{STYLE=Logback}"/>
> </Console>
> {code}
> Log message:
> DEBUG | 2014-08-18 19:05:13,795 | main | ?.() | HashSet: [A, B]
> Log message without the VM option "Log4jContextSelector":
> DEBUG | 2014-08-18 19:09:43,608 | main | Main.main(32) | HashSet: [A, B]



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message