小编DUD*_*MXP的帖子

Logging in Python/Django not working as expected

I have the following handler configuration for logging:

    "handlers": {
      'system_file': {
        'level': 'DEBUG',
        'class': 'logging.handlers.TimedRotatingFileHandler',
        'filename': os.path.join(LOG_FOLDER, "all.log"),
        'formatter': 'verbose',
        'when': 'midnight',
        'backupCount': '30',
      }
   }
Run Code Online (Sandbox Code Playgroud)

Now based on this configuration my logs should get rotated every midnight, i.e it should create date wise logs.

In the all.log file, everything gets logged properly with correct timestamp, but when the rotation happens, I do not see all the logs in the backup log files (previous day log files).

For example: …

python django logging django-logging python-logging

5
推荐指数
1
解决办法
172
查看次数

标签 统计

django ×1

django-logging ×1

logging ×1

python ×1

python-logging ×1