From: Quanah Gibson-M. <qu...@zi...> - 2012-04-06 18:31:26
|
--On Thursday, April 05, 2012 2:33 PM -0700 Quanah Gibson-Mount <qu...@zi...> wrote: > --On Thursday, April 05, 2012 9:13 PM +0100 Alan Kennedy > <jyt...@xh...> wrote: > >> [Quanah] >>> I see I can easily do this directly with Java via syslog4j, so I'm >>> covered. ;) >> >> Cool. >> >> If you could send a couple of code or configuration snippets to the >> list, that would be great. >> >> That would help any others who face the same problem in the future. > > from org.productivity.java.syslog4j import Syslog > from org.productivity.java.syslog4j import SyslogIF > from org.productivity.java.syslog4j import SyslogConstants > from org.productivity.java.syslog4j.impl.unix import UnixSyslog > from org.productivity.java.syslog4j.impl.unix.socket import > UnixSocketSyslogConfig > > zmconfigdSyslogInstance = > UnixSocketSyslogConfig(SyslogConstants.FACILITY_LOCAL0, "/dev/log") > zmsyslog = Syslog.createInstance("zmSyslog",zmconfigdSyslogInstance) > > zmsyslog.info("info level test message") > > Will log the message via facility LOCAL0 at info level. ;) One final note: By default, syslog4j uses the hostname as the local process name it reports, which isn't ideal. You can easily change the name it logs to syslog with the setLocalName function. For example, my process is called zmconfigd. To make its messages look like other syslog messages, I did: zmsyslog.getConfig().setLocalName("zmconfigd[%d]:" % os.getpid()) --Quanah -- Quanah Gibson-Mount Sr. Member of Technical Staff Zimbra, Inc A Division of VMware, Inc. -------------------- Zimbra :: the leader in open source messaging and collaboration |