Solved

Apache Access Log File Reset

Posted on 2011-02-10
5
298 Views
Last Modified: 2012-05-11
We have Apache v2.2 running on a Windows Server 2008 64 bit that has an access.log file that is over 6gb in size.  I want to know (in detail) how to reset the log file as well as any suggestions on how to set up a maintenance plan or configuration settings to avoid this in the future.  I am not overly proficient in Apache so please be as detailed as possible.  Thank you very much for your help.
0
Comment
Question by:mjfox1725
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:DangerousJeff
Comment Utility
Wow, 6GB log file!
OK, so you will likely want to use a tool like rotatelogs or cronolog to automatically split your log file as it gets larger.
In your Apache configuration file (httpd.conf or apache.conf ?) you'll need to find the line that mentions your access.log file that is huge.

*Before making any changes to this config, make a backup copy of this file*

For example (don't copy this litterally) you might have the following currently:
CustomLog log/access.log combined 

Open in new window


You would want to change that to (untested):
CustomLog "||C:/path/to/cronolog.exe log/%Y-%m-%d-access.log combined"

Open in new window


Take special notes of the quote marks ", the pipes |, the %Y%m%d bit to date the logs and pointing to the specific path of your log rotation tool. By default this will create a new log every day.

You should then run the check configuration tool, which should be in the start menu and then do a graceful restart of Apache for it to load this new configuration.

You can find out more here:
http://cronolog.org/usage.html
http://httpd.apache.org/docs/current/logs.html#piped

rotatelogs should be in your apache directory somewhere, or cronolog can be downloaded from:
http://cronolog.org/download/index.html
0
 

Author Comment

by:mjfox1725
Comment Utility
This is what I have presently:
<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "logs/access.log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access.log" combined
</IfModule>

Open in new window

0
 
LVL 4

Expert Comment

by:DangerousJeff
Comment Utility
Yeah, so depending on where you have put your log rotation tool, change line 21 to *something* like:

CustomLog "||C:/path/to/cronolog.exe logs/%Y-%m-%d-access.log common"

Open in new window

0
 

Author Comment

by:mjfox1725
Comment Utility
Do I just download cronolog and copy it to the server as there does not look like there is any sort of installation procedure.  Also that application looks like it si from 5+ years ago on their website.  Please confirm when you get a chance.
0
 
LVL 4

Accepted Solution

by:
DangerousJeff earned 500 total points
Comment Utility
Yeah its just a basic tool, you could use rotatelogs.exe instead if you prefer, it *should* be in your apache directory somewhere.
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Suggested Solutions

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

9 Experts available now in Live!

Get 1:1 Help Now