You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Tomislav Petrović (Jira)" <ji...@apache.org> on 2022/02/08 09:49:00 UTC

[jira] [Commented] (LOG4J2-3335) Logging ends up on stdout intead in the RollingFileAppender when using Log4J 1.2 bridge

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

Tomislav Petrović commented on LOG4J2-3335:
-------------------------------------------

I have find the culprit in this story..... 

The config file used (which has been working for decades on Log4J 1) has a single space after the filename!!!!

{{log4j.appender.CPJAVACALL.File=${catalina.base}/webapps/cpjavacall/log/JavaCallServlet.log }}

{{                                                                                          ^space above here}}

When you remove space everything works as expected. Seems like new config parser is a lot more restrictive than the old one :(.

Anyhow, you can close this as far as I'm concerned, or improve parser to ignore this hard to track space, whichever you prefer.

> Logging ends up on stdout intead in the RollingFileAppender when using Log4J 1.2 bridge
> ---------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3335
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3335
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Log4j 1.2 bridge
>    Affects Versions: 2.17.1
>         Environment: 32bit Tomcat 10 under Windows and Temurin JDK 17, log4j-1.2-api-2.17.1.jar, log4j-api-2.17.1.jar, log4j-core-2.17.1.jar
>            Reporter: Tomislav Petrović
>            Priority: Major
>
> I have a webapp running under Tomcat using log4j1 for logging with following configuration in log4j.properties:
> {{log4j.appender.CPJAVACALL=org.apache.log4j.RollingFileAppender}}
> {{log4j.appender.CPJAVACALL.File=${catalina.base}/webapps/cpjavacall/log/JavaCallServlet.log }}
> {{log4j.appender.CPJAVACALL.MaxBackupIndex=10}}
> {{log4j.appender.CPJAVACALL.MaxFileSize=128MB}}
> {{log4j.appender.CPJAVACALL.layout=org.apache.log4j.PatternLayout}}
> {{log4j.appender.CPJAVACALL.layout.ConversionPattern=%d\{ISO8601} C=%5X\{channel} [%25t] %X\{sessionId} %m%n}}
> {{log4j.logger.com.example.cp.javacall.JavaCallServlet = ALL, CPJAVACALL}}
> With log4j1 everything works OK and log lines end up in JavaCallServlet.log file.
> When moved to log4j2 using Log4J 1.2 bridge the JavaCallServlet.log file is created but log lines are not written to it.
> Instead they are written into tomcat10-stdout.*.log file in following format:
> {{16:22:41.382 [http-nio-8080-exec-3] INFO  com.example.cp.javacall.JavaCallServlet - Request ended}}
> {{{}16:22:41.396 [http-nio-8080-exec-4] INFO  com.{}}}{{{}example.{}}}{{{}cp.javacall.JavaCallServlet - Request started{}}}
>  
> Obviously log lines are not written to my CPJAVACALL appender but to Console appender only.
> Why? Is this a bug or missing functionality in Log4j 1.2 bridge or some error in my configuration file?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)