-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
touch-reopen
doesn't repoen log file created by req-logger
#741
Comments
Having the same issue with 'touch-logreopen' option. The option only reopens log filed defined with 'logto' option. |
request logging only uses pluggable loggers, so "basic file-logging" procedure cannot work. Each plugin has its features, and, as an example, "reopening" is not meaningful for the vast majority of them. You could improve the logfile plugin to support reopening, or you can use the logpipe plugin to use (again as an example) a tool like this: http://httpd.apache.org/docs/2.2/programs/rotatelogs.html Try to describe your specific scenario, maybe there is a better solution or approach to follow |
I am using linux bundled 'logrotate' to rotate the log file of req-logger. I do not want to reload uWSGI after each rotation and thus trying to use the touch-logreopen option. BTW, I am using 'copytruncate' option of 'logrotate' as a workaround right now. And, I will later use chain reload of uWSGI instead of 'copytruncate' if the logfile plugin is not going to support touch-logreopen. FYI, my logrotate config right now:
@unbit, is there a better alternative to 'copytruncate' other than uWSGI chain reload? |
I would have suggested the 'copytruncate' approach, but i have to suppose it is problematic for you (huge logfile size and/or copying it requires ages, slow I/O ...). @xrmx implemented log-rotation in the file logger, but (being based on size and not time) i suppose it is suboptimal too. The only solution i could think of is improving https://github.com/unbit/uwsgi/blob/master/plugins/logfile/logfile.c to reopen logs on specific events (like on a master-fifo command). Or to improve it to periodically (like once every 30 seconds) check if the inode of the logfile changed, and automatically reopen it when happens. |
It looks like the logfile plugin already supports rotating to a backup file based on a maxsize (see the 'backupname' and 'maxsize' options in https://github.com/unbit/uwsgi/blob/master/plugins/logfile/logfile.c). You can then setup logrotate to rotate the backup file. If logrotate runs frequently enough, it should be able to get the backup file out of the way before uwsgi does the next rotation. |
Well, I think it's better to use syslog instead of logging to file directly. No more reload / reopen headache. So, logrotate now manages the log file produced by syslog instead of uwsgi :) fyi - https://hynek.me/articles/taking-some-pain-out-of-python-logging/ |
Anyone bumping here check this commit xrmx@79bbed9 that explains how to actually use maxsize and backupname arguments. Copy-paste for the lazy:
My problem is that logfile plugin doesn't apparently obey |
Touching the file specified by
touch-reopen
option does not reopen the request log file (specified byreq-logger
option).The text was updated successfully, but these errors were encountered: