logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-904) RollingFile appender doesn't zip and create new files
Date Tue, 05 Jul 2016 05:34:11 GMT

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

Ralph Goers commented on LOG4J2-904:

I don't understand why you keep asking about use cases involving multiple processes.  The
RollingFileAppender does not support that. I specifically did not add the option for file
locking to the Appender, which is the only safe way for multiple processes to write to a file,
because it is full of problems. Note that the documentation for the RollingFileAppender clearly
says file locking is not supported.

What you are forgetting is that without file locking writes from process A and process B can
overlap and you will end up with garbage in the file. In addition, users are going to wonder
why they have multiple copies of the files when they thought they should only have one.

So unless you really want to redesign the RollingFileAppender to use a lock file or some other
such mechanism to allow multiple processes to roll over the file safely, I am perfectly fine
with the solution Bernhard provided.  

I should add that I will be implementing another enhancement to have the RollingFileAppender
only write to the "rolled over" file (the one specified via filePattern), so file renames
won't be required. This mechanism is far more likely to be able to support multiple processes
writing to the file but it will still require some trickery to make it work correctly.

> RollingFile appender doesn't zip and create new files
> -----------------------------------------------------
>                 Key: LOG4J2-904
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-904
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.1
>         Environment: Windows 7
>            Reporter: Stephen A. Weinfield
>             Fix For: 2.6.2
> Using TimeBasedTriggeringPolicy, with a filePattern of {{f:/Log4J/$$\{date:yyyy-MM}/IIB-%d\{MM-dd-yyyy}-%i.log.zip}}
and a fileName of f:/Log4J/IIB.log:
> on date change, directory is created but filename is not zipped. Also old file is not
cleared out, but just appended to.
> Log4j2.xml:
> {code}
> <Configuration status = "warn" name = "Log4j2_Configuration" monitorInterval = "60"
packages = "">
>     <Appenders>
>         <RollingFile name = "RollingFile" fileName = "f:/Log4J/IIB.log" filePattern
= "f:/Log4J/$${date:yyyy-MM}/IIB-%d{MM-dd-yyyy}-%i.log.zip" >
>             <PatternLayout>
>                 <Pattern>%d %p %c{1} %m%n%n</Pattern>
>             </PatternLayout>
>             <Policies>
>                 <TimeBasedTriggeringPolicy interval = "1" modulate = "true"/>
>             </Policies>
>             <DefaultRolloverStrategy fileIndex = "min" max = "7" compressionLevel
= "5"/>
>         </RollingFile>
>     </Appenders>
>     <Loggers>
>         <Root level = "trace">
>             <AppenderRef ref = "RollingFile" level = "warn"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}

This message was sent by Atlassian JIRA

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

View raw message