mguessan / davmail

DavMail POP/IMAP/SMTP/Caldav/Carddav/LDAP Exchange and Office 365 Gateway - Synced with main subversion repository at
http://davmail.sourceforge.net
GNU General Public License v2.0
582 stars 86 forks source link

provide with a /dev/log syslog example #244

Open f1-outsourcing opened 2 years ago

f1-outsourcing commented 2 years ago

Please add config sample of logging to syslog at /dev/log

mguessan commented 2 years ago

Did you try native Log4J syslog appender ?

log4j.appender.Syslog=org.apache.log4j.net.SyslogAppender
log4j.appender.Syslog.layout=org.apache.log4j.PatternLayout
log4j.appender.Syslog.layout.ConversionPattern=%d{ISO8601} %-5p [%t] %c %x - %m%n
log4j.appender.Syslog.syslogHost=localhost
log4j.appender.Syslog.facility=LOCAL1
log4j.appender.Syslog.threshold=debug
f1-outsourcing commented 2 years ago

Currently I am logging directly to the remote syslog with this, but it took me quite some time getting it to work. I also struggle with the logging format, so it is 'syslog' compatible. It would have helped me a lot if there was just an example file.

If I compare your line log4j.appender.Syslog.syslogHost=localhost with mine, I would assume that packets are just being send to 127.0.0.1 port 514. I have this running in a container and I can't be sure that a remote syslog is available, that is why I want to log to /dev/log that volume is always available.

webapps/davmail/WEB-INF/classes/log4j.properties

log4j.rootLogger=INFO, syslog

log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
;log4j.appender.syslog.layout.ConversionPattern=davmail: [%c] [%t] >> ${hostName} %M - %msg%xEx%n
log4j.appender.syslog.layout.ConversionPattern=davmail: %M - %m
log4j.appender.syslog.syslogHost=xxxx.xxx.xx
log4j.appender.syslog.facility=LOCAL1
log4j.appender.syslog.threshold=INFO