I need to use log4j to append logs to a socket with UDP. However, I cannot find much on the internet about how to do so. In Log4J, the socketappender uses TCP. So I got log4j 2 beta, but I can't find any examples/documentation on how to use the socketappender, especially for UDP. I would really appreciate it if anyone could give me an example/show me how to use Log4j for UDP. Thanks.
I have been working with log4j 2.0-beta8 and got the UDP appender working with following log4j2.xml file (but note the 2 in the name of the file!):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appenders>
<Socket name="UDP" host="myhostname.com" port="3333" protocol="UDP">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c{1} - %m%n"/>
</Socket>
</appenders>
<loggers>
<root level="info">
<appender-ref ref="UDP"/>
</root>
</loggers>
</configuration>
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