Solved

how to rotate apache log files in day.

Posted on 2003-10-31
8
31,254 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

772 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