Bug 6125 - OSX Lion, syslog call does not send message to syslog
Summary: OSX Lion, syslog call does not send message to syslog
Alias: None
Product: Runtime
Classification: Mono
Component: Interop ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-07-14 12:35 UTC by Attila Tamás Zimler
Modified: 2012-07-16 17:47 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Test program for sending all level log entries with direct and Mono calls to syslog (562 bytes, application/octet-stream)
2012-07-14 13:18 UTC, Attila Tamás Zimler

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Attila Tamás Zimler 2012-07-14 12:35:09 UTC
Call to Syscall.syslog does not write any message to the given log file on OSX Lion.

Mono Runtime:
	Mono 2.10.9 (tarball Mon May  7 20:25:51 EDT 2012)
	GTK 2.24.10
	GTK# (
	Package version: 210090011

Relevant line in /etc/syslog.conf:

After the modification syslogd was restarted with:
killall -HUP syslog

The code that is supposed to write to the log file:
using Mono.Unix.Native;

namespace Syslog
	class MainClass
		public static void Main(string[] args)
			Syscall.syslog(SyslogLevel.LOG_DEBUG, "Test message for logging from BackupTool!");

However no entries are written into the log.
Comment 1 Attila Tamás Zimler 2012-07-14 12:36:48 UTC
sorry for the typo, the restart command is correctly:
killall -HUP syslogd

(The correct command was given on the command line, just the error report has the typo.)
Comment 2 Attila Tamás Zimler 2012-07-14 13:17:13 UTC
Additional investigation shows that it seems that on OSX Lion only message level 5 (LOG_NOTICE) and above are valid (for testing, see the attached test program).
Comment 3 Attila Tamás Zimler 2012-07-14 13:18:43 UTC
Created attachment 2196 [details]
Test program for sending all level log entries with direct and Mono calls to syslog
Comment 4 Jonathan Pryor 2012-07-16 15:34:56 UTC
This isn't a Mono binding bug, this is an OS X configuration "bug"/issue (as the same thing will happen in C, as seen by your manual P/Invoke); see:


If you want LOG_NOTICE messages to be logged in syslog, you need to edit /etc/syslog.conf and add an entry for *.debug. See also:

Comment 5 Attila Tamás Zimler 2012-07-16 15:48:53 UTC
Even writing *.debug does not log the LOG_DEBUG information (just checked it again). Is there any other condition that should be met?

And I know that this is happening with C, because I checked it with DllImport (even there with LOG_DEBUG and *.debug it is ignored).

However there is one more issue related to the problem (and this is the main reason for reporting the error):
- In C you use integers for defining the interval accepted with the syslog function.
- In Mono, you use the SyslogLevel enumeration, which suggests that all value of the enumeration is valid (however as indicated two of them is invalid in this context). I think at least some warning should occure if this is really an OS problem.
Comment 6 Jonathan Pryor 2012-07-16 17:47:42 UTC
> Is there any other condition that should be met?

I don't know. :-(

As for integers vs. enumerations, the enumerations are hand-written against the POSIX standard. SyslogLevel.LOG_NOTICE exists because POSIX defines it, as does syslog(3) on OS X. It's a valid value. OS X just happens to ignore it, but it is a valid POSIX value.

I'm not sure how/where "some warning" should even work. OS support for syslog values is inherently OS specific, and there's no way for the C# compiler to warn that a given value isn't supported. MonoPosixHelper could presumably generate an LOG_ERROR message if you generate a LOG_NOTICE message on OS X, but that sounds wrong/bad, and afaik there's no way to check at runtime if a given log level will be ignored or not.

In short, this is an OS configuration issue, outside the bounds of Mono.Posix.dll.