RE: Apache log rotation question...
I am using cronolog to handle the logging end of apache. Cronolog basically takes care of the logging for apache, allowing you much more flexibility with the logging options. Assuming.. 1. You have cronolog installed 2. /path/to/your/logs/vhost1/ is a valid path A sample Apache config line would read (main or virtual host context): ErrorLog |cronolog /path/to/your/logs/vhost1/%Y%m%d_error.log CustomLog |cronolog /path/to/your/logs/vhost1/%Y%m%d_access.log combined I this example, you will generate logs with the names 20061108_error.log and 20061108_access.log respectively and each day (midnight server time) cronolog will auto-gen new ones as soon as apache sends it something to log. Using this method, cronolog is doing the logging for Apache specifically the way when where and how you want it negating the need for further scripting and manipulating of the logs afterward. Hope that helps. Steve -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Philip Hallstrom Sent: Friday, November 03, 2006 3:21 PM To: Curtis Jewell Cc: [EMAIL PROTECTED] Subject: Re: Apache log rotation question... I'm wondering if I can safely use newsyslog with a newsyslog.conf with these lines in it: I don't know the answer to your question, but you might look at cronolog... http://www.freebsd.org/cgi/url.cgi?ports/sysutils/cronolog/pkg-descr /var/log/httpd/access_log/*644 1 *$W0D0 G /var/log/httpd/error_log/* 644 1 *$W0D0 G /var/log/httpd/ssl_request.log 644 1 *$W0D0 /var/log/httpd/error.log 644 1 *$W0D0 # After this point should be one line... /var/log/httpd/access.log 644 1 *$W0D0 - /var/run/httpd.pid 30 or if not, what should I do instead? (I have 4 separate vhosts that keep their access logs in the first 2 directories) For the record, I want weekly rotation on Sundays at midnight (I assume JST, since I have my time set to local time, which is JST [GMT+9, no DST]), keeping 1 log, (the way I read the fine manuals, I'll have to have a cron job bzip2 it up later and move it aside if I want to keep more and/or compress them) permissions 644 with the owner being root:wheel, no size check, and the last part of the last line should send a SIGUSR1 (30) signal to Apache, which should do the equivalent of a 'apachectl -k graceful' per http://httpd.apache.org/docs/2.2/stopping.html. My question really is, does newsyslog send the signal at the right time [after the rotation is done, per http://httpd.apache.org/docs/2.2/logs.html#rotation] and does it do the lines in order???) - --Curtis - -- Curtis Jewell [EMAIL PROTECTED] Killed enough? ... Yes, Your Highness, I think we all have. --John Patrick Ryan (from 'The Sum Of All Fears', Tom Clancy) [I use Pine, which deliberately does not display colors and pictures in HTML mail] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFS6ByvCi+150VKIMRAs6PAKDOOvnARxXKUTY5dvNrob3gl9+aZACdG+P+ Uz0GrVe1p5MNuRPwiTbBXxY= =lTB2 -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Apache log rotation question...
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm wondering if I can safely use newsyslog with a newsyslog.conf with these lines in it: /var/log/httpd/access_log/*644 1 *$W0D0 G /var/log/httpd/error_log/* 644 1 *$W0D0 G /var/log/httpd/ssl_request.log 644 1 *$W0D0 /var/log/httpd/error.log 644 1 *$W0D0 # After this point should be one line... /var/log/httpd/access.log 644 1 *$W0D0 - /var/run/httpd.pid 30 or if not, what should I do instead? (I have 4 separate vhosts that keep their access logs in the first 2 directories) For the record, I want weekly rotation on Sundays at midnight (I assume JST, since I have my time set to local time, which is JST [GMT+9, no DST]), keeping 1 log, (the way I read the fine manuals, I'll have to have a cron job bzip2 it up later and move it aside if I want to keep more and/or compress them) permissions 644 with the owner being root:wheel, no size check, and the last part of the last line should send a SIGUSR1 (30) signal to Apache, which should do the equivalent of a 'apachectl -k graceful' per http://httpd.apache.org/docs/2.2/stopping.html. My question really is, does newsyslog send the signal at the right time [after the rotation is done, per http://httpd.apache.org/docs/2.2/logs.html#rotation] and does it do the lines in order???) - --Curtis - -- Curtis Jewell [EMAIL PROTECTED] Killed enough? ... Yes, Your Highness, I think we all have. --John Patrick Ryan (from 'The Sum Of All Fears', Tom Clancy) [I use Pine, which deliberately does not display colors and pictures in HTML mail] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFS6ByvCi+150VKIMRAs6PAKDOOvnARxXKUTY5dvNrob3gl9+aZACdG+P+ Uz0GrVe1p5MNuRPwiTbBXxY= =lTB2 -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache log rotation question...
I'm wondering if I can safely use newsyslog with a newsyslog.conf with these lines in it: I don't know the answer to your question, but you might look at cronolog... http://www.freebsd.org/cgi/url.cgi?ports/sysutils/cronolog/pkg-descr /var/log/httpd/access_log/*644 1 *$W0D0 G /var/log/httpd/error_log/* 644 1 *$W0D0 G /var/log/httpd/ssl_request.log 644 1 *$W0D0 /var/log/httpd/error.log 644 1 *$W0D0 # After this point should be one line... /var/log/httpd/access.log 644 1 *$W0D0 - /var/run/httpd.pid 30 or if not, what should I do instead? (I have 4 separate vhosts that keep their access logs in the first 2 directories) For the record, I want weekly rotation on Sundays at midnight (I assume JST, since I have my time set to local time, which is JST [GMT+9, no DST]), keeping 1 log, (the way I read the fine manuals, I'll have to have a cron job bzip2 it up later and move it aside if I want to keep more and/or compress them) permissions 644 with the owner being root:wheel, no size check, and the last part of the last line should send a SIGUSR1 (30) signal to Apache, which should do the equivalent of a 'apachectl -k graceful' per http://httpd.apache.org/docs/2.2/stopping.html. My question really is, does newsyslog send the signal at the right time [after the rotation is done, per http://httpd.apache.org/docs/2.2/logs.html#rotation] and does it do the lines in order???) - --Curtis - -- Curtis Jewell [EMAIL PROTECTED] Killed enough? ... Yes, Your Highness, I think we all have. --John Patrick Ryan (from 'The Sum Of All Fears', Tom Clancy) [I use Pine, which deliberately does not display colors and pictures in HTML mail] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFS6ByvCi+150VKIMRAs6PAKDOOvnARxXKUTY5dvNrob3gl9+aZACdG+P+ Uz0GrVe1p5MNuRPwiTbBXxY= =lTB2 -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache log rotation question...
At 5:02 AM +0900 11/4/06, Curtis Jewell wrote: My question really is, does newsyslog send the signal at the right time [after the rotation is done, per http://httpd.apache.org/docs/2.2/logs.html#rotation ] and does it do the lines in order???) You can see what it will do by running newsyslog with the options of `-nv' to see what it would do, without it doing anything. Eg: newsyslog -nvvf /tmp/newsyslog.conf In your case you'd first want to use a different time in the entries you've added, just so the time to rotate is this hour (ie, whatever hour it is that you're running the program...). So, do that, and then run: newsyslog -nvf /tmp/newsyslog.conf You'll see that it first rotates all files that should be rotated for this run, then sends all signals it is supposed to send, then waits 10 seconds or so, and finally it compresses any of the old-files that it should compress. If you have a set of files which are all written to by a single process, then you should add the '/var/run/httpd.pid' to the newsyslog entry for *every* file that process writes to. The way newsyslog handles things, it will only send a single signal to any given process id, even if several different files from that process were rotated. Since all files have been rotated before the process is signalled, the process will only need to be signalled one time. Try the run with '-nv' to see exactly how it would work. -- Garance Alistair Drosehn = [EMAIL PROTECTED] Senior Systems Programmer or [EMAIL PROTECTED] Rensselaer Polytechnic Institute; Troy, NY; USA ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Apache log rotation
Hi, If one install Apache from the ports, the logs go in /var/log, namely in: ssl_request_log httpd-access.log ssl_engine_log httpd-error.log Is there a clean way to rotate these logs a la newsyslog? I know I can use newsyslog to rotate them, but then how to notify Apache to use the new log files? I don't expect a signal HUP sent to httpd would be enough. Best regards, Olivier ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache log rotation
On Wed, Oct 19, 2005 at 03:54:15PM +0700, Olivier Nicole wrote: [...] Is there a clean way to rotate these logs a la newsyslog? I know I can use newsyslog to rotate them, but then how to notify Apache to use the new log files? I don't expect a signal HUP sent to httpd would be enough. It is. All you need to make sure that only the last line has the HUP to the httpd, as newsyslog works from top to bottom. eg: /var/log/apache/httpd-access.log644 12*$M1D0 BN /var/log/apache/httpd-error.log 644 12*$M1D0 B /var/run/httpd.pid Cheers. -- Jonathan Chen [EMAIL PROTECTED] -- Lots of folks confuse bad management with destiny - Kin Hubbard ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache log rotation
Sending HUP is fine. Olivier Nicole wrote: Hi, If one install Apache from the ports, the logs go in /var/log, namely in: ssl_request_log httpd-access.log ssl_engine_log httpd-error.log Is there a clean way to rotate these logs a la newsyslog? I know I can use newsyslog to rotate them, but then how to notify Apache to use the new log files? I don't expect a signal HUP sent to httpd would be enough. Best regards, Olivier ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache log rotation
On October 19, 2005 04:54 am, Olivier Nicole wrote: Hi, If one install Apache from the ports, the logs go in /var/log, namely in: ssl_request_log httpd-access.log ssl_engine_log httpd-error.log Is there a clean way to rotate these logs a la newsyslog? I know I can use newsyslog to rotate them, but then how to notify Apache to use the new log files? I don't expect a signal HUP sent to httpd would be enough. Best regards, Olivier I use ports/sysutils/cronolog/ which does a great job transparently. Nicolas. -- FreeBSD 7.0-CURRENT #0: Sat Oct 15 12:09:14 EDT 2005 [EMAIL PROTECTED]:/usr/obj/usr/src/sys/CLK01A PGP? : http://www.clkroot.net/security/nb_root.asc pgpHDhINjG4hf.pgp Description: PGP signature
Re: Apache log rotation
At 10:00 PM +1300 10/19/05, Jonathan Chen wrote: On Wed, Oct 19, 2005 at 03:54:15PM +0700, Olivier Nicole wrote: [...] Is there a clean way to rotate these logs a la newsyslog? I know I can use newsyslog to rotate them, but then how to notify Apache to use the new log files? I don't expect a signal HUP sent to httpd would be enough. It is. All you need to make sure that only the last line has the HUP to the httpd, as newsyslog works from top to bottom. eg: /var/log/apache/httpd-access.log644 12*$M1D0 BN /var/log/apache/httpd-error.log 644 12*$M1D0 B /var/run/httpd.pid *ALL* lines should include the HUP request. In the above example you are rotating at an explicit time, but many people also depend on the size of the file. If they do depend on the size of the file, then the above trick will not always work. It used to be that you had to do some trick like the above to avoid sending multiple HUP's to the process. I changed that so that the same process can be specified on many log files, and newsyslog will first rotate all files which need rotating, and then send a single signal to the process. So now there is no problem caused by specifying the same process on multiple entries in newsyslog.conf . -- Garance Alistair Drosehn = [EMAIL PROTECTED] Senior Systems Programmer or [EMAIL PROTECTED] Rensselaer Polytechnic Institute; Troy, NY; USA ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Apache Log Rotation Statistics
Hi, What I am looking for here is some advice on what will be the best ways to acomplish what I have in mind. What I hope to acomplish follows, so any thoughts on how to do it, or if it is complex or impossible would be very helpful. I have Apache 2.x running with a collection of virtual hosts, each logging to their own access.log file. I want to offer log statistics to all of my virtual hosts on an individual basis. I want them to be able to go to say log.theirdomain.com or www.theirdomain.com/log and be able to view the statistics for their site from day x, week y, month z, year k, whatever. Ideally these logs will be stored compressed and in a directory specific to their virtual domain. I am sorry if I am not explaining this 100%, please feel free to ask me to clarify myself. Thanks much, Gadi Golan ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache Log Rotation Statistics
On Jan 12 at 18:03, Gadi Golan wondered aloud: I have Apache 2.x running with a collection of virtual hosts, each logging to their own access.log file. I want to offer log statistics to all of my virtual hosts on an individual basis. I want them to be able to go to say log.theirdomain.com or www.theirdomain.com/log and be able to view the statistics for their site from day x, week y, month z, year k, whatever. Ideally these logs will be stored compressed and in a directory specific to their virtual domain. Well, just some thoughts straight out of the box: Since you have individual logs for each virtual site, logrotate should do much of what you're aiming for I believe. If you don't already have it installed it's in; /usr/ports/sysutils/logrotate There's a ton of highly useful stuff in the logrotate man pages, although I use few of the possibilities myself, and really when I think about it, ought to use more. Here's something that is apropos of your situation: (from man logrotate) The file you're immediately concerned with in the beginning BTW is: /etc/logrotate.conf CONFIGURATION FILE logrotate reads everything about the log files it should be handling from the series of configuration files specified on the command line. Each configuration file can set global options (local definitions over-ride global ones, and later definitions override earlier ones) and specify a logfile to rotate. A simple configuration file looks like this: # sample logrotate configuration file compress /var/log/messages { rotate 5 weekly postrotate /sbin/killall -HUP syslogd endscript } /var/log/httpd/access.log /var/log/httpd/error.log { rotate 5 mail [EMAIL PROTECTED] size=100k sharedscripts postrotate /sbin/killall -HUP httpd endscript } /var/log/news/news.crit { monthly rotate 2 olddir /var/log/news/old missingok postrotate kill -HUP `cat /var/run/inn.pid` endscript nocompress As you can see, there is much which you can use here. Logrotate is a powerful utility and may be perfect for your purposes. Good luck HTH, -Colin ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache Log Rotation Statistics
On Jan 12, 2005, at 5:03 PM, Gadi Golan wrote: Hi, What I am looking for here is some advice on what will be the best ways to acomplish what I have in mind. What I hope to acomplish follows, so any thoughts on how to do it, or if it is complex or impossible would be very helpful. I have Apache 2.x running with a collection of virtual hosts, each logging to their own access.log file. I want to offer log statistics to all of my virtual hosts on an individual basis. I want them to be able to go to say log.theirdomain.com or www.theirdomain.com/log and be able to view the statistics for their site from day x, week y, month z, year k, whatever. Ideally these logs will be stored compressed and in a directory specific to their virtual domain. I am sorry if I am not explaining this 100%, please feel free to ask me to clarify myself. Thanks much, Gadi Golan I would recommend webalizer in the ports. If you read through the documentation, you specify the logfile and destination of each run, so you could have multiple configurations and cron jobs to compute the stats for you. Let me know if you have any more questions. IIRC, you can see an example at www.webalizer.org. HTH ___ Eric F Crist I am so smart, S.M.R.T! Secure Computing Networks -Homer J Simpson PGP.sig Description: This is a digitally signed message part
Re: Apache log rotation problems
On 8 July, 2004, at 22:46 (-0400) Bill Moran [EMAIL PROTECTED] wrote: Graham North [EMAIL PROTECTED] wrote: Hello all: There has to be a simple fix to this problem - I am using newsyslog and cron to rotate my Apache logfiles.They get rotated and Apache keeps working however after a log rotation takes place Apache will not longer log my accesses. It does continue to serve pages but I need to do an apachectl restart in order for it to continue logging properly. newsyslog.conf and crontab files are attached for reference. You need to restart apache to get it to start logging to a new file. Luckily, newsyslog can do this for you. With the default Apache install, Apache will log its PID to a file when it starts, just add this filename (/var/run/httpd.pid) to the end of each newsyslog entry that rotates an apache file, and newsyslog will automatically send a HUP signal to that PID when the log file is rotated See the man pages for newsyslog for more detailed info. Another option is to use the sysutils/cronolog port. Configure it in httpd.conf, with ErrorLog and CustomLog directives similar to the following: ErrorLog |/usr/local/sbin/cronolog --symlink=/var/log/httpd/error_log /var/log/httpd/error_log_%y%m%d CustomLog |/usr/local/sbin/cronolog --symlink=/var/log/httpd/access_log /var/log/httpd/access_log_%y%m%d combined cronolog will rotate logs automatically each day. From the cronlog man page: Before writing a message cronolog checks the time to see whether the current log file is still valid and if not it closes the current file, expands the template using the current date and time to generate a new file name, opens the new file (creating missing directories on the path of the new log file as needed unless the program is compiled with -DDONT_CREATE_SUBDIRS) and calculates the time at which the new file will become invalid. See the man page for further details. I've been using it for awhile on my public web server. Seems to work just fine. -Brian Brian Clapper, http://www.clapper.org/bmc/ Scott's first Law: No matter what goes wrong, it will probably look right. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Apache log rotation problems
Graham North [EMAIL PROTECTED] wrote: Hello all: There has to be a simple fix to this problem - I am using newsyslog and cron to rotate my Apache logfiles.They get rotated and Apache keeps working however after a log rotation takes place Apache will not longer log my accesses. It does continue to serve pages but I need to do an apachectl restart in order for it to continue logging properly. newsyslog.conf and crontab files are attached for reference. You need to restart apache to get it to start logging to a new file. Luckily, newsyslog can do this for you. With the default Apache install, Apache will log its PID to a file when it starts, just add this filename (/var/run/httpd.pid) to the end of each newsyslog entry that rotates an apache file, and newsyslog will automatically send a HUP signal to that PID when the log file is rotated See the man pages for newsyslog for more detailed info. -- Bill Moran Potential Technologies http://www.potentialtech.com ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
RE: Apache log rotation problems
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Graham North Sent: Thursday, July 08, 2004 9:32 PM To: [EMAIL PROTECTED]; Matthew Seaman Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; Matthew Seaman Subject: Apache log rotation problems Hello all: There has to be a simple fix to this problem - I am using newsyslog and cron to rotate my Apache logfiles.They get rotated and Apache keeps working however after a log rotation takes place Apache will not longer log my accesses. It does continue to serve pages but I need to do an apachectl restart in order for it to continue logging properly. newsyslog.conf and crontab files are attached for reference. Any help and suggestions greatly appreciated. Regards, Graham/ Hello, Try something like this: newsyslog.conf: /var/log/httpd-access.log 644 2 * @T00 B /var/run/httpd.pid 30 More info: http://www.freebsddiary.org/rotatelogs.php Best regards, Andras Kende http://www.kende.com ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]