Solved

Apache Access Log File Reset

Posted on 2011-02-10
5
300 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

775 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