Loguru loguruDelgan • Updated 2025 May 14 11:16
loguru
Delgan • Updated 2025 May 14 11:16
from loguru import logger # Set up logging with custom formatting and level logger.add("file.log", format="{time} {level} {message}", level="INFO") # Log messages with different severity logger.debug("This is a debug message") logger.info("Training started") logger.warning("Data preprocessing might take longer") logger.error("Model training failed") logger.exception("Exception occurred during testing")
logger.getLogger().setLevel(logger.WARNING)
logging - Logging facility for Python - Python 3.8.6rc1 documentation
Source code: Lib/logging/__init__.py This module defines functions and classes which implement a flexible event logging system for applications and libraries. The key benefit of having the logging API provided by a standard library module is that all Python modules can participate in logging, so your application log can include your own messages integrated with messages from third-party modules.
https://docs.python.org/ko/3/library/logging.html
In python, why use logging instead of print?
For simple debugging in a complex project is there a reason to use the python logger instead of print? What about other use-cases? Is there an accepted best use-case for each (especially when you...
https://stackoverflow.com/questions/6918493/in-python-why-use-logging-instead-of-print

Seonglae Cho