Rodomi pranešimai su žymėmis logging. Rodyti visus pranešimus
Rodomi pranešimai su žymėmis logging. Rodyti visus pranešimus

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

2020 m. gegužės 20 d., trečiadienis

Java spring logging


The available logging levels in Logback are:

OFF (output no logs)
ERROR
WARN
INFO
DEBUG
TRACE

Loging messeage meanings:
LOGGER.trace("doStuff needed more information - {}", value);
LOGGER.debug("doStuff needed to debug - {}", value);
LOGGER.info("doStuff took input - {}", value);
LOGGER.warn("doStuff needed to warn - {}", value);
LOGGER.error("doStuff encountered an error with value - {}", value);


To disable dublicating log code to log, add to logback.xml:
additivity="false"


Adding logger like:
private static final Logger log = LoggerFactory.getLogger(YourClassName.class);


Sources:

2017 m. lapkričio 14 d., antradienis

python logging

Adds logger to usual projects:

logging.getLogger('flask_cors').level = logging.DEBUG

Logging to file for paramiko library

logging.getLogger('paramiko').setLevel(logging.DEBUG)
paramiko.util.log_to_file('foo.log')