You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is mostly to help other people as we are probably just going to move away from log4r to syslog or something. We have a project which uses log4r with the RollingFileOutputter. The latest log is not growing in size but instead being overwritten frequently. I believe this is the due to the fact that log4r is opening it in write mode instead of append mode.
I see in RollingFileOutputter#roll you have open_log_file('w'), I'm guessing there may be a race condition or something that is causing that to happen in multiple processes. (Extra info: we have the maximum number of logs -- eg max_backups has been reached). I'm not sure why you would ever want to open a log file in write mode, since append mode also creates the file if it doesn't exist.
We are seeing this too with many processes writing to the same log file. There is certainly a race condition between checking if its time to roll and opening the next file. When the second process re-opens the same file in "w" mode you get lots of craziness because, unlike append mode, "w" does not seek to the end of the file for you when writing. That means the processes will be battling it out and overwriting the middle of the file.
I'll note that simply changing "w" to "a" brought up another issue -- we got occasional errors where log4r was looking for a log file that didn't exist and raising an error, on the line @start_time = File.ctime(@filename). It only happens once a week or so for us so I haven't had time to debug it further.
This is mostly to help other people as we are probably just going to move away from log4r to syslog or something. We have a project which uses log4r with the RollingFileOutputter. The latest log is not growing in size but instead being overwritten frequently. I believe this is the due to the fact that log4r is opening it in write mode instead of append mode.
I see in
RollingFileOutputter#roll
you haveopen_log_file('w')
, I'm guessing there may be a race condition or something that is causing that to happen in multiple processes. (Extra info: we have the maximum number of logs -- eg max_backups has been reached). I'm not sure why you would ever want to open a log file in write mode, since append mode also creates the file if it doesn't exist.The text was updated successfully, but these errors were encountered: