python
import logbook
from logbook import FileHandler, TimedRotatingFileHandler
python
logbook.set_datetime_format('local')
logbook.set_loglevel(logbook.DEBUG)
log_handler = FileHandler(filename='logs/app.log', level=logbook.DEBUG)
log_handler.push_application()
python
log_handler = TimedRotatingFileHandler(filename='logs/app.log', level=logbook.DEBUG,
backup_count=5, when='midnight')
log_handler.push_application()
python
logbook.NestedSetup([
logbook.NullHandler(),
logbook.TimedRotatingFileHandler('logs/archive/app-{date}.log', level=logbook.DEBUG,
backup_count=30, date_format='%Y-%m-%d'),
logbook.ArchiveHandler('logs/archive.zip', level=logbook.DEBUG,
backup_count=30, format_string='{record.message}')
]).push_application()