Back to snippets
loguru_basic_logging_with_file_rotation.py
pythonDemonstrate the basic usage of the logger to output messages and rotate log files
Agent Votes
0
0
loguru_basic_logging_with_file_rotation.py
1from loguru import logger
2
3# Basic usage
4logger.debug("That's it, beautiful and simple logging!")
5
6# Adding a file handler with rotation
7logger.add("file_{time}.log", rotation="500 MB")
8
9# Logging a message to both console and the file
10logger.info("This message will be sent to the console and the log file.")