In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you how to use cronolog in Linux to cut server log files, the content is very detailed, interested friends can refer to, I hope to help you.
Download (latest version)
The code is as follows:
# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
2. Decompression
The code is as follows:
# tar zxvf cronolog-1.6.2.tar.gz
3. Enter the directory where cronolog installation files are located
The code is as follows:
# cd cronolog-1.6.2
4. Operation and installation
The code is as follows:
# ./ configure
# make
# make install
5. Check the directory where cronolog is installed (verify that the installation is successful)
The code is as follows:
# which cronolog
Usually displayed as: /usr/local/sbin/cronolog
The installation process is complete. The following is the log format configuration:
1. Virtual host configuration file httpd-vhosts.conf
Modify the Web log setting CustomLog to the following format
The code is as follows:
CustomLog "|/usr/local/sbin/cronolog /www/logs/example_%Y%m%d.log" combined
Of course, the error log setting ErrorLog can also be divided by cronolog, set to
The code is as follows:
ErrorLog "|/usr/local/sbin/cronolog /www/logs/error_%Y%m%d.log"
2, if there is only one site on the server (of course, this situation is relatively rare), directly according to the above format to modify the httpd.conf file log settings.
Description:
The green part is the location of cronolog after installation. The location may not be exactly the same for different system versions. The location viewed by which command shall prevail.
The blue part is the location of the set log file, which can be modified as needed;
The red part is the set log file identification character, which can be modified as needed;
%Y%m%d is the log file partition method, in the example, it is "year, day", or it can be modified to your own needs.
Modify the httpd.conf file:
This file is located in/etc/httpd/conf/httpd.conf on my computer. Different servers should be different.
Add at the end
The code is as follows:
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
ErrorLog /data/logs/apache/webapps.wps.cn-error_log
CustomLog "|/usr/local/sbin/cronolog /data/logs/apache/%Y%m%d/access_log.% H" combined
#This ensures that a folder every day generates a log every hour under the folder
#CustomLog "|/usr/local/sbin/cronolog /data/logs/apache/%Y%m%%Hdaccess_log" combined
Go to/etc/init.d/httpd configtest to verify that your configuration file is correct
Go to/etc/init.d/httpd restart Restart the apache server (different systems should be different to find)
For Tomcat
the first step
will
The code is as follows:
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
modified to
The code is as follows:
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out.% Y-%m-%d
fi
the second step
will
The code is as follows:
touch "$CATALINA_OUT"
changed to
The code is as follows:
#touch "$CATALINA_OUT"
the third step
will
The code is as follows:
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 &
modified to
The code is as follows:
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
| /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
restart the Tomcat
The code is as follows:
service tomcat restart
About how to use cronolog in Linux to cut server log files to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.