Apache HTTPd - rotatelogs not working
5,845
rotatelogs requires a full path.
Prepending the ServerRoot to relative paths (i.e those not not starting with a /
or driveletter:\
) happens only within Apache and external programs such as rotatelogs are not aware of Apache's ServerRoot variable.
Related videos on Youtube
Author by
Mike C
Updated on September 18, 2022Comments
-
Mike C over 1 year
I've edited my conf.d/ssl.conf file and changed the TransferLog directive from:
TransferLog logs/ssl_access_log
to
TransferLog "|/usr/sbin/rotatelogs logs/ssl_access_log.%Y-%m-%d.log 60"
(I am using 60 seconds for testing)
Since that change and an httpd restart my original ssl_access_log is not updating and a new log was not generated. What am I missing?
in my error log, I am receiving this message
Could not open log file 'logs/ssl_access_log.2014-05-30.log' (No such file or directory) piped log program '/usr/sbin/rotatelogs logs/ssl_access_log.%Y-%m-%d.log 60' failed unexpectedly
-
Mike C almost 10 yearsNo, selinux is disabled.
-
Mike C almost 10 yearsIf I specify the full path it seems to work, but why is that required when the default path writes to the correct directory? (i.e /var/log/httpd/ssl_access...)
-
-
Mike C almost 10 yearsThanks, that explains it then. I'd up vote you, but apparantly I can't yet. One more question if you don't mind. According to the docs if the location is not prefixed with a "/" then it will append to the server root which in my case is "/etc/httpd". But my logs (without rotatelogs) are written to /var/logs/httpd. Where is this specified? I am ok with the location, but the logic makes me thing they should be written to "/etc/httpd/logs".
-
Mike C almost 10 yearsI guess I missed that, thanks again for your help in helping me understand!
-
end-user over 8 yearsCould the OP use something like
TransferLog "|/usr/sbin/rotatelogs ${SERVER_ROOT}/logs/ssl_access_log.%Y-%m-%d.log 60"
? -
HBruijn over 8 yearsI don't know but that's easily tested (when one is not on mobile ) but I don't think the Apache internal variables are available to the sub shell that gets called to run rotatelogs