logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Problems with FileoverAppender
Date Wed, 27 Mar 2013 15:57:34 GMT
Unfortunately, the appender has no idea how much data is being buffered as the buffer is managed
by the Socket.

Ralph

On Mar 27, 2013, at 4:11 AM, Daniele Menotti wrote:

> 
> Thanks for your reply Ralph.
> 
> In order to preserve the  performance could be better to guarantee that when the  buffer
gets full and the I/O takes place, the entire content of the buffer is written on the alternative
appender, instead of only the last message. This will guarantee that all logs are tracked
in some way and the performace is not affected.
> 
> Is it feasible?
> 
> 
> 
>> Subject: Re: Problems with FileoverAppender
>> From: ralph.goers@dslextreme.com
>> Date: Tue, 26 Mar 2013 10:32:24 -0700
>> To: log4j-user@logging.apache.org
>> 
>> I've been doing some work on the SocketAppender, which is the base for the SyslogAppender.
The SocketAppender is not flushing the OutputStream on every send. From what I can tell this
is causing the data to be buffered and the exception only gets thrown when the buffer gets
full and actual I/O takes place. To fix this I will need to add an "immediate flush" option
to force the I/O, but that is also probably going to negatively impact performance.
>> 
>> Ralph
>> 
>> 
>> On Mar 26, 2013, at 9:35 AM, Daniele Menotti wrote:
>> 
>>> 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
>>> 
>>> 
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-user-help@logging.apache.org
>> 
> 		 	   		  


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


Mime
View raw message