The unprintable characters at the beginning of the message are probably UTF-8 BOM.
Please note that RFC 5424 suggest to use UTF-8 with BOM by default. See section 6.4:
The character set used in MSG SHOULD be UNICODE, encoded using UTF-8 as specified in [RFC3629].
...
If a syslog application encodes MSG in UTF-8, the string MUST start with the Unicode byte order mask (BOM), which for UTF-8 is ABNF %xEF.BB.BF.
At the current version, there is no option to disable UTF-8 BOM. However, BOM is emitted for utf-8
encoding only. If you set SyslogMessage.TextEncoding
to any other value (e.g. Encoding.ASCII
) the UTF-8 BOM is not emitted.
Alternatively, you can create and use your own UTF-8 encoding like this:
private class MyUtf8Encoding : System.Text.UTF8Encoding
{
public override string WebName { get { return "my-utf-8"; } }
public override int CodePage { get { return 65002; } }
}