2023 m. rugsėjo 5 d., antradienis

Logging Levels

System logger

$ journalctl --unit=service

$ journalctl -fu service # To follow log as with tail -f

 
To limit journal logging:

$ sudo nano /etc/systemd/journald.conf
Uncomment
SystemMaxUse=100M
sudo systemctl restart systemd-journald

$ journalctl --disk-usage # How much space is used


Restart system logging
$ sudo systemctl restart rsyslog # resets /var/log/syslog, deamong.log
$ sudo systemctl restart logrotate

/usr/sbin/logrotate -f /etc/logrotate.d/spaikon # Force run logrotate

Show detailed debug trace
from loguru import logger
@logger.catch # Stack trace

Python logger

When a logger is created, the level is set to NOTSET (which causes all messages to be processed when the logger is the root logger, or delegation to the parent when the logger is a non-root logger).

Note that the root logger is created with level WARNING.

Level

Numeric value

CRITICAL

50

ERROR

40

WARNING

30

INFO

20

DEBUG

10

NOTSET

0

Documentation:

https://docs.python.org/3/howto/logging.html