I have a logger that send log to a log server storage. This work fine but the patternlayout isn't used. With or without that doesn't change anything. I believe remember to read somewhere that socketappender use is own pattern and not others.
<appender name="LOGSTASH" class="org.apache.log4j.net.SocketAppender">
<param name="Port" value="5000"/>
<param name="RemoteHost" value="192.168.81.131"/>
<param name="ReconnectionDelay" value="5000"/>
<param name="LocationInfo" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n" />
</layout>
</appender>
But on this documentation (and a few other) thay use this. Example from this doc :
<appender name="A1" class="org.apache.log4j.net.SocketAppender">
<param name="RemoteHost" value="localhost"/>
<param name="Port" value="5000"/>
<param name="LocationInfo" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
</layout>
</appender>
So is it impossible to use personnal pattern with socketappender or is it my fault?
If it's impossible is there an alternative appender for tcp logging with custom pattern?
It seems that SocketAppender don't use a layout.
SocketAppenders do not use a layout. They ship a serialized LoggingEvent object to the server side.
See documentation here
So I use a SyslogAppender to replace. It's not perfect because of unused possibilies (like facility and priority) but works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With