8.6. Non-printable characters

  1. In order not to cause trouble to log analysis tools or terminals during log
  2. consulting, non-printable characters are not sent as-is into log files, but are
  3. converted to the two-digits hexadecimal representation of their ASCII code,
  4. prefixed by the character '#'. The only characters that can be logged without
  5. being escaped are comprised between 32 and 126 (inclusive). Obviously, the
  6. escape character '#' itself is also encoded to avoid any ambiguity ("#23"). It
  7. is the same for the character '"' which becomes "#22", as well as '{', '|' and
  8. '}' when logging headers.
  9.  
  10. Note that the space character (' ') is not encoded in headers, which can cause
  11. issues for tools relying on space count to locate fields. A typical header
  12. containing spaces is "User-Agent".
  13.  
  14. Last, it has been observed that some syslog daemons such as syslog-ng escape
  15. the quote ('"') with a backslash ('\'). The reverse operation can safely be
  16. performed since no quote may appear anywhere else in the logs.