Where do DEBUG and INFO messages go when using Python's SyslogHandler on MAC OSX?

帅比萌擦擦* 提交于 2019-12-22 07:20:40

问题


I configured a Python logger with a SysLogHandler and as a test logged some messages using all the levels: debug, info, warning, error, critical. I see all my messages if I run 'syslog' or if I look at the Console.app display. So, all the messages are logged correctly. But, when I tail /var/log/messages.log I don't see the DEBUG and INFO messages. I read about ASL and I see a directory called /var/log/asl full of binary files, but I didn't understand exactly how it interacts with syslog if at all.


回答1:


Using man syslog, man asl (ASL = Apple System Log) and man aslmanager, you'll find that there's a configuration file /etc/asl.conf and the default version contains the lines:

# save everything from emergency to notice
? [<= Level notice] store

This messages at DEBUG and INFO are therefore not stored by ASL, which in turn means they can't be printed by syslog after the fact. The syslog program appears to read the stored data from the binary ASL files and not from the text /var/log/messages.log file.

If you edit the /etc/asl.conf file, you could change the Level to record INFO and DEBUG messages. You'd need to restart the ASL daemons (syslogd, aslmanager), or reboot the computer, and you'd probably need to keep an eye on the space used (because the reason that DEBUG and INFO messages are not stored is that they are apt to be very voluminous).



来源:https://stackoverflow.com/questions/22004505/where-do-debug-and-info-messages-go-when-using-pythons-sysloghandler-on-mac-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!