How to delete error. log, access. log files and methods to limit the size of Apache log files. log and error. the log file has never been moved. Today, a MYSQL database connection error occurs in wordpress, and error 2003 is returned. log, access. the log is too big, and the file has 30 GB. The following is the deletion error found on the Internet. log, access. log File method.
Delete the error. log and access. log files in Windows:
Delete the error. log and access. log files in the Apache2/logs/directory.
Open the httpd. conf configuration file of Apache and find the following two configurations:
ErrorLog logs/error. log
CustomLog logs/access. log common
Directly Comment out and replace it with the following configuration file.
# Restrict Apache error log files to 1 MB
ErrorLog "| bin/rotatelogs.exe-l logs/www.111cn.net _ error-% Y-% m-% d. log 1 MB"
# Generating error log files every day
# ErrorLog "| bin/rotatelogs.exe-l logs/error-% Y-% m-% d. log 86400 & Prime;
# Restrict access log file size to 1 MB
CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 1M 1M" common
# Generate an access log file every day
# CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 86400 & Prime; common
Refer:
Solutions for access. log and error. log files under Apache
Two log files under Apache2 are very large, and the total size is MB.
They are access. log and error. log.
I found access. log and error. log methods to lose weight on the internet. This method allows the two files to be generated on a daily basis. In this way, you can delete the old file.
In the httpd. conf configuration file under Apache, find the following:
ErrorLog logs/error. log
CustomLog logs/access. log common
Change the two sentences as follows:
CustomLog "| D:/apache2/bin/rotatelogs.exe D:/apache2/logs/access _ % Y _ % m _ % d. log 86400 480 & Prime; common
ErrorLog "| D:/apache2/bin/rotatelogs.exe D:/apache2/logs/error _ % Y _ % m _ % d. log 86400 480 & Prime;
Everything is so simple, so that these two log files will start a new file every day, so that a single file will not be too large and cannot be opened, and the log information cannot be seen. you can also delete the preceding log file.
Access. after running log on the WEB server for a long time, it may reach dozens or hundreds of megabytes. If an error occurs during Apache running, the error occurs. the log size will also increase to dozens of megabytes. It is very memory-consuming for the system to read and write a large text file. Therefore, it is necessary to limit the log file size. By referring to the http://httpd.apache.org/docs/2.0/programs/rotatelogs.html, you can use apache's own program rotatelogs.exe (located under the {$ apache}/bin/directory) to limit the size of the log file.
Usage: rotatelogs [-l] [offset minutes from UTC] or
Add this:
TransferLog "| rotatelogs/some/where 86400 & Prime;
Or
TransferLog "| rotatelogs/some/where 5M"
To httpd. conf. the generated name will www.111cn.net be/some/where. nnnn where nnnn is the system time at which the log nominally starts (N. b. if using a rotation time, the time will always be a multiple of the rotation time, so you can synchronizecron scripts with it ). at the end of each rotation time or when the file size is reached a new log is started.
An example of setting in Windows is as follows:
# Restrict the error log file to 1 MB
ErrorLog "| bin/rotatelogs.exe-l logs/error-% Y-% m-% d. log 1M"
# Generate an error log file every day
# ErrorLog "| bin/rotatelogs.exe-l logs/error-% Y-% m-% d. log 86400 & Prime;
# Restrict access log files to 1 MB
CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 1M 1M" common
# Generate an access log file every day
# CustomLog "| bin/rotatelogs.exe-l logs/access-% Y-% m-% d. log 86400 & Prime; common
It should be similar in linux/Unix.
How to clear apache access. log
The server was built using apache. Recently, the website was always very slow, the server was very slow, and sometimes even the website could not be opened. After investigation and analysis, it turned out to be access in it. log and error. log files should be read and cleared frequently. If you are busy and forget to read and clean them up, the two files will expand very large in a short time, it cannot be opened. The following describes how to clean the access. log and error. log files. I suspect there are other crawlers. I will be crawling several of my websites tomorrow.
The methods to optimize access. log and error. log are as follows:
CustomLog "| D:/thridparty-system/java/apache2/bin/rotatelogs.exe D: /thridparty-system/java/apache2/logs/access _ % Y _ % m _ % d. log 86400 480 & Prime; common
ErrorLog "| D:/thridparty-system/java/apache2/bin/rotatelogs.exe D: /thridparty-system/java/apache2/logs/error _ % Y _ % m _ % d. log 86400 480 & Prime;
Everything is so simple, so that these two log files will start a new file every day, so that a single file will not be too large and cannot be opened, and the log information cannot be seen.
A solution to the increasingly expanding ACCESS. LOG of Apache LOG files
Change customlog logs/access. log common in httpd. conf
Customlog "| c:/apache/bin/rotatelogs c:/apache/logs/% y _ % m _ % d. access. log 86400 480 & Prime; common
Restart apache
C:/apache/is the path to install apache.
In this way, a log file is generated every day.
A solution to the increasingly expanding ACCESS. LOG of Apache LOG files