Hi, The RFC5424 format is what it is: https://tools.ietf.org/html/rfc5424
If you want to do something else, you can use a SocketAppender configured with a PatternLayout. Gary On Tue, Nov 24, 2015 at 1:35 AM, jinhong lu <[email protected]> wrote: > Hi, > > I want to write log to rsyslog > > when I use log4j1.x,I use this to define the pattern: > > appender.setLayout(new PatternLayout("%r " + loggerName +" > [%t] %-5p %C%x - %m %C")); > > How can I do the same thing in log4j2.x? > > Now I get the message like this: > Nov 24 17:26:59 liaoliuqingdeMacBook-Air.local MyApp ljh_test message > > I even can not see the level of the log. So how can I set the pattern in > log4j2.x syslogPattern. > > here is my configuration > > > <?xml version="1.0" encoding="UTF-8"?> > <Configuration status="warn" name="MyApp" packages="com.lujinhong"> > <Appenders> > <Syslog name="RFC5424" format="RFC5424" host="10.120.1.1" > port="514" > protocol="UDP" appName="MyApp" includeMDC="true" > facility="LOCAL7" enterpriseNumber="18060" newLine="true" > messageId="Audit" mdcId="mdc" id="storm" > > > <LoggerFields> > <KeyValuePair key="thread" value="%t"/> > <KeyValuePair key="priority" value="%p"/> > <KeyValuePair key="category" value="%c"/> > <KeyValuePair key="exception" value="%ex"/> > <KeyValuePair key="message" value="%r [%t] %-5p %C%x - %m > %C"/> > </LoggerFields> > </Syslog> > </Appenders> > <Loggers> > <Logger name="com.mycorp" level="info" /> > <Root level="info"> > <AppenderRef ref="RFC5424"/> > </Root> > </Loggers> > </Configuration> -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
