Solved

Apache Access Log File Reset

Posted on 2011-02-10
5
305 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
[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
  • 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
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 …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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