thegreenhundred / python_logging_example

template python scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python_templates

This shows an example of how to use the timedRotatingFileHandler to rotate log files in Python.

Example

Run the Python script 'myapp.py'. This will generate a log entry in the log/ directory. Run the script again after 1 second. It will rotate off the previous log file.

  python myapp.py

You can change the frequency of log rotation by changing this variable in logging_config.ini. This example means the log file is rotated off every second, it keeps 5 old log files at most.

args=(os.environ['mylogfile'], 's', 1, 5)

About

template python scripts


Languages

Language:Python 100.0%