Difference between revisions of "Log Files"
From Hostek.com Wiki
(Created page with "==Getting IP addresses From Site Log Files== If you need to get the lines out of the logs for a certain IP you can use the PHP code below: *NOTE: You'll need to change the $i...") |
|||
Line 1: | Line 1: | ||
+ | ==How Long Are Log Files Kept?== | ||
+ | We will always leave at least the last 30 days of WWW logs in your "W3SVCxxx" folder. If you wish to keep log files from older than 30 days, you'll need to download the log files to your local machine. Log files older than 30 days may be deleted from the server to conserve disk space and help keep the server running at an optimal level. | ||
+ | |||
==Getting IP addresses From Site Log Files== | ==Getting IP addresses From Site Log Files== | ||
If you need to get the lines out of the logs for a certain IP you can use the PHP code below: | If you need to get the lines out of the logs for a certain IP you can use the PHP code below: |
Latest revision as of 10:14, 3 December 2012
How Long Are Log Files Kept?
We will always leave at least the last 30 days of WWW logs in your "W3SVCxxx" folder. If you wish to keep log files from older than 30 days, you'll need to download the log files to your local machine. Log files older than 30 days may be deleted from the server to conserve disk space and help keep the server running at an optimal level.
Getting IP addresses From Site Log Files
If you need to get the lines out of the logs for a certain IP you can use the PHP code below:
- NOTE: You'll need to change the $ip and $file variables to match your needs.
<?php header('Content-type: text/plain'); $ip = '1.2.3.4'; $file = 'D:\home\example.com\logs\W3SVC123\ex090430.log'; if ($fh = fopen($file, 'r')) { while ($line = fgets($fh)) { if (strpos($line, $ip) !== FALSE) { echo $line; } } } else { die("Can't open $file for reading.\n"); } ?>