[Mono-list] Using the syslog [Mono.Unix.Native.Syscall] with own identifier

Jonathan Pryor jonpryor at vt.edu
Wed Dec 1 18:45:29 EST 2010

On Dec 1, 2010, at 2:37 PM, <mabra at manfbraun.de> <mabra at manfbraun.de> wrote:
> If I use:
> Syscall.syslog(SyslogFacility.LOG_DAEMON, SyslogLevel.LOG_NOTICE, "myMsg");
> this appears with identifier "mono:" in the syslog. To make syslog
> more evaluable, I need to define my own identifier instead.

You need to use Syscall.openlog() before calling Syscall.syslog() to provide the ident string:


You can find more info by reading the Linux man pages, in particular the openSUSE openlog(3) page states:

       The  argument  ident in the call of openlog() is probably stored as-is.
       Thus, if the string  it  points  to  is  changed,  syslog()  may  start
       prepending the changed string, and if the string it points to ceases to
       exist, the results are undefined.  Most portable is  to  use  a  string

Which is why the first character to Syscall.openlog() is an IntPtr, not a string; you'd thus want to call as:

	Syscall.openlog(Marshal.StringToHGlobalAnsi("my-ident"), 0, 0);

 - Jon

More information about the Mono-list mailing list