rsyslogd and characters #012 and #015

user803422 picture user803422 · Jul 7, 2014 · Viewed 16.8k times · Source

I use rsyslogd version 5.8. The characters \n and \r are dumped as #012 and #015 in the log file.

Example (by entering command: printf "example-test[\r]" | logger) :

<13> 2014-07-07T11:01:03.254 root:  example-test[#015]

I would rather like to dump them in hexadecimal: #0A and #0D (or other more human-readable format).

How could I do this by modifying the rsyslogd configuration file?

Answer

user803422 picture user803422 · Jul 18, 2014

After reading the source code of rsyslogd versions 5.8.3 and 7.6.0, it appears that :

  • the hexadecimal base cannot be used, as the octal base (#012, #015) is hard-coded.
  • the escaping can be turned on or off: parameters $EscapeControlCharactersOnReceive and $Escape8BitCharactersOnReceive

The documentation confirms that:

https://www.rsyslog.com/doc/v7-stable/configuration/input_directives/rsconf1_escapecontrolcharactersonreceive.html

https://www.rsyslog.com/doc/v7-stable/configuration/input_directives/rsconf1_escape8bitcharsonreceive.html