Solved

how to rotate apache log files in day.

Posted on 2003-10-31
8
31,270 Views
Last Modified: 2012-06-27
I tried to add

TransferLog "|rotatelogs /logs/access.log 86400"

to http.conf file.But the http service can not startup.I use windows 2000 advanced server & IBM http server (Apache 2.0.42.2).Did anyone meet this problem before?

Any advise will be appreciated.

yunfeng
0
Comment
Question by:yunfengex
8 Comments
 
LVL 8

Expert Comment

by:heskyttberg
ID: 9670148
Hi!

You cannot do it like that, read Apache manual on LogFormat, TransferLog and related.

TransferLog:
This directive has exactly the same arguments and effect as the CustomLog  directive, with the exception that it does not allow the log format to be specified explicitly or for conditional logging of requests. Instead, the log format is determined by the most recently specified LogFormat directive which does not define a nickname. Common Log Format is used if no other format has been specified.
-----

You should do something like this:
CustomLog "|X:/apache/apache2/bin/rotatelogs.exe
X:/www_logs/www.server.de_%y%m%d.log 86400" combined env=!dontlog

Or use some sort of third party software to do logrotate.
In windows I don't think you need to restart or reaload apache service.

This might be possible for you to do though it will require you to install perl and maybe a few cpan modules.
http://www.serverwatch.com/tutorials/article.php/10825_1129851_2

Try the customLog above first, change drives and paths to suit your environment.

Regards
/Hasse
0
 

Author Comment

by:yunfengex
ID: 9675738
I tried the customlog but still failed.What I added is
CustomLog "|D:/IBMHTT~1.0/bin/rotatelogs D:/IBMHTT~1.0/logs/esdzc-access.log 86400".
I think it conform to directive grammar.

For second solution,frankly,I don't hope to use perl because I have no experience on perl.

Yunfeng
0
 

Author Comment

by:yunfengex
ID: 9676192
I tried to add
CustomLog "|D:/IBM HTTP Server 2.0/bin/rotatelogs.exe D:/IBM HTTP Server 2.0/logs/esdzc-access.log 86400" common

And get the error message from apache console:
unable to start piped log program 'D:/IBM HTTP Server 2.0/bin/rotatelogs.exe D:/
IBM HTTP Server 2.0/logs/esdzc-access.log 86400': 拒绝访问。
Unable to open logs
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:yunfengex
ID: 9676209
tried to add
CustomLog "|D:/IBM HTTP Server 2.0/bin/rotatelogs.exe D:/IBM HTTP Server 2.0/logs/esdzc-access.log 86400" common

And get the error message from apache console:
unable to start piped log program 'D:/IBM HTTP Server 2.0/bin/rotatelogs.exe D:/
IBM HTTP Server 2.0/logs/esdzc-access.log 86400': Access denied.
Unable to open logs
0
 
LVL 8

Accepted Solution

by:
heskyttberg earned 125 total points
ID: 9676896
Hi!

Ok, make sure the user running Apache have write permissions to D:/IBM HTTP Server 2.0/logs/.
Make sure that this file exists: D:/IBM HTTP Server 2.0/bin/rotatelogs.exe
Also check permissons on this file.

If all is ok, do the following. Create a dir on d: called weblog.
Make sure apache user can write here. Copy rotatelogs.exe to d:\weblog.

And change the CustomLog to look like this:
CustomLog "|D:/weblog/rotatelogs.exe D:/weblog/esdzc-access.log 86400" common

If this works then there is a issue with spaces in path name for CustomLog directive.

Make sure Apache user have right to execute the rotatelogs exec.

Regards
/Hasse

0
 

Author Comment

by:yunfengex
ID: 9711820
Hasse,

To me surprised,apache seems only to recognze one level directory from root.That is , if I use CustomLog "|D:/weblog/rotatelogs.exe D:/weblog/esdzc-access.log 86400" common,OK;but if I use
CustomLog "|D:/weblog/www/rotatelogs.exe D:/weblog/esdzc-access.log 86400" common,it failed to start.Anyway,the rotatelogs works now.Thank you very much!

Yunfeng



0
 

Expert Comment

by:JVirumbi
ID: 11158479
Hi,

We are running Apache 1.3.12.
In order to user rotatelogs.exe, I added this line in the httpd.cong commenting the previuos line:

CustomLog "|D:/rw70/RWWebdriver/apache/bin/rotatelogs D:/rw70/RWWebdriver/log/webdriver/apache/rwweb_access.log 86400" common

But apache fails to start.
I have the rotatelogs.exe in the right place.
I have the folder structure created for the log file.
The error as follows:
ap_spawn_child: Bad file descriptor
Couldn't fork child for piped log process

But If I download from apache site, version 1.3.29, roattelog is working.

So, I have replaced old Apache.exe and ApacheCore.dll with new ones taken from version 1.3.29 in my APACHE_HOME folder.
Also added newly Win9xConHook.dll file to the HOME.

It's working and seems no problem.

is that OK ??

or is there any tutorial to do a formal upgrade
 If so plz help me to get it.

Thanks & Rgds  
0
 

Expert Comment

by:Jon8RFC
ID: 14675930
Thank you very much, heskyttberg!
I've had a very rough time for the past hour, and your solution did the trick.


However, I still have a question concerning my log format.  Here is my directive:
CustomLog "|C:/logs/rotatelogs.exe C:/logs/access/access_%Y-%m-%d--%H-%M-%S.log 86400 -360" combined

The only things that fails to work are the %H %M %S variables.  My log file is saved as "access_2005-08-15--00-00-00.log", and I don't understand why or how to fix the double zeros.
0

Featured Post

Save the day with this special offer from ATEN!

Save 30% on the CV211 using promo code EXPERTS30 now through April 30th. The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to analyze web traffic logs 10 118
php54-php-imap for redhat enterprise linux 7.2 1 107
ports for sccm 2012 1 100
HTTPS for signup & login - HTTP for all other pages 10 46
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question