logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniele Menotti <danielemeno...@hotmail.com>
Subject Problems with FileoverAppender
Date Tue, 26 Mar 2013 16:35:51 GMT
Hi all,
I'm writing an application where I want to log to a Syslog server. I'm doing it using a FailoverAppender,
so when the Syslog server is down I can log to a local file. I'm using Log4j 2.0beta4.
 
Here is my log4j2.xml configuration file:
 
<configuration>
    <appenders>
        <RollingFile name="RollingFile" fileName="logs/app.log" filePattern="logs/archive/app_%d{yyyy-MM-dd}.log"
immediateFlush="true" suppressExceptions="false">
            <PatternLayout>
                <pattern>%d %-5p - %m%n</pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
        <Syslog name="Syslog_local0" host="16.63.165.60" port="514" protocol="TCP" appName="LogTester"
immediateFlush="true" facility="LOCAL0" newLine="true" reconnectionDelay="1" suppressExceptions="false"/>

        <Failover name="Failover" primary="Syslog_local0" retryInterval="3" suppressExceptions="false">
            <Failovers>
                <appender-ref ref="RollingFile"/>
            </Failovers>
        </Failover>
    </appenders>
    <loggers>
        <root level="debug">
            <appender-ref ref="Failover"/>
        </root>
    </loggers>
</configuration>
 
Now, I tried some scenarios:

Syslog server is up when my application starts and it remains up till the end: I can log to
Syslog without problems ;-)
Syslog server is down when my application starts and it remains always down: I don't log to
Syslog, but I log to my local file, as expected ;-)
Syslog server is up when my application starts, than it goes down - for example I log message1
to Syslog, than I put the server down and I log message2 and message3: in this case I can
log message1 to Syslog and when my application tries to log message2 I get an Exception: ERROR
StatusLogger Unable to write to stream TCP:16.63.165.60:514 for appender Syslog_local0
ERROR StatusLogger An exception occurred processing Appender Syslog_local0 org.apache.logging.log4j.core.appender.AppenderRuntimeException:
Error writing to TCP:16.63.165.60:514
 at org.apache.logging.log4j.core.net.TCPSocketManager.write(TCPSocketManager.java:120)
 at org.apache.logging.log4j.core.appender.OutputStreamManager.write(OutputStreamManager.java:127)
 at org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:115)
 at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:102)
 at org.apache.logging.log4j.core.appender.FailoverAppender.callAppender(FailoverAppender.java:122)
 at org.apache.logging.log4j.core.appender.FailoverAppender.append(FailoverAppender.java:109)
 at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:102)
 at org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:335)
 at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:316)
 at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:281)
 at org.apache.logging.log4j.core.Logger.log(Logger.java:108)
 at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:657)
 at com.hp.prp.util.log.SyslogLogger.info(SyslogLogger.java:82)
 at com.hp.prp.util.log.Prova.main(Prova.java:25)
Caused by: java.net.SocketException: Software caused connection abort: socket write error
 at java.net.SocketOutputStream.socketWrite0(Native Method)
 at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
 at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
 at org.apache.logging.log4j.core.net.TCPSocketManager.write(TCPSocketManager.java:111)
 ... 13 more
 
message2 is lost and message3 is logged to the local file.... So why message2 becomes lost??
How can I do to log it to the local file as I expect?
 
4. Syslog server is down when my application starts, than it goes up - for example I log message1
to the local file, than I put the server up and I log message2 and message3 to Syslog: in
this case logging works fine because fileoverAppender tries the primary appender every 3 seconds.
 
How can I do to resolve my problems in scenario 3?
 
Thanks in advance,
Daniele
 
 
  		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message