multiple instances of rotatelogs writing to the same file

Hello all,

I have several virtual hosts piping their log files to rotatelogs. For various reasons I have two virtual hosts piping to the same log file:
<VirtualHost 1.2.3.4>
CustomLog "|/usr/sbin/rotatelogs /logs/site/access_log.%U-%Y 604800" combined
</VirtualHost>
<VirtualHost 1.2.3.5>
CustomLog "|/usr/sbin/rotatelogs /logs/site/access_log.%U-%Y 604800" combined
</VirtualHost>

In this case there are understandably two processes of rotatelogs running:
..../usr/sbin/rotatelogs /logs/access_log.%U-%Y 604800
..../usr/sbin/rotatelogs /logs/access_log.%U-%Y 604800

Is this setup going to cause any unintended consequences? I'm thinking it might run into a couple of problems but the man page and the web doesn't have a real answer. Does apache and rotatelogs handle cleanly the rotation because there are two processes trying to do the rotation? Is there a file locking problem with rotatelogs whereby one process won't be able to write to the log file?




------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
stupidmail4me [ Di, 09 März 2010 17:03 ] [ ID #2034448 ]

Re: multiple instances of rotatelogs writing to thesame file

On 2010-03-09 at 11:03, stupidmail4me <stupidmail4me [at] yahoo.com> wrote:

> Hello all,
>
> I have several virtual hosts piping their log files to rotatelogs. For various reasons I have two virtual hosts piping to the same log file:
> <VirtualHost 1.2.3.4>
> CustomLog "|/usr/sbin/rotatelogs /logs/site/access_log.%U-%Y 604800" combined
> </VirtualHost>
> <VirtualHost 1.2.3.5>
> CustomLog "|/usr/sbin/rotatelogs /logs/site/access_log.%U-%Y 604800" combined
> </VirtualHost>
>
> In this case there are understandably two processes of rotatelogs running:
> .../usr/sbin/rotatelogs /logs/access_log.%U-%Y 604800
> .../usr/sbin/rotatelogs /logs/access_log.%U-%Y 604800
>
> Is this setup going to cause any unintended consequences?

Yes.

> I'm thinking it might run into a couple of problems but the man page
> and the web doesn't have a real answer.

Well, if the doc tried to list all the things people might try that
wouldn't work, it would get awfully long. Nevertheless, if you look at
<http://httpd.apache.org/docs/2.2/en/stopping.html> you'll see this:

Multiple running instances of rotatelogs attempting to rotate the
same logfiles at the same time may destroy each other's logfiles.

Dan

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Dan Poirier [ Mi, 10 März 2010 14:22 ] [ ID #2034518 ]

Re: multiple instances of rotatelogs writing to the

On Tue, Mar 9, 2010 at 9:33 PM, stupidmail4me <stupidmail4me [at] yahoo.com> wro=
te:
>
> Hello all,
>
> I have several virtual hosts piping their log files to rotatelogs. For va=
rious reasons I have two virtual hosts piping to the same log file:
> <VirtualHost 1.2.3.4>
> CustomLog "|/usr/sbin/rotatelogs /logs/site/access_log.%U-%Y 604800" comb=
ined
> </VirtualHost>
> <VirtualHost 1.2.3.5>
> CustomLog "|/usr/sbin/rotatelogs /logs/site/access_log.%U-%Y 604800" comb=
ined
> </VirtualHost>
>
> In this case there are understandably two processes of rotatelogs running=
:
> .../usr/sbin/rotatelogs /logs/access_log.%U-%Y 604800
> .../usr/sbin/rotatelogs /logs/access_log.%U-%Y 604800
>
> Is this setup going to cause any unintended consequences? I'm thinking it=
might run into a couple of problems but the man page and the web doesn't h=
ave a real answer. Does apache and rotatelogs handle cleanly the rotation b=
ecause there are two processes trying to do the rotation? Is there a file l=
ocking problem with rotatelogs whereby one process won't be able to write t=
o the log file?
>
>
>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project=
..
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
> =A0 " =A0 from the digest: users-digest-unsubscribe [at] httpd.apache.org
> For additional commands, e-mail: users-help [at] httpd.apache.org
>

Use standard logging methods, and run logrotate regularly using cron.
I do it this way. With logrotate you can also mail the owner(s) of the
virtualhosts a compressed version of the log for analysis and delete
it from your server.

--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Nilesh Govindrajan [ Mi, 10 März 2010 14:39 ] [ ID #2034519 ]
Webserver » gmane.comp.apache.user » multiple instances of rotatelogs writing to the same file

Vorheriges Thema: myriads of access to unknown pages on my server bring my serverdown (DOS?)
Nächstes Thema: mpm_worker and mod_ssl: requirements to OpenSSL