title: Python's SyslogHandler and TCP
body: <p>I'm trying to understand why the SyslogHandler class from Python's logging framework (logging.handlers) does not implement any of the framing mechanism described by RFC 6587:</p>
  
  <ol>
  <li><p><strong>Octet Counting</strong>: it "prepends" the message length to the syslog frame:</p></li>
  <li><p><strong>Non-Transparent-Framing</strong>: a trailer character to separate messages. This is what most of the servers understand.</p></li>
  </ol>
  
  <p>This "problem" can be easily solved by adding a LF character to the end of the messages, however I would expect that the SyslogHandler would take care of this by default:</p>
  
  <pre class="lang-python prettyprint-override"><code>sHandler = logging.handlers.SysLogHandler(address=(address[0], address[1]), socktype = socket.SOCK_STREAM)
  sHandler.setFormatter(logging.Formatter(fmt=MSG_SYSLOG_FORMAT, datefmt=DATE_FMT))
  self.addHandler(sHandler)
  </code></pre>
  
  <p>This does not work neither with Fluentd, nor with rsyslog. As I said, I've temporarily added this to line 855 of handlers.py (just to test):</p>
  
  <pre><code>msg = prio + msg + '\n'
  </code></pre>
  
  <p>And now is working.</p>
  
  <hr>
  
  <h1>My questions:</h1>
  
  <ol>
  <li>Should the Python SyslogHandler class offer the possibility to set on/off the octet counting or trailer character. Currently it does nothing...</li>
  <li>It is the job of the programmer to know how the server works and override the Handler to address the message framing?</li>
  </ol>
  
  <p>For now, what I'm doing now is to override emit() method, sub-classing SyslogHandler.</p>