Search code examples
syslogwildfly-10byte-order-markrsyslog

Wildfly 10 Sys-log-handler printing with Byte_order_mark <feff>


I have configured a syslog-handler in WildFly-10 Standalone.xml as below

<syslog-handler name="mysyslog">
    <level name="INFO"/>
    <hostname value="localhost"/>
    <app-name value="myappserver"/>
    <facility value="local-use-7"/>
</syslog-handler>

I have added rules in rsyslog.d as

if $programname == 'myappserver'   then /tmp/mysyslog.log

When i check the mysyslog file i could see <feff> characters

These characters are appended by Wildfly itself before sending it to rsyslog.

Can you please let me know how to get rid of these from my logs

I referred this link https://en.wikipedia.org/wiki/Byte_order_mark and it indicated that these are BOM characters


Solution

  • That is per the RFC 5424 spec that the BOM is added. A simple workaround is to override the encoding. Unfortunately the standard syslog server management resource doesn't allow for an encoding to be set. There is an issue filed to fix this though.

    However you could use a custom-handler to override this and use an encoding like US-ASCII to change the encoding which would remove the BOM. The following CLI commands should create a syslog handler similar to the one you have configured.

    /subsystem=logging/pattern-formatter=syslog-pattern:add(pattern="(%t) %s%e")
    /subsystem=logging/custom-handler=syslog:add(module=org.jboss.logmanager, class=org.jboss.logmanager.handlers.SyslogHandler, named-formatter=syslog-pattern, level=INFO, properties={hostname=localhost, appName="myappserver", facility="LOCAL_USE_7", encoding="US-ASCII", syslogType=RFC5424})