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

Guillaume Turri commented on LOG4J2-1052:
-----------------------------------------

I'm afraid I still experience the issue.

I did the same manipulations as before, with 'socketTimeoutMillis="1000" ' 
added in my config, and with your patch; and when I shutdown my wifi, the 
application still hangs after a while.

According to the setSoTimeout documentation 
(http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#setSoTimeout%28int%29),
 it's suppose to add a timeout on the read, whereas here we have issues with a 
write, so I guess it explains why I still experience this issue. On the other 
hand, I'm afraid I don't see any other option that could help us here.

> Syslog appender hangs if it looses connection for too long
> ----------------------------------------------------------
>
>                 Key: LOG4J2-1052
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1052
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.3
>         Environment:     > lsb_release -a
>     No LSB modules are available.
>     Distributor ID: Ubuntu
>     Description: Ubuntu 14.04.2 LTS
>     Release: 14.04
>     Codename: trusty
>     > java -version
>     java version "1.7.0_79"
>     OpenJDK Runtime Environment (IcedTea 2.5.5) (7u79-2.5.5-0ubuntu0.14.04.2)
>     OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
>            Reporter: Guillaume Turri
>            Priority: Minor
>         Attachments: log4j2-1052.diff
>
>
> * Steps to reproduce:
> ** Launch the following program
> ** Ensure the syslog receives the messages
> ** Stop the wifi of the laptop running the program, and unplug its ethernet 
> cable (do it on the laptop running the program; *not* on the box running the 
> syslog)
> The code is
> {code}
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger
> public class App
> {
>       private static final Logger _logger = 
> LogManager.getLogger("TestLogger");
>       public static void main( String[] args ) throws Exception
>       {
>               int id = 0;
>               while ( true ){
>                       String msg = "message: " + id;
>                       _logger.error(msg);
>                       id++;
>                        Thread.sleep(10);
>               }
>       }
> }
> {code}
> The config is:
> {code}
> <?xml version="1.0" encoding="UTF-8"?>                                        
>                                                                               
>                                                                               
>                                                                          
> <Configuration status="WARN">
>   <Appenders>
>     <Console name="Console" target="SYSTEM_OUT">
>       <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - 
> %msg%n"/>
>     </Console>
>     <Syslog name="my-syslog" host="my-host" port="12201" protocol="TCP" 
> format="RFC5424" mdcId="mdc" includeMDC="true" appName="testGTApp" 
> newLine="true" connectTimeoutMillis="100" immediateFail="true" 
> reconnectionDelayMillis="3000" immediateFlush="true" />
>   </Appenders>
>   <Loggers>
>     <Root level="info">
>       <AppenderRef ref="Console" />
>       <AppenderRef ref="my-syslog"/>
>     </Root>
>   </Loggers>
> </Configuration>
> {code}
> * Expected behavior: even though the messages doesn't reach the syslog 
> anymore, the program continues to run forever
> * Actual behavior: after about 350 messages, the program hangs. A thread 
> dumps shows
> {code}
> "main" prio=10 tid=0x00007fa21800a000 nid=0x2303 runnable [0x00007fa2209b6000]
>    java.lang.Thread.State: RUNNABLE
>       at java.net.SocketOutputStream.socketWrite0(Native Method)
>       at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
>       at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
>       at 
> org.apache.logging.log4j.core.net.TcpSocketManager.write(TcpSocketManager.java:129)
>       - locked <0x00000007d96ce668> (a 
> org.apache.logging.log4j.core.net.TcpSocketManager)
>       at 
> org.apache.logging.log4j.core.appender.OutputStreamManager.write(OutputStreamManager.java:135)
>       at 
> org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender.append(AbstractOutputStreamAppender.java:110)
>       at 
> org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:99)
>       at 
> org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:430)
>       at 
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:409)
>       at 
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:367)
>       at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:112)
>       at 
> org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:727)
>       at 
> org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:716)
>       at 
> org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:344)
>       at fr.test.App.main(App.java:17)
> {code} 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to