I have a main process which makes use of different other modules. And these modules also use other modules. I need to log all the logs into single log file. Due to use of TimedRotatingFileHandler, my log behaves differently after midnight. I got toknow why it is so but couldn't get how I can solve it.
Issue
On 22 Jun 2022, at 11:06, Lars Liedtke <lal@solute.de> wrote:as if nothing has happened.
Could be unrelated and only a part of a solution, but if you are on a unixoid system, you could use logrotate, instead of TimedRotatingFileHandler. logfrotate ensures that the logging service does not realize, its logs have been rotated. So it can log
The process that is writing the file must be told that rotation has
happened for it to work.
Other wise all the logs keep being write to the original file via the
FD that the process has.
logrotate's config include how to tell the process the log file needs reopening.
...why it is so but couldn't get how I can solve it.
I have a main process which makes use of different other modules. And these modules also use other modules. I need to log all the logs into single log file. Due to use of TimedRotatingFileHandler, my log behaves differently after midnight. I got to know
Issue was because of serialization in logging when multiple processes are involved.
Below is log_config.py which is used by all other modules to get the logger and log.
import logging
import sys
from logging.handlers import TimedRotatingFileHandler
FORMATTER = logging.Formatter("%(asctime)s — %(name)s — %(message)s")
I have a main process which makes use of different other modules. And^^^^^^^^^^^^^^^^^^
these modules also use other modules. I need to log all the logs into
single log file. Due to use of TimedRotatingFileHandler, my log
behaves differently after midnight. I got to know why it is so but
couldn't get how I can solve it.
Issue was because of serialization in logging when multiple processes
are involved.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 80:30:14 |
Calls: | 6,658 |
Calls today: | 4 |
Files: | 12,203 |
Messages: | 5,333,186 |
Posted today: | 1 |