我读了logging — Logging facility for Python — Python 3.7.3rc1 documentation,发现定义了6种日志级别
| Level | Numeric value |
| ---------- | ------------- |
| `CRITICAL` | 50 |
| `ERROR` | 40 |
| `WARNING` | 30 |
| `INFO` | 20 |
| `DEBUG` | 10 |
| `NOTSET` | 0 |
根据linux syslog
,定义了8种
The log level
Every printk() message has its own log level. If the log level is
not explicitly specified as part of the message, it defaults to
default_message_loglevel. The conventional meaning of the log level
is as follows:
Kernel constant Level value Meaning
KERN_EMERG 0 System is unusable
KERN_ALERT 1 Action must be taken immediately
KERN_CRIT 2 Critical conditions
KERN_ERR 3 Error conditions
KERN_WARNING 4 Warning conditions
KERN_NOTICE 5 Normal but significant condition
KERN_INFO 6 Informational
KERN_DEBUG 7 Debug-level messages
The kernel printk() routine will print a message on the console only
if it has a log level less than the value of console_loglevel.
此外,SSH还定义了8种
SSH LogLevel
LogLevel
Gives the verbosity level that is used when logging messages from
sshd(8). The possible values are:
QUIET,
FATAL,
ERROR,
INFO,
VERBOSE,
DEBUG,
DEBUG1,
DEBUG2,
and DEBUG3. The default is INFO.
DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify
higher levels of debugging output. Logging with a DEBUG level
violates the privacy of users and is not recommended.
五种日志记录级别的定义从何而来?
答案 0 :(得分:1)
您会注意到,logging
模块允许您根据需要定义其他级别,而缺少的级别则是特定于您要引用其文档的工具的领域。
“安静”等同于完全禁用logging
,“致命”错误可能是您的Python程序必须终止的错误。如果您想在自己的特定应用程序中使用其他调试级别,请继续定义它们-尽管更好的方法可能是对所有内容仅使用logging.DEBUG
,而是有选择地启用或禁用调试级别logging
用于系统中的各个子模块。