Solved

how to rotate apache log files in day.

Posted on 2003-10-31
8
31,227 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
 

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now