You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2017/11/29 03:34:05 UTC

[jira] [Comment Edited] (LOG4J2-2135) Logs are not flushed when using AsyncRoot

    [ https://issues.apache.org/jira/browse/LOG4J2-2135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16270047#comment-16270047 ] 

Remko Popma edited comment on LOG4J2-2135 at 11/29/17 3:33 AM:
---------------------------------------------------------------

I tried with 2.9.1 and 2.10.0 (the latest) but I am unable to reproduce the issue. 
I tried both the console and the rolling file appender, but I consistently see the correct expected output:

{noformat}
1129.121151.379#main F       Log4JTest|  Fatal i=0; j=0;
1129.121151.381#main E       Log4JTest|  Error i=0; j=0;
1129.121151.381#main W       Log4JTest|  Warn   i=0; j=0;
1129.121151.381#main I       Log4JTest|  Info   i=0; j=0;
1129.121151.381#main D       Log4JTest|  Debug i=0; j=0;
1129.121151.381#main F       Log4JTest|  Fatal i=0; j=1;
1129.121151.381#main E       Log4JTest|  Error i=0; j=1;
...
1129.121151.393#main I       Log4JTest|  Info   i=9; j=8;
1129.121151.394#main D       Log4JTest|  Debug i=9; j=8;
1129.121151.394#main F       Log4JTest|  Fatal i=9; j=9;
1129.121151.394#main E       Log4JTest|  Error i=9; j=9;
1129.121151.394#main W       Log4JTest|  Warn   i=9; j=9;
1129.121151.394#main I       Log4JTest|  Info   i=9; j=9;
1129.121151.394#main D       Log4JTest|  Debug i=9; j=9;
1129.121151.394#main I       Log4JTest|  DONE.
{noformat}

I tested with
JVM:          1.8.0_60 (Oracle Corporation 25.60-b23)
OS:           Windows 7 6.1 amd64
disruptor: 3.3.6
Log4j: 2.9.1 and 2.10.0 (only log4j-api and log4j-core in classpath)


was (Author: remkop@yahoo.com):
I tried with 2.9.1 and 2.10.0 (the latest) but I am unable to reproduce the issue. 
I tried both the console and the rolling file appender, but I consistently see the correct expected output:

{noformat}
1129.121151.379#main F       Log4JTest|  Fatal i=0; j=0;
1129.121151.381#main E       Log4JTest|  Error i=0; j=0;
1129.121151.381#main W       Log4JTest|  Warn   i=0; j=0;
1129.121151.381#main I       Log4JTest|  Info   i=0; j=0;
1129.121151.381#main D       Log4JTest|  Debug i=0; j=0;
1129.121151.381#main F       Log4JTest|  Fatal i=0; j=1;
1129.121151.381#main E       Log4JTest|  Error i=0; j=1;
...
1129.121151.393#main I       Log4JTest|  Info   i=9; j=8;
1129.121151.394#main D       Log4JTest|  Debug i=9; j=8;
1129.121151.394#main F       Log4JTest|  Fatal i=9; j=9;
1129.121151.394#main E       Log4JTest|  Error i=9; j=9;
1129.121151.394#main W       Log4JTest|  Warn   i=9; j=9;
1129.121151.394#main I       Log4JTest|  Info   i=9; j=9;
1129.121151.394#main D       Log4JTest|  Debug i=9; j=9;
1129.121151.394#main I       Log4JTest|  DONE.
{noformat}

> Logs are not flushed when using AsyncRoot
> -----------------------------------------
>
>                 Key: LOG4J2-2135
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2135
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.9.1
>         Environment: * java 1.8.151
> * log4j-api-2.9.1.jar
> * log4j-core-2.9.1.jar
> * log4j-web-2.9.1.jar
> * disruptor-3.3.6.jar
>            Reporter: Laurent Hasson
>
> With the following code
> {code:java}
> public class Log4JTest
>   {
>     protected static final Logger Log = LogManager.getLogger(Log4JTest.class.getName());
>     protected static final int MAX = 10;
>     public static void main(String[] args)
>       {
>         for (int i = 0; i < MAX; ++i)
>           {
>             for (int j = 0; j < MAX; ++j)
>               {
>                 Log.fatal("Fatal i=" + i + "; j=" + j + ";");
>                 Log.error("Error i=" + i + "; j=" + j + ";");
>                 Log.warn("Warn   i=" + i + "; j=" + j + ";");
>                 Log.info("Info   i=" + i + "; j=" + j + ";");
>                 Log.debug("Debug i=" + i + "; j=" + j + ";");
>                 Log.trace("Trace i=" + i + "; j=" + j + ";");
>               }
>           }
>         Log.info("DONE.");
>       }
> {code}
> and log4j2.xml configuration
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="info">
>      <Appenders>
>           <Console name="Console" target="SYSTEM_OUT" >
>                <PatternLayout>
>                     <pattern>%d{MMdd.HHmmss.SSS}#%-3t %level{length=1} %15.15c{1}|  %m%ex{20}%n</pattern>
>                </PatternLayout>
>           </Console>
>      </Appenders>
>      <Loggers>
>           <AsyncRoot level="debug">
>                <AppenderRef ref="Console" />
>           </AsyncRoot>
>      </Loggers>
> </Configuration>
> {code}
> by the time the program ends, a number of logs are missing in the output. They may be either lost or not flushed? I'd expect the program to end and all log messages to be output properly, ending with the "DONE" message. If i change the config file to a rolling appender, i can observe the same behavior, i.e., missing messages.
> {code:xml}
> <RollingFile name="FILES" fileName="${log-path}/aaa.log" filePattern="${log-path}/aaa.%i.log.gz">
>     <PatternLayout>
>         <pattern>%d{MMdd.HHmmss.SSS}#%-3t %level{length=1} %15.15c{1}|  %m%ex{20}%n</pattern>
>     </PatternLayout>
>     <Policies>
> 	<SizeBasedTriggeringPolicy size="100 MB" />
>     </Policies>
>     <DefaultRolloverStrategy max="99999" compressionLevel="6"/>
> </RollingFile>
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)