[ https://issues.apache.org/jira/browse/LOG4J2-1628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15776495#comment-15776495 ]
Remko Popma commented on LOG4J2-1628: ------------------------------------- [~markbowman] It turns out this is a regression caused by LOG4J2-1343: If [direct encoding|https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/util/Constants.html#ENABLE_DIRECT_ENCODERS] is enabled (true by default), then FileAppender [does not call|https://github.com/apache/logging-log4j2/blob/56aac98b0569531e6af4e7917c053c172ce30c6a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractOutputStreamAppender.java#L167] the {{FileAppender.write}} method where the file is locked. In Log4j 2.6 and later, you can work around this issue by setting system property {{log4j2.enable.direct.encoders}} to "false". The fix is likely to override {{OutputStreamManager.writeToDestination}} in FileManager, and lock the FileChannel in that method, similar to how [FileAppender.write|https://github.com/apache/logging-log4j2/blob/dd943975b7c809c3d302237cecf7116c9c9e9ea2/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/FileManager.java#L120] overrides {{OutputStreamManager.write}}. > Scrambled log messages > ---------------------- > > Key: LOG4J2-1628 > URL: https://issues.apache.org/jira/browse/LOG4J2-1628 > Project: Log4j 2 > Issue Type: Bug > Components: Appenders > Affects Versions: 2.6.2 > Environment: centos > Reporter: Mark Bowman > Assignee: Remko Popma > > We have several threads writing to an async file with locking set to true. > Under log4j 2.5 the message from each thread are interleaved correctly. Using > log4j 2.6.2 some messages are scrambled as if multiple threads are writing to > the file simultaneously. Reverting to 2.5 fixes the problem. > Configuration to follow. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org