本文介绍了在MAC OSX上使用Python的SyslogHandler时,DEBUG和INFO消息会发送到哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用SysLogHandler配置了一个Python记录器,并作为测试记录了使用所有级别的一些消息:调试,信息,警告,错误,严重.如果我运行"syslog"或查看Console.app显示屏,我会看到所有消息.因此,所有消息均已正确记录.但是,当我 tail/var/log/messages.log 时,我看不到DEBUG和INFO消息.我读到有关ASL的信息,并且看到一个名为/var/log/asl 的目录,里面充满了二进制文件,但我完全不了解它与syslog的交互方式.

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.

推荐答案

使用 man syslog man asl (ASL = Apple系统日志)和 man aslmanager,您会发现有一个配置文件/etc/asl.conf ,默认版本包含以下行:

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

因此,位于DEBUG和INFO的此消息不会由ASL存储,这反过来意味着事发后 syslog 不能打印这些消息. syslog 程序似乎从二进制ASL文件而不是从文本/var/log/messages.log 文件读取存储的数据.

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.

如果编辑/etc/asl.conf 文件,则可以更改级别以记录INFO和DEBUG消息.您需要重新启动ASL守护程序( syslogd aslmanager )或重新启动计算机,并且可能需要注意所使用的空间(因为之所以没有存储DEBUG和INFO消息,是因为它们很庞大.)

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).

这篇关于在MAC OSX上使用Python的SyslogHandler时,DEBUG和INFO消息会发送到哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 22:02