How to set up apache to save logs every day

王林
Release: 2021-03-12 10:22:47
forward
3211 people have browsed it

How to set up apache to save logs every day

Due to work requirements, it is necessary to set apache logs to be saved every day. Now I will share the specific method for your reference.

1. Search rotatelogs

rotatelogs is a module that apache comes with to generate logs by date. The specific location is subject to the rotatelogs location on your own website

[root@localhost ~]# find / -name rotatelogs /usr/sbin/rotatelogs
Copy after login

2. Modify /etc /httpd/conf/httpd.conf configuration file

Mainly modify two parts

#ErrorLog logs/error_log #注释此行,添加下面这行 ErrorLog "|/usr/sbin/rotatelogs /var/log/httpd/error_log%Y%m%d.log 86400 480" #CustomLog logs/access_log common #注释此行,添加下面这行 CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/access_log%Y%m%d.log 86400 480" common
Copy after login

3. Restart Apache

[root@localhost ~]# systemctl restart httpd.service
Copy after login

4. Revisit to see the effect

[root@localhost ~]# cat /var/log/httpd/ access_log access_log20200504.log error_log error_log20200504.log
Copy after login

Related recommendations:apache tutorial

The above is the detailed content of How to set up apache to save logs every day. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!