I want to use log4j2 to send my log messages to an syslog server(syslog-ng in my case). I have two issues right now
If I stop the syslog service, and start my application it says
2015-04-22 09:56:14,582 ERROR TcpSocketManager (TCP:192.168.0.81:1000) java.net.ConnectException:
And from then on, my application hangs, until a Exception is thrown and my application crashes.
2015-04-22 09:59:21,064 ERROR Unable to write to stream TCP:192.168.0.81:1000 for appender RFC5424
What I want is that log4j tries to send the logmessage, and If the server is not available it should buffer it, until the server is available again(is this possible at all?, I thought immediateFail=false should do it) Which comes to my second problem.
If I start my application (with syslog-ng available) and then I stop it after a while and start it again. It get not reconnected(EDIT: Ok It does after a while, but lost a lot of logmessages).
Here is my log42.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyAppx" packages="">
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout
pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n" />
</Console>
<Syslog name="RFC5424" format="RFC5424" host="192.168.0.81" port="1000"
protocol="TCP" appName="app" mdcId="mdc" includeMDC="true"
facility="LOCAL0" enterpriseNumber="18060" newLine="true" immediateFail="false"
messageId="Audit" id="App" ignoreExceptions="true"/>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="STDOUT" />
<AppenderRef ref="RFC5424" />
</Root>
</Loggers>
I am open for other solutions, but what I want is that no logmessage is lost at all. And sooner or later all logmessages should be available on an central stations(thats because I wanna use a syslogserver instead of multiple local files)