Solved

Log Rotation

Posted on 2002-05-02
8
339 Views
Last Modified: 2012-05-04
Hi,

I know Apache has a capability of rotates the log files periodically by moving or deleting the existing logs.  But the bad thing is the server need to restart after moving or deleting the old logs in order for the new logs to be opened.

This is what i want to do:
Create 4 folders: let say Week1, Week2, Week3, Week4.  For this month, log all files into these folders based on the appropriate week.  Next month, it should goes back and re-use these folders to log the new files.  When it logs, the old file should be deleted or at least emptied or overwrite the old files, instead of append to the old files.  The reason for this is to save space, the log files grow big really fast and i don't have time to go in and empty it out.  Is there a way to do this?  Any third party software that does that?  I know cronolog.org has one, but not exactly what i wanted though.  

Please help!

TommyN14
0
Comment
Question by:TommyN14
[X]
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
  • 5
  • 3
8 Comments
 
LVL 15

Expert Comment

by:samri
ID: 6987761
Tommy,

There is an existing PAQ on the subject:
http://www.experts-exchange.com/apache/Q.20256453.html

http://httpd.apache.org/docs/logs.html
Look for this section - "Piped Logs"

Based on your requirement, I would suggest that you go for the piped-log approach.  The drawback is that you need to do some coding.

0
 
LVL 15

Expert Comment

by:samri
ID: 6987779
I tried to look for way to split up the logfile by weeks.  Personally it would be a bit difficult since one month will have 5 weeks, with the 1st and last week will have less days.

Perhaps you might want to look at other grouping method - months probably, will be a bit straightforward, and within each month, have a daily log.

just a recommendation.
0
 
LVL 15

Expert Comment

by:samri
ID: 6987840
Another option is to use "logrotate"

On RH the package should come in the standard distribution.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 1

Author Comment

by:TommyN14
ID: 6988641
Samri,

I've read those site be4 i posted the question.  I guess i wasn't sure exactly what it does.  Will Pipe Logs does what i need?  What i need is to have just a few folders and have the program logs to these folder rotationally.  And when it complete one cycle, it goes back and reuse those old log files and overwrite them.  This way we will only have to use some amount of spaces on the hard drive.  

I know cronolog is a more flexible one, but it only does creating folder after folder (or file after file).  This way, i have to go back and manually delete old files to clear out space.

TommyN14
0
 
LVL 15

Expert Comment

by:samri
ID: 6990126
Tommy,
The problem with those recommendation is that for the logfile rotation to work, the apache needs to be restarted.

I haven't personally tried cronolog.  By your description, it should not be that difficult to write a small script to manipulate those files, and move them the their respective weekly directories.
0
 
LVL 1

Author Comment

by:TommyN14
ID: 6991325
Samri,

Could you please provide some codes?

TommyN14
0
 
LVL 15

Accepted Solution

by:
samri earned 100 total points
ID: 6991385
Tommy,

I might be able to get one, in a few days (lost my RH box - no Linux is allowed in our office - *sigh*).

If you could identify which method you feels like using, I would be able to help (I'm not very good at coding - but should be able to get the basic).

Basically, any option, Apache would have to be restarted.  Let;s pick the simplest method - stick to the basic (since some Unix doesn't come with logrotate, or cronolog.

The concept would be;

1. Run the script from cron at midnight.  And the script should;

a. rename current logfile to whatever format we want.
b. restart apache (upon restart, apache should create a new logfile).
c. work on the renamed-log file. We can archive it, delete it :), or anything.
 
0
 
LVL 1

Author Comment

by:TommyN14
ID: 6991772
Samri,

You know what, forget it.  I'm just gonna use cronolog and write my own java app to delete the old files instead. I'm working on my java app, and i'm almost done.  Eventhough, you answers are not what i expected, but you can have all the points.  Thanks for your time in trying to help.

TommyN14
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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 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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses

623 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