I have a java application using log4j SyslogAppender (facility=USER) and I can see using tcpdump on port 514 that my application is sending intended log message as a datagram and also netstat shows me that syslogd (red hat) is running and listening on 0.0.0.0:514 but I do not see any logging happening in /var/log/messages.
In my syslog.conf, I have
*.info /var/log/messages
My conversion pattern for SyslogAppender is
%d{MMM dd HH:mm:ss} %F %L %5p [%t] %m %n"
I am clueless as why it is failing to log or where exactly should I look for to see what is failing. And I don't have enough permissions on the machine to start/stop syslogd or run manually to have verbose debug logs enabled.
Any pointers as how I proceed?
Edit:
The Appender below
private void initSyslog() {
SyslogAppender syslogAppender = new SyslogAppender();
syslogAppender.setName("syslog");
syslogAppender.setLayout(new PatternLayout("%d{MMM dd HH:mm:ss} %F %L %5p [%t] %m %n"));
syslogAppender.setFacility("USER");
syslogAppender.setFacilityPrinting(true);
syslogAppender.setSyslogHost("localhost");
syslogAppender.activateOptions();
Logger.getRootLogger().addAppender(syslogAppender);
Logger.getRootLogger.info("Syslogdone");
}
The syslog appender writes to a syslogd deamon. The syslogd deamon is the standard logging utility on most UNIX systems.
Community support: Log4j 1. x is not actively maintained, whereas Log4j 2 has an active community where questions are answered, features are added and bugs are fixed. Automatically reload its configuration upon modification without losing log events while reconfiguring.
Log4j is part of the Apache Logging Services Project -- an open source effort within the Apache Software Foundation. The Apache Logging Services Project includes multiple variations of the Log4j logging framework for different programming deployments and use cases.
Log4j, Logback, and Log4j2 are good logging frameworks that are broadly used. So which one should you use? I recommend using Log4j2 because it's the fastest and most advanced of the three frameworks. Logback is still a good option, if performance is not your highest priority.
Remote logging was not enabled in syslog. Weird, because it still opens and listens on 514. Once I started with syslog -r, everything started logging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With