httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Albert Lunde <atlu...@panix.com>
Subject [users@httpd] problem with rotatelogs time of day formatting
Date Sat, 01 Oct 2011 03:20:12 GMT
I'm trying to set up piped access and error logs, with "rotatelogs", as 
I'm porting the configuration from Solaris box to a small cluster of 
Linux VMs running RHEL 5.

We're trying to use file name patterns like:

error_log_chnuinfow3.%Y-%m-%d-%H_%M_%S.txt

The date substitutions are working, but the time of day characters come 
out as zeros. An example, and some system information, are quoted below.

I originally was trying to use rotatelogs from the Red Hat httpd RPMs.

But since they are a version of httpd 2.2.3 with back-ported patches,
I then tried building the newest httpd 2.2.21 from source, off to one 
side, with static support binaries.

That's the source of /usr/local/sbin/rotatelogs below. But both versions 
seem to have the same symptom.

I wrote a C program to test the system strftime, and that seemed to work 
as expected, but I suppose the APR library date/time library is what is 
being used, making that somewhat moot.

(I'm also aware of logrotate, and the legacy server just stops and 
starts the server in a nightly job that also rotates the logs in a shell 
script. Others wanted to do use piped log rotation,
I'm trying to make it work.)

Any ideas?

ErrorLog "|/usr/local/sbin/rotatelogs -f 
/var/log/httpd/error_log_chnuinfow3.%Y-%m-%d-%H_%M_%S.txt 86400"

[root@chnuinfow3 conf]# ls -1 /var/log/httpd
access_log_chnuinfow3.2011-09-30-00_00_00.txt
access_log_chnuinfow3.2011-10-01-00_00_00.txt
access_log_skipped_chnuinfow3.2011-09-30-00_00_00.txt
access_log_skipped_chnuinfow3.2011-10-01-00_00_00.txt
error_log_chnuinfow3.2011-09-30-00_00_00.txt
error_log_chnuinfow3.2011-10-01-00_00_00.txt

> [lunde@chnuinfow3 ~]$ rpm -qa | grep httpd
> httpd-devel-2.2.3-45.el5
> httpd-manual-2.2.3-45.el5
> system-config-httpd-1.3.3.3-1.el5
> httpd-2.2.3-45.el5

> [lunde@chnuinfow3 ~]$ uname -a
> Linux chnuinfow3.it.northwestern.edu 2.6.18-238.9.1.el5 #1 SMP Fri Mar 18 12:42:39 EDT
2011 x86_64 x86_64 x86_64 GNU/Linux

> [root@chnuinfow3 conf]# /usr/sbin/httpd -V
> Server version: Apache/2.2.3
> Server built:   Dec  7 2010 11:19:58
> Server's Module Magic Number: 20051115:3
> Server loaded:  APR 1.2.7, APR-Util 1.2.7
> Compiled using: APR 1.2.7, APR-Util 1.2.7
> Architecture:   64-bit
> Server MPM:     Prefork
>   threaded:     no
>     forked:     yes (variable process count)
> Server compiled with....
>  -D APACHE_MPM_DIR="server/mpm/prefork"
>  -D APR_HAS_SENDFILE
>  -D APR_HAS_MMAP
>  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
>  -D APR_USE_SYSVSEM_SERIALIZE
>  -D APR_USE_PTHREAD_SERIALIZE
>  -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
>  -D APR_HAS_OTHER_CHILD
>  -D AP_HAVE_RELIABLE_PIPED_LOGS
>  -D DYNAMIC_MODULE_LIMIT=128
>  -D HTTPD_ROOT="/etc/httpd"
>  -D SUEXEC_BIN="/usr/sbin/suexec"
>  -D DEFAULT_PIDLOG="run/httpd.pid"
>  -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
>  -D DEFAULT_LOCKFILE="logs/accept.lock"
>  -D DEFAULT_ERRORLOG="logs/error_log"
>  -D AP_TYPES_CONFIG_FILE="conf/mime.types"
>  -D SERVER_CONFIG_FILE="conf/httpd.conf"

Test of the system strftime on a similar pattern seems OK:

> [lunde@chnuinfow3 ~]$ cat strftime_test.c
> #include <stdio.h>
> #include <time.h>
> #include <stdlib.h>
> #include <unistd.h>
>
> /* gcc -ansi -Wall strftime_test.c -o strftime_test */
>
> int main (int argc, char** argv)
> {
>
> time_t rawtime;
> struct tm * timeinfo;
> char buffer [80];
> if(argc<2){
>     printf("# Usage: strftime_test <format-string>\n");
>     exit(0);
> }
>
> time ( &rawtime );
> timeinfo = localtime ( &rawtime );
>
> strftime (buffer,80,argv[1],timeinfo);
> puts (buffer);
>
> return 0;
> }
>
>
> [lunde@chnuinfow3 ~]$ ./strftime_test "%Y-%m-%d-%H_%M_%S"
> 2011-09-30-22_02_12
> [lunde@chnuinfow3 ~]$



-- 
     Albert Lunde  albert-lunde@northwestern.edu
                   atlunde@panix.com  (address for personal mail)

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message