Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

how to rotate apache log files in day.

Posted on 2003-10-31
8
31,260 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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). #…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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