简体   繁体   English

在MAC OSX上使用Python的SyslogHandler时,DEBUG和INFO消息在哪里?

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

I configured a Python logger with a SysLogHandler and as a test logged some messages using all the levels: debug, info, warning, error, critical. 我使用SysLogHandler配置了一个Python记录器,并作为测试使用所有级别记录了一些消息:debug,info,warning,error,critical。 I see all my messages if I run 'syslog' or if I look at the Console.app display. 如果我运行'syslog'或者我查看Console.app显示,我会看到所有消息。 So, all the messages are logged correctly. 因此,所有消息都被正确记录。 But, when I tail /var/log/messages.log I don't see the DEBUG and INFO messages. 但是,当我tail /var/log/messages.log我没有看到DEBUG和INFO消息。 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. 我读到了ASL,我看到一个名为/var/log/asl的目录,里面装满了二进制文件,但我根本不明白它是如何与syslog交互的。

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: 使用man syslogman asl (ASL = Apple System Log)和man aslmanager ,你会发现有一个配置文件/etc/asl.conf ,默认版本包含以下行:

# 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. 因此,ASB不会存储DEBUG和INFO中的此消息,这反过来意味着事后不能由syslog打印。 The syslog program appears to read the stored data from the binary ASL files and not from the text /var/log/messages.log file. syslog程序似乎从二进制ASL文件而不是文本/var/log/messages.log文件中读取存储的数据。

If you edit the /etc/asl.conf file, you could change the Level to record INFO and DEBUG messages. 如果编辑/etc/asl.conf文件,则可以更改Level以记录INFO和DEBUG消息。 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). 您需要重新启动ASL守护程序( syslogdaslmanager )或重新启动计算机,并且您可能需要密切关注所使用的空间(因为未存储DEBUG和INFO消息的原因是它们是容易变得非常庞大)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM