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-174) Multiple instances of same application server cause 2 problems - want to know if they are solved in log4j 2
Date Thu, 07 Mar 2013 17:34:13 GMT

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

Ralph Goers commented on LOG4J2-174:
------------------------------------

Log4j 2 supports multiple applications writing to the same file with the FileAppender. At
this time it does not support it for the RollingFileAppender, primarily because it isn't clear
how to do the rollover safely. 

Normally the file is "rolled" by renaming it and then compressing it, if requested. On some
systems the rename will fail if the file is opened by another application. On others the rename
will succeed but the other applications will still have a handle to the renamed file and not
be aware they should write to a new file.  If the rename fails the RollingFileAppender will
instead try to copy the file to the renamed file and then delete the original file. Again,
on some systems the delete will fail if the file is in use while on others it will succeed
but the other apps will still have a handle to the deleted file and, in effect, will be writing
to /dev/null.  

Because the file is being renamed or copied just using a file lock on the file doesn't really
work. Instead, a second file object would be needed to block other applications while the
rollover is in progress, but even then I have doubts that the rename/copy-delete would work
in all cases.

My recommendation for this is to use something like Flume to aggregate your logging content
and then have Flume write to the file.
                
> Multiple instances of same application server cause 2 problems - want to know if they
are solved in log4j 2
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-174
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-174
>             Project: Log4j 2
>          Issue Type: Question
>          Components: Appenders
>         Environment: Unix based OS and Java based application servers
>            Reporter: Jas Gill
>
> When we start multiple instances of application server using log4j 1.2 and all instances
read same configuration file, two problems are noticed. 
> 1. At rollover time first app server doing rollover will do its job properly but when
subsequent ones will do rollover again and we lose logs. May be log4j should check that if
rolled over file is already present, it should skip rollover.
> 2. After rollover only one instance is logging and others stop logging. The problem is
that the active file was rolled over and new file is created. Only one server has pointer
to it.
> 	<appender name="ROLLING" class="org.apache.log4j.rolling.RollingFileAppender">
> 		<param name="Threshold" value="ALL"/>
> 		<param name="Append" value="true" />	
> 		<rollingPolicy name="CONSOLE" class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
> 			<param name="FileNamePattern" value="${LOG_FILE}.%d{yyyy-MM-dd-HH-mm}" />
> 			<param name="ActiveFileName" value="${LOG_FILE}" />					
> 		</rollingPolicy>
> 		<layout class="org.apache.log4j.PatternLayout">
> 			<param name="ConversionPattern" value="%d{ISO8601} %-5p [%t]%x %c{2} - %m%n"/>
> 		</layout>
> 	</appender>

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
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