I need to log events into the syslog.
I use lo4j2 and the syslog appender.
My appenders block in log4j2.xml
looks like this:
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<Syslog name="syslog" host="localhost" port="514" protocol="UDP" charset="ISO-8859-1">
</Syslog>
<RollingFile name="AppLog" fileName="/var/log/app.log"
filePattern="/var/log/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
</RollingFile>
</appenders>
As you can see I have a Console appender and RollingFile appender with a specific PatternLayout. I want to use the same PatternLayout for the Syslog appender. However, the log messages in the syslog seem to always use a predefined layout. I tried to do the following:
<Syslog name="syslog" host="localhost" port="514" protocol="UDP" charset="ISO-8859-1">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Syslog>
But this does not have any effect. the syslog messages still have the same predfined format.
How can I determine the format of my log messages that go into the syslog?