Re: rotating apache logs

2006-03-31 Thread Constantine A. Murenin
On 31/03/06, Hiro Protagonist <[EMAIL PROTECTED]> wrote:
> below a small piece of code i found somewhere.
> It works but mayby you wanna fix something.

[piece of code was here]

Why bother with manually compiling some third-party utility, when
rotatelogs(8) is already included with apache, see
http://www.openbsd.org/cgi-bin/man.cgi?query=rotatelogs&sektion=8>.

But most people still use newsyslog(8), AFAIAA.



Re: rotating apache logs

2006-03-31 Thread Frank Garcia
On Friday 31 March 2006 01:05, Peter wrote:
> Hi.  What is the best way to rotate apache logs on OpenBSD?  Ideally I
> would like to create a new one at the beginning of each month.  I
> searched my system for logrotate and could not find it.
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

Have a look at cronolog in the ports tree, I've used that with success.

Frank



Re: rotating apache logs

2006-03-31 Thread Olivier Mehani
On Fri, Mar 31, 2006 at 03:05:25AM -0500, Peter wrote:
> Hi.  What is the best way to rotate apache logs on OpenBSD?  Ideally I
> would like to create a new one at the beginning of each month.  I
> searched my system for logrotate and could not find it.

After discussing that on the list [1], I endend up using cronolog (in the ports)
and am quite satisfied with this. It has this "mothly" feature you want, too.

[1] http://marc.theaimsgroup.com/?l=openbsd-misc&m=113410754403756&w=2

-- 
Olivier Mehani <[EMAIL PROTECTED]>
PGP fingerprint: 3720 A1F7 1367 9FA3 C654 6DFB 6845 4071 E346 2FD1



Re: rotating apache logs

2006-03-31 Thread Hiro Protagonist
Hello Peter

below a small piece of code i found somewhere.
It works but mayby you wanna fix something.

Add in httpd.conf

LogFormat "%h %v %u %t \"%r\" %>s %b \"%{Referer}i\" " combined
.
CustomLog   "| PATH_TO_ROTATELOGSDAY YOUR_LOGFILE" combined


/*
 * Simple program to rotate Apache logs without having to kill the server.
 *
 * Contributed by Ben Laurie <[EMAIL PROTECTED]>
 *
 * 12 Mar 1996
 */

#define BUFSIZE 65536
#define MAX_PATH1024

#include 
#include 
#include 
#include 
#include 



int main (int argc, char **argv)
{
char buf[BUFSIZE], buf2[MAX_PATH];
int nLogFD = -1;
int nRead;
int LogDay=-1;
char *szLogRoot;
 
time_t curtime;
struct tm *curtm;
char curtimestr[20]; 
 
 
 
if (argc != 2) {
fprintf(stderr,
"%s \n\n",
argv[0]);
#ifdef OS2
fprintf(stderr,
"Add this:\n\nTransferLog \"|%s.exe /some/where \"\n\n",
argv[0]);
#else
fprintf(stderr,
"Add this:\n\nTransferLog \"|%s /some/where \"\n\n",
argv[0]);
#endif
fprintf(stderr,
"to httpd.conf. \n\nThe generated name will be
/some/where.mm \n"
"where mmm is the year and month. \n"
"At the end of each month a new log is started.\n");
exit(1);
}

szLogRoot = argv[1];

  for (;;) 
{
nRead = read(0, buf, sizeof buf);
if (nRead == 0)
exit(3);
if (nRead < 0)
if (errno != EINTR)
exit(4);

curtime=time(NULL); 
curtm=localtime(&curtime);
  
if (nLogFD >= 0 && (curtm->tm_mday != LogDay || nRead < 0)) {
close(nLogFD);
nLogFD = -1;
}
if (nLogFD < 0) {
  
  LogDay=curtm->tm_mday;
  sprintf(curtimestr, "%04d%02d%02d", 1900 + curtm->tm_year,
curtm->tm_mon+1, curtm->tm_mday);
  
sprintf(buf2, "%s.%s", szLogRoot, curtimestr);
nLogFD = open(buf2, O_WRONLY | O_CREAT | O_APPEND, 0666);
if (nLogFD < 0) {
perror(buf2);
exit(2);
}
}
if (write(nLogFD, buf, nRead) != nRead) {
perror(buf2);
exit(5);
}
  }
}

-- 
GMX Produkte empfehlen und ganz einfach Geld verdienen!
Satte Provisionen f|r GMX Partner: http://www.gmx.net/de/go/partner



Re: rotating apache logs

2006-03-31 Thread Martin Schröder
On 2006-03-31 09:57:59 +0200, Antoine Jacoutot wrote:
> You can use newyslog for that.

And why does httpd(8) point to rotatelogs(8) instead?

Best
Martin
-- 
http://www.tm.oneiros.de



Re: rotating apache logs

2006-03-31 Thread Antoine Jacoutot
Selon Peter <[EMAIL PROTECTED]>:

> Hi.  What is the best way to rotate apache logs on OpenBSD?  Ideally I
> would like to create a new one at the beginning of each month.  I
> searched my system for logrotate and could not find it.
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

You can use newyslog for that.

ie. in your /etc/newsyslog.conf
/var/www/logs/access_log 644  31*$M1D0   Z "(apachectl stop; (while
`pgrep httpd > /dev/null 2>&1`; do sleep 1; done); apachectl start) >/dev/null"
/var/www/logs/error_log  644  31*$M1D0   Z "(apachectl stop; (while
`pgrep httpd > /dev/null 2>&1`; do sleep 1; done); apachectl start) >/dev/null"

-- 
Antoine



Re: rotating apache logs

2006-03-30 Thread Per-Olov Sjöholm
On Friday 31 March 2006 09.05, you wrote:
> Hi.  What is the best way to rotate apache logs on OpenBSD?  Ideally I
> would like to create a new one at the beginning of each month.  I
> searched my system for logrotate and could not find it.
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com

/etc/newsyslog.conf

Like
/var/www/logs/access_log644  60*$D0   
Z /var/www/logs/httpd.pid SIGUSR1


One log per month sounds like they could grow a bit... I rotate every 
midnight.


/Per-Olov
-- 
GPG keyID: 4DB283CE
GPG fingerprint: 45E8 3D0E DE05 B714 D549 45BC CFB4 BBE9 4DB2 83CE



rotating apache logs

2006-03-30 Thread Peter
Hi.  What is the best way to rotate apache logs on OpenBSD?  Ideally I
would like to create a new one at the beginning of each month.  I
searched my system for logrotate and could not find it.
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com