A simple Python logging utility with console/file output and automatic log cleanup. This library provides an easy-to-use interface for setting up logging in your Python projects with minimal configuration.
Key Features:
- Simple setup with one function call
- Session tracking with auto-generated UUID to trace logs from the same execution
- Dual output: log to console for debugging and file for persistent records
- Auto cleanup: keep only recent logs (default: 3 days), no manual deletion needed
This project uses Python 3.x with only standard library modules (no external dependencies required).
-
create
demo.py -
Import the logger setup function:
from logger import setup_logger- Choose your setup method:
Method 1: Customized Configuration
logger = setup_logger(
name=__name__,
enable_console=True,
enable_file=True,
level=logging.INFO,
dir='./logs'
)
logger.debug('Debug message')
logger.info('Info message')Method 2: Default Configuration
logger = setup_logger()
logger.debug('Debug message')
logger.info('Info message')- Run your Python script:
python3 demo.py2025-11-16 00:41:00,951 | demo.py | INFO | 49e1e65d-2734-4807-81de-306ee628d788 | Your message
See the result of running the logger with both console and file output:

Shyin Lim -> https://github.com/shyinlim