You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by po...@apache.org on 2010/02/25 19:00:43 UTC
svn commit: r916377 - in /httpd/httpd/trunk: CHANGES
docs/manual/programs/rotatelogs.xml support/rotatelogs.c
Author: poirier
Date: Thu Feb 25 18:00:42 2010
New Revision: 916377
URL: http://svn.apache.org/viewvc?rev=916377&view=rev
Log:
Add -L option to create a hard link to the current log file.
PR: 48761
Submitted by: <lindon orthanc.ca>
With additional changes by: poirier
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/docs/manual/programs/rotatelogs.xml
httpd/httpd/trunk/support/rotatelogs.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=916377&r1=916376&r2=916377&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Feb 25 18:00:42 2010
@@ -2,6 +2,9 @@
Changes with Apache 2.3.7
+ *) support/rotatelogs: Add -L option to create a link to the current
+ log file. PR 48761 [<lyndon orthanc.ca>, Dan Poirier]
+
*) mod_ldap: Update LDAPTrustedClientCert to consistently be a per-directory
setting only, matching most of the documentation and examples.
PR 46541 [Paul Reder, Eric Covener]
Modified: httpd/httpd/trunk/docs/manual/programs/rotatelogs.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/programs/rotatelogs.xml?rev=916377&r1=916376&r2=916377&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/programs/rotatelogs.xml (original)
+++ httpd/httpd/trunk/docs/manual/programs/rotatelogs.xml Thu Feb 25 18:00:42 2010
@@ -35,6 +35,7 @@
<p><code><strong>rotatelogs</strong>
[ -<strong>l</strong> ]
+ [ -<strong>L</strong> <var>linkname</var> ]
[ -<strong>f</strong> ]
[ -<strong>v</strong> ]
<var>logfile</var>
@@ -53,6 +54,12 @@
changes the GMT offset (such as for BST or DST) can lead to unpredictable
results!</dd>
+<dt><code>-L</code> <var>linkname</var></dt>
+<dd>Causes a hard link to be made from the current logfile
+to the specified link name. This can be used to watch
+the log continuously across rotations using a command like
+<code>tail -F linkname</code>.</dd>
+
<dt><code>-f</code></dt>
<dd>Causes the logfile to be opened immediately, as soon as
<code>rotatelogs</code> starts, instead of waiting for the
Modified: httpd/httpd/trunk/support/rotatelogs.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/support/rotatelogs.c?rev=916377&r1=916376&r2=916377&view=diff
==============================================================================
--- httpd/httpd/trunk/support/rotatelogs.c (original)
+++ httpd/httpd/trunk/support/rotatelogs.c Thu Feb 25 18:00:42 2010
@@ -89,6 +89,7 @@
int verbose;
const char *szLogRoot;
int truncate;
+ const char *linkfile;
};
typedef struct rotate_status rotate_status_t;
@@ -115,7 +116,7 @@
fprintf(stderr, "%s\n", reason);
}
fprintf(stderr,
- "Usage: %s [-v] [-l] [-f] [-t] <logfile> "
+ "Usage: %s [-v] [-l] [-L linkname] [-f] [-t] <logfile> "
"{<rotation time in seconds>|<rotation size>(B|K|M|G)} "
"[offset minutes from UTC]\n\n",
argv0);
@@ -139,7 +140,9 @@
"when the file size\nis reached a new log is started. If the "
"-t option is specified, the specified\nfile will be truncated "
"instead of rotated, and is useful where tail is used to\n"
- "process logs in real time.\n");
+ "process logs in real time. If the -L option is specified, "
+ "a hard link will be\nmade from the current log file to the "
+ "specified filename.\n");
exit(1);
}
@@ -351,6 +354,20 @@
status->pfile_prev = NULL;
}
status->nMessCount = 0;
+ if (config->linkfile) {
+ apr_file_remove(config->linkfile, status->pfile);
+ if (config->verbose) {
+ fprintf(stderr,"Linking %s to %s\n", status->filename, config->linkfile);
+ }
+ rv = apr_file_link(status->filename, config->linkfile);
+ if (rv != APR_SUCCESS) {
+ char error[120];
+ apr_strerror(rv, error, sizeof error);
+ fprintf(stderr, "Error linking file %s to %s (%s)\n",
+ status->filename, config->linkfile, error);
+ exit(2);
+ }
+ }
}
/*
@@ -440,11 +457,14 @@
apr_pool_create(&status.pool, NULL);
apr_getopt_init(&opt, status.pool, argc, argv);
- while ((rv = apr_getopt(opt, "lftv", &c, &optarg)) == APR_SUCCESS) {
+ while ((rv = apr_getopt(opt, "lL:ftv", &c, &optarg)) == APR_SUCCESS) {
switch (c) {
case 'l':
config.use_localtime = 1;
break;
+ case 'L':
+ config.linkfile = optarg;
+ break;
case 'f':
config.force_open = 1;
break;
Re: svn commit: r916377 - in /httpd/httpd/trunk: CHANGES
docs/manual/programs/rotatelogs.xml support/rotatelogs.c
Posted by Joe Orton <jo...@redhat.com>.
On Mon, Jun 20, 2011 at 04:14:10PM +0200, Graham Leggett wrote:
> On 20 Jun 2011, at 12:58 PM, Plüm, Rüdiger, VF-Group wrote:
>
> >>more general
> >>-p mode just added - is it worth keeping?
> >
> >I think it is worth keeping for those people that only need the link.
> >Creating a post rotation script that does this seems to be a little
> >bit of overkill in this case.
>
> +1.
OK, fair enough - thanks guys. I've fixed the error case and simplified
the code a little in r1140138.
Regards, Joe
Re: svn commit: r916377 - in /httpd/httpd/trunk: CHANGES docs/manual/programs/rotatelogs.xml support/rotatelogs.c
Posted by Graham Leggett <mi...@sharp.fm>.
On 20 Jun 2011, at 12:58 PM, Plüm, Rüdiger, VF-Group wrote:
>> more general
>> -p mode just added - is it worth keeping?
>
> I think it is worth keeping for those people that only need the link.
> Creating a post rotation script that does this seems to be a little
> bit of overkill in this case.
+1.
Regards,
Graham
--
RE: svn commit: r916377 - in /httpd/httpd/trunk: CHANGES docs/manual/programs/rotatelogs.xml support/rotatelogs.c
Posted by "Plüm, Rüdiger, VF-Group" <ru...@vodafone.com>.
> -----Original Message-----
> From: Joe Orton
> Sent: Montag, 20. Juni 2011 12:44
> To: dev@httpd.apache.org
> Subject: Re: svn commit: r916377 - in /httpd/httpd/trunk:
> CHANGES docs/manual/programs/rotatelogs.xml support/rotatelogs.c
>
> Dredging up an change from last year:
>
> On Thu, Feb 25, 2010 at 06:00:43PM -0000, poirier@apache.org wrote:
> > Author: poirier
> > Date: Thu Feb 25 18:00:42 2010
> > New Revision: 916377
> >
> > URL: http://svn.apache.org/viewvc?rev=916377&view=rev
> > Log:
> > Add -L option to create a hard link to the current log file.
> ...
> > @@ -351,6 +354,20 @@
> > status->pfile_prev = NULL;
> > }
> > status->nMessCount = 0;
> > + if (config->linkfile) {
> > + apr_file_remove(config->linkfile, status->pfile);
> > + if (config->verbose) {
> > + fprintf(stderr,"Linking %s to %s\n",
> status->filename, config->linkfile);
> > + }
> > + rv = apr_file_link(status->filename, config->linkfile);
>
> This snippet gets invoked even in the case where opening a
> new log file
> fails, and the old one is truncated and re-used; it will then
> fail and
> break the link, I think. -L is kind of redundant with the
Why? Because status->filename is not pointing to the old filename?
> more general
> -p mode just added - is it worth keeping?
I think it is worth keeping for those people that only need the link.
Creating a post rotation script that does this seems to be a little
bit of overkill in this case.
Regards
Rüdiger
Re: svn commit: r916377 - in /httpd/httpd/trunk: CHANGES
docs/manual/programs/rotatelogs.xml support/rotatelogs.c
Posted by Joe Orton <jo...@redhat.com>.
Dredging up an change from last year:
On Thu, Feb 25, 2010 at 06:00:43PM -0000, poirier@apache.org wrote:
> Author: poirier
> Date: Thu Feb 25 18:00:42 2010
> New Revision: 916377
>
> URL: http://svn.apache.org/viewvc?rev=916377&view=rev
> Log:
> Add -L option to create a hard link to the current log file.
...
> @@ -351,6 +354,20 @@
> status->pfile_prev = NULL;
> }
> status->nMessCount = 0;
> + if (config->linkfile) {
> + apr_file_remove(config->linkfile, status->pfile);
> + if (config->verbose) {
> + fprintf(stderr,"Linking %s to %s\n", status->filename, config->linkfile);
> + }
> + rv = apr_file_link(status->filename, config->linkfile);
This snippet gets invoked even in the case where opening a new log file
fails, and the old one is truncated and re-used; it will then fail and
break the link, I think. -L is kind of redundant with the more general
-p mode just added - is it worth keeping?
http://svn.apache.org/viewvc?view=revision&revision=1137590
Regards, Joe