1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-29 16:55:32 +00:00

examples for log file rotation

This commit is contained in:
Unrud 2017-06-10 21:00:35 +02:00 committed by GitHub
parent 8d4b497847
commit 5493f89646

View file

@ -20,6 +20,8 @@ A logging configuration file can be specified in the `config` configuration
option in the `logging` section. The file format is explained in the option in the `logging` section. The file format is explained in the
[Python Logging Module](https://docs.python.org/3/library/logging.config.html#configuration-file-format). [Python Logging Module](https://docs.python.org/3/library/logging.config.html#configuration-file-format).
## Logging to a file
An example configuration to write the log output to the file `/var/log/radicale/log`: An example configuration to write the log output to the file `/var/log/radicale/log`:
```ini ```ini
[loggers] [loggers]
@ -48,3 +50,31 @@ format = %(asctime)s - [%(thread)x] %(levelname)s: %(message)s
You can specify multiple **logger**, **handler** and **formatter** if you want You can specify multiple **logger**, **handler** and **formatter** if you want
to have multiple simultaneous log outputs. to have multiple simultaneous log outputs.
### Timed rotation of disk log files
An example **handler** configuration to write the log output to the file `/var/log/radicale/log` and rotate it .
Replace the section `handle_file` from the file logging example:
```ini
[handler_file]
class = handlers.TimedRotatingFileHandler
# Specify the output file and parameter for rotation here.
# See https://docs.python.org/3/library/logging.handlers.html#logging.handlers.TimedRotatingFileHandler
# Example: rollover at midnight and keep 7 files (means one week)
args = ('/var/log/radicale/log', when='midnight', interval=1, backupCount=7)
formatter = full
```
### Rotation of disk log files based on size
An example **handler** configuration to write the log output to the file `/var/log/radicale/log` and rotate it .
Replace the section `handle_file` from the file logging example:
```ini
[handler_file]
class = handlers.RotatingFileHandler
# Specify the output file and parameter for rotation here.
# See https://docs.python.org/3/library/logging.handlers.html#logging.handlers.RotatingFileHandler
# Example: rollover at 100000 kB and keep 10 files (means 1 MB)
args = ('/var/log/radicale/log', 'a', 100000, 10)
formatter = full
```