title: LoggerFields for Syslog (output log priority and stack trace)
body: <p>Log4j can send logs to Papertrail using a syslog appender (<a href="http://help.papertrailapp.com/kb/configuration/java-log4j-logging/" rel="nofollow">documentation</a>): </p>
  
  <pre><code>log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
  log4j.appender.syslog.Facility=LOCAL7 
  log4j.appender.syslog.FacilityPrinting=false 
  log4j.appender.syslog.Header=true 
  log4j.appender.syslog.SyslogHost=&lt;host&gt;.papertrailapp.com:XXXXX
  log4j.appender.syslog.layout=org.apache.log4j.PatternLayout 
  log4j.appender.syslog.layout.ConversionPattern=%p: (%F:%L) %x %m %n
  </code></pre>
  
  <p>Notice the handy <code>ConversionPattern</code> property.</p>
  
  <hr>
  
  <p>I have managed to get something similar rolling for log4j2:</p>
  
  <pre><code>Syslog:
    name: Syslog
    id: [my-id]
    appName: [my-app]
    protocol: UDP
    format: RFC5424
    facility: local7
    host: &lt;host&gt;.papertrailapp.com
    port: XXXXX
    includeMDC: true
    mdcId: mdc 
  </code></pre>
  
  <p>It works and outputs using the default RFC5424 format:</p>
  
  <pre><code>May 14 14:31:36 [server] [app]: My log message
  </code></pre>
  
  <hr>
  
  <p>What I really want is a message with priority information as well as full stack traces: </p>
  
  <pre><code>May 14 14:31:36 [server] [app]: ERROR My log message MyException
          at package1.MyClass.method1(MyClass.java:20)
          at ...
  </code></pre>
  
  <p>Looks like <a href="http://logging.apache.org/log4j/2.x/manual/appenders.html#SyslogAppender" rel="nofollow">LoggerFields</a> is supposed to do it, but I can't get it to work:</p>
  
  <pre><code> loggerFields:
     LoggerFields:
       KeyValuePair:
         key: priority
         value: "%p"
       KeyValuePair:
         key: exception
         value: "%ex"
  </code></pre>
  
  <p>How can I get Log4j2 to output to syslog using the desired format?</p>