Java Log4j2 Syslog Appender doen't send messages -
i'm trying use log4j2 syslog appender no messages sent. i'm monitoring environment using wireshark , no messages detected. running on windows 7.
when use kiwi syslog, messages arrive fine.
here log4j2 xml configuration file:
<?xml version="1.0" encoding="utf-8"?> <configuration status="warn" name="myapp" packages=""> <appenders> <console name="console" target="system_out"> <patternlayout pattern="%d{hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/> </console> <syslog name="rfc5424" format="rfc5424" host="localhost" port="514" protocol="udp" appname="myapp" includemdc="true" facility="user" enterprisenumber="18060" newline="true" messageid="audit" mdcid="mdc" id="app" connecttimeoutmillis="1000" reconnectiondelaymillis="5000"> <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="%m"/> </loggerfields> </syslog> </appenders> <loggers> <logger name="com.mycorp" level="info" /> <root level="info"> <appenderref ref="rfc5424"/> <appenderref ref="console"/> </root> </loggers> </configuration>
here java code:
import org.apache.logging.log4j.logger; import org.apache.logging.log4j.logmanager; import java.io.*; import java.sql.sqlexception; public class sysloglogger { private static final logger log = logmanager.getlogger(sysloglogger.class); public static void main (string[] args)throws ioexception,sqlexception { log.error("testing error level"); } }
the console appender works fine, syslog doesn't.
please advise.
try code below , check it:
<appender name="console" class="org.apache.log4j.consoleappender"> <param name="target" value="system.out"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/> </layout> </appender>
Comments
Post a Comment