[JDEV] patch: jabberd-1.4 logfile rotation
Ralph Siemsen
ralphs at blueairnetworks.com
Tue Oct 22 12:18:40 CDT 2002
A minor update for anyone who is using this patch... writing the logs in
synchronous mode really slows things down... you just want the regular
buffered stdout, and unbuffered stderr, so remove the O_SYNC from the
open() call in this section of the patch:
> +
> +/* Redirect stdout/stderr to a logfile instead */
> +void redirect_logs(char *filename)
> +{
> + /* Try to open the specified logfile for writing */
> + int fd;
> + fd = open(logfilename, O_WRONLY|O_CREAT|O_APPEND|O_SYNC, 0640);
> + if (fd == -1) {
> + printf("Fatal: could not open logfile %s\n", logfilename);
> + exit(0);
> + }
> + /* Re-open the stdout/stderr streams on the logfile instead */
> + dup2(fd, STDOUT_FILENO);
> + dup2(fd, STDERR_FILENO);
> + close(fd);
> +}
More information about the JDev
mailing list