The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Raw Server Logs

Discussion in 'General Discussion' started by Freexxxmen, Jun 11, 2003.

  1. Freexxxmen

    Freexxxmen Member

    Joined:
    Jun 11, 2003
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Where are they located on the server itself... I have a client wanting to create a Symlink to this folder so they can have WebTrends analize the raw logs automatically and WebTrends doesnt support wilcards or datemarcos on a htttp:// due to the fact it cant do a directory listing as easily asit can with ftp://

    cPanel.net Support Ticket Number:
     
  2. KenMaier

    KenMaier Member

    Joined:
    Nov 5, 2002
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Try /usr/local/apache/domlogs/

    -ken

    cPanel.net Support Ticket Number:
     
  3. Freexxxmen

    Freexxxmen Member

    Joined:
    Jun 11, 2003
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    this works for if i want the entire logs is there away to get only the daily... as the logs in the folder you indiacated is 524mb in size.

    cPanel.net Support Ticket Number:
     
  4. KenMaier

    KenMaier Member

    Joined:
    Nov 5, 2002
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Unfortunately, the rotation can only be monthly.

    Note: If you are running 6.4.2 B35+, users can opt to have their log file rotated into their account each month (so symlinks are not necessary). I wish this feature was a DAILY rotation because some of our sites generate 90+MB log files per day and a monthly rotation is just not enough to keep /usr/local/apache/domlogs to a reasonable size. (feature request please!)

    -ken

    cPanel.net Support Ticket Number:

    cPanel.net Support Ticket Number:
     
  5. Freexxxmen

    Freexxxmen Member

    Joined:
    Jun 11, 2003
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Well does anyone know how to write a script i could have in cron.. that would open the file and export the previous days entrys to its own log file ? This might be the answer to the issue for me and other people that get alot of traffic and monthly logs are just to big.

    cPanel.net Support Ticket Number:
     
  6. KenMaier

    KenMaier Member

    Joined:
    Nov 5, 2002
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    Something like this would work, but needs to more efficient (it's hard-coded to one domain/logfile right now). I run this in cron each night to dump a particularly busy site's logs into their own directory.

    The resulting filename contains the date so users can easily grab one day's worth of logs if they want to process the files with an external program.

    Good luck, this isn't the most elegant script, but it works.


    --------- %< ---- snip snip ---- %< -----------

    #!/bin/sh
    # Note! Replace <userdirectory> and <userdomain>
    # This will rename the current logfile, restart apache and
    # then compress the original logfile in the background
    #
    # This script really needs to be optimized for multiple domains
    #
    SERVERLOGDIR="/usr/local/apache/domlogs"
    SERVERLOGSTOREDIR="/home/<userdirectory>/logs"
    TODAY=`/bin/date +%Y%m%d`
    LOGNAME="<userdomain>.com"
    SERVERRESTART="/usr/local/apache/bin/apachectl"
    GZIPBIN="/bin/gzip"

    # STEP 1: Backup the logs
    # Do this for every log type you have (i.e., add another line for
    # error_log, another for referer_log, etc.)
    mv $SERVERLOGDIR/$LOGNAME $SERVERLOGDIR/$LOGNAME-$TODAY

    # STEP 2: Restart the server
    $SERVERRESTART restart

    # STEP 3: Compress the logs backed up in Step 1
    /bin/nice mv $SERVERLOGDIR/$LOGNAME-$TODAY $SERVERLOGSTOREDIR/$LOGNAME-$TODAY
    /bin/nice $GZIPBIN -9 $SERVERLOGSTOREDIR/$LOGNAME-$TODAY


    cPanel.net Support Ticket Number:
     
  7. Freexxxmen

    Freexxxmen Member

    Joined:
    Jun 11, 2003
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    im not looking to just rename the log file... but actually extract the previoius days entrys and put that to a new log file. Thanks in advance if anyone knows how to get that processed from the old log.....

    cPanel.net Support Ticket Number:
     
  8. KenMaier

    KenMaier Member

    Joined:
    Nov 5, 2002
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    1
    You could either:

    (a) run the above script at midnight in cron so each log file will contain exactly one day's worth of logs (you'll end up with a new log file each day containing the previous days traffic), or

    (b) just grep through the log file of choice and extract the day you are looking for... you could put this into a script so it extracts out the date you pass it.

    -ken

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page