21 lines
577 B
Python
21 lines
577 B
Python
|
"""
|
||
|
RotatingFileHandler, mantiene un log con los eventos mas actuales y
|
||
|
mantiene el log de un tamaño mas pequeño
|
||
|
"""
|
||
|
|
||
|
import logging
|
||
|
from logging.handlers import RotatingFileHandler
|
||
|
|
||
|
logger = logging.getLogger(__name__)
|
||
|
logger.setLevel(logging.INFO)
|
||
|
|
||
|
# Sobreescribe el log cuando este pasa los 2KB, y mantiene respaldo de los logs.
|
||
|
# app.log.1, app.log.2, etc.
|
||
|
handler = RotatingFileHandler('./rotating_logs/rotating_file_handler_app.log', maxBytes=2000, backupCount=5)
|
||
|
logger.addHandler(handler)
|
||
|
|
||
|
for _ in range(10000):
|
||
|
logger.info('manejador de logs rotativo')
|
||
|
|
||
|
|