Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System logs do not work on macOS 12 #368

Open
deluan opened this issue Apr 5, 2023 · 1 comment
Open

System logs do not work on macOS 12 #368

deluan opened this issue Apr 5, 2023 · 1 comment

Comments

@deluan
Copy link

deluan commented Apr 5, 2023

Looks like Apple changed the way the syslog daemon receives log messages, causing all Go programs to not log anything to syslog when using the log/syslog package.

The current workaround is to use CGO and call the syslog() system call.

Are you open to receive a PR that implements the syslog for darwin like that? It could be disabled by simply setting CGO=0, which would revert to the current behaviour, i.e. not working :(

Let me know if you have other possible solutions for this. Thanks!

@craig65535
Copy link

As I mentioned in the linked bug report, I do have a (bad) workaround for when CGO is not desired, and I'll describe it here in case you find it useful.

I exec /usr/bin/logger -p <facility>.<severity> and then feed it messages over stdin. It doesn't tag the messages as coming from my process, but it does get logs into the Console and log store. Note also that the facility seems to be ignored, and all messages going to logger will be logged with the severity given when it was launched. You can work around this in turn by starting separate logger processes for debug, info and notice (notice and higher severity messages like error all appear in the Console as default-level).

One thing I had to do was exec logger into a new process group so it wouldn't be affected by the parent process receiving a ctrl-C. This allowed me to catch SIGINT in my process and continue logging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants