0
votes

I'm currently working on a java log forwarder which logs the messages to a remote syslog server. Using the Official Log4J2 manual, I've written the code using SyslogAppender configured via ConfigurationBuilder Factory. It works fine for UDP. But for TCP, it is, kind of buffering all the messages and once the program is terminated it flushes out all the log messages at once as a single log message. I tried setting the immediateFlush field, But no use.

1
Your explanation of the problem is good, but in this case you also need to include the actual code (which you are explaining therein). Doing this will give all of us a fair idea of what you are working with.ishmaelMakitla
The TcpSocketManager, which the SyslogAppender uses, writes directly to the Socket's OutputStream. With immediaFlush flush() is called on the OutputStream after every write, so unless there is OS buffering going on the data should be written immediately.rgoers
Which version of Log4j 2 are you using? You may want to raise a Jira ticket on the Log4j issue tracker.Remko Popma
Hi, I have exactly the same problem, did you find a solution? I'm using log4j 2.14. ThanksLoic

1 Answers

0
votes

Using the newLine="true" boolean in the Syslog definition worked for me.

Example :

<Syslog name="LogStashSysLog" host="localhost" port="9998" protocol="TCP" newLine="true"/>