Solved

Apache Access Log File Reset

Posted on 2011-02-10
5
299 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
ID: 34865082
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
ID: 34865337
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
ID: 34865605
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
ID: 34866020
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
ID: 34866556
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

861 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

29 Experts available now in Live!

Get 1:1 Help Now