Skip to content
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

Open
tahajahangir opened this issue Oct 11, 2014 · 7 comments
Open

touch-reopen doesn't repoen log file created by req-logger #741

tahajahangir opened this issue Oct 11, 2014 · 7 comments

Comments

@tahajahangir
Copy link

Touching the file specified by touch-reopen option does not reopen the request log file (specified by req-logger option).

@mrkschan
Copy link

mrkschan commented Dec 1, 2014

Having the same issue with 'touch-logreopen' option. The option only reopens log filed defined with 'logto' option.

@unbit
Copy link
Owner

unbit commented Dec 2, 2014

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

@mrkschan
Copy link

mrkschan commented Dec 2, 2014

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:

   /var/log/uwsgi/*.log {
        daily
        missingok
        rotate 7
        compress
        delaycompress
        notifempty
        copytruncate
        create 644 www-data www-data
    }

@unbit, is there a better alternative to 'copytruncate' other than uWSGI chain reload?

@unbit
Copy link
Owner

unbit commented Dec 2, 2014

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.

@tstack
Copy link

tstack commented Feb 25, 2015

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.

@mrkschan
Copy link

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/

@tuukkamustonen
Copy link

tuukkamustonen commented Nov 23, 2016

Anyone bumping here check this commit xrmx@79bbed9 that explains how to actually use maxsize and backupname arguments.

Copy-paste for the lazy:

logger = staticlogger file:logfile=%dstatic.log,backupname=%dstatic.log.old,maxsize=1500

My problem is that logfile plugin doesn't apparently obey umask directive? Would that need separate support from the plugin as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants