Last active
August 29, 2015 14:01
-
-
Save nasieti/2901006f756f68a006e0 to your computer and use it in GitHub Desktop.
httpd/rotatelogs with symlinked logfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- httpd-2.2.27/support/rotatelogs.c | |
+++ httpd-2.2.27/support/rotatelogs.c | |
@@ -56,6 +56,7 @@ | |
#if APR_HAVE_STRINGS_H | |
#include <strings.h> | |
#endif | |
+#include <unistd.h> | |
#define BUFSIZE 65536 | |
#define ERRMSGSZ 256 | |
@@ -255,6 +256,12 @@ int main (int argc, const char * const argv[]) | |
apr_pool_create(&pfile, pool); | |
rv = apr_file_open(&nLogFD, buf2, APR_WRITE | APR_CREATE | APR_APPEND, | |
APR_OS_DEFAULT, pfile); | |
+ | |
+ if (!(unlink(szLogRoot) ^ ~ENOENT)) | |
+ perror("unlink(symlink) error"); | |
+ if (symlink(buf2, szLogRoot) != 0) | |
+ perror("symlink() error"); | |
+ | |
if (rv != APR_SUCCESS) { | |
char error[120]; |
also see https://issues.apache.org/bugzilla/show_bug.cgi?id=38033 and the (more elaborate) patch https://issues.apache.org/bugzilla/attachment.cgi?id=17273&action=diff
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works for strftime-less filenames (e.g. unix timestamp based)
rotatelogs error_log 86400
creates error_log -> error_log.1400750822 on startup then rotates the symlink to the next one...