Tomcat in use will encounter Catalina.out log is too large, the following we use the system (in CentOS as an example) with the logrotate to cut files, to achieve automatic daily log file cutting. logrotate Program Default program will be cut/etc/logrotate.d/the files defined below, the following methods use the root user action, otherwise you will be prompted insufficient permissions. To create a file:
For Linux system security, log files are extremely important tools. The system administrator can use the logrotate program to manage the latest events in the system. For Linux system security, log files are an extremely important tool. The system administrator can use the logrotate program to manage the latest events in the system. Logrotate can also be used to b
The Logrotate program is a log file management tool. Used to split the log file, delete the old log file, and create a new log file that acts as a "dump". You can save disk space.Logrotate command format:Logrotate [OPTION ...] -D,--debug:debug mode, test the configuration file for errors.-F,--force: Forced dump file.-M,--mail=command: Sends the log to the specified mailbox.-S,--state=statefile: Use the specified state file.-V,--verbose: Displays the d
Logrotate Introductionlog rotation is especially useful for log files with fixed file names, such as MySQL error log, regular query log, slow query log, and so on. Linux system has a very easy to use according to Logratate can achieve automatic rotation, this article describes its principle and usage.
Logrotate is the tool for managing log files, in CentOS systems, where commands are located in/usr/sbin/
In many real-world projects, the application will continue to write logs, and if there are no log libraries in the program code that support automatic sharding, such as by filesize or date cutting, the log files will grow to the G level very quickly. Operating large files on a single machine is very inconvenient for subsequent follow-up logs.This article describes how to use the Logrotate tool to slice logs outside the application. 1. What is
Many software comes with cutting logs, such as Tomcat, which can be named by time. Rsyslog can generate files by date, but does not support "% $year%-% $month%-% $day%" These variables to read the file (current version number: rsyslog-8.17.0-1.el6.x86_64).Then, you need to use the log polling logrotate.
overview, configuration.Global configuration:/etc/logrotate.confLocal configuration:/etc/logrotate.d/for ease of administration, custom confi
Logrotate module for processing log file rotation related tasks#-*-Coding:utf-8-*-"Module for managing Logrotate." # import Python libsimport osimport logging# Import salt libsimport salt.utilslog = Logging.getlogger (__name__) Default_co NF = '/etc/logrotate.conf ' # Define a function alias in order not to shadow built-in ' s__func_alias__ = {' set_ ': ' Set '}This article is from the Linux SA John blog, s
Case: Logrotate's log rotationFor admin.log files, set logrotateRotate once a dayKeep 3 BackupsFile larger than 100k Auto rotateOn the finished file compression Create permission 0600, owner Root belongs to group rootSteps:1. First check if the Logrotate package is installed[Email protected] log]# rpm-q logrotateLogrotate-3.7.8-17.el6.x86_64Create log Admin.log because I don't have admin.log this file in my virtual machine[Email protected] log]# Mkair
log_throttle_queries_not_using_indexes to limit the number of logs that do not use indexes per minute.Slow log outputMySQL slow query log by default is all written to a file, the file will be more and more large, very inconvenient for us to analyze. Use logrotate to cut MySQL slow query log, error log, to facilitate analysis and find problems.Define the log theory roll strategy [Email protected]_db_40 ~]# Cat Mysql-log-rotate/opt/mysql/data/idc_db_40
significant condition * *#define LOGLEVEL_INFO 6/* Informational */#define LOGLEVEL_DEBUG 7/* debug-level messages */We know about facility and severity, so how do we modify syslog.conf?The basic syntax for the syslog.conf file line is this:[Type of message (Facility)]. [Log level (Severity)] [Store target log file].The following statement joins Syslog.conf, meaning that all level log messages of the Authpriv type are stored in/var/log/secure.authpriv.*/var/log/secureOf course, the syslog suppo
Recently just to rearrange the log server, just need to reconfigure the system logrotate, so simply write some basic configuration parameters of Logrotate, for easy access.Logrotate The main configuration parameter file is/etc/logrotate.conf, and/etc/logrotate.d/directory in the write configuration is for the usual management convenience written inside, it will eventually be/etc/ Logrotate.conf, which is th
Yesterday, the online project we participated in was launched. After reading the log file, we did not split it. Considering that the log file may cause a large number of log files to cause performance degradation, we quickly split the log file. In Linux, there is a logrotate tool that can assist log segmentation. You only need to configure the parameters, which is very convenient. Therefore, you can directly configure this method. I used to split ngi
The Logrotate program is a log file management tool. Used to split the log file, delete the old log file, and create a new log file that acts as a "dump". You can save disk space.logrotate command format: Logrotate [OPTION ...] -D,--debug:debug mode, Test the configuration file for errors. -F,--force: Forced dump file. -M,--mail=command: Sends the log to the specified mailbox. -S,--state=statefile: uses th
The previous article has the salt installation process and the Salt module, not clear can go to look, this article mainly realizes nginx+php uses the logrotate to carry on the cutting to the log, then simply uses under the Salt this tool;
The architecture is as follows:
The following. pp files are under/etc/puppet/modules/logrotate/manifests, as follows
Init.pp
Class
Parameters
-? or--help online Help.-D or--debug the instruction execution process in detail to facilitate error-making or understanding of program execution.-F or--force forcibly initiates record file maintenance operations, even if the Logrotate directive deems it unnecessary.The-sThe-V or--version displays the instruction execution process.-usage Display instruction basic usage.
Parameter function
Compress the subsequent logs via gzip compression
Label: better embedded operating system space planScenario: in the actual application environment, we need to independently mount the log directory to a partition or a virtual memory disk. If you mount/var/log to the memory virtual disk and the file format is tmpfs, You need to calculate it carefully. After all, memory resources are always limited, not to mention embedded operating systems. Therefore, it is best to allocate proper memory space during mounting. The so-called fit should be the max
1, under the LOGROTATE.D a new file, file name random
Touch/etc/logrotate.d/tomcat-log-cut
2, the contents of the document:
/home/mes/tomcat8-mes/logs/catalina.out {
Su root rootDailyRotate 14DateextDateFormat.%y%m%d#size 100NotifemptyMissingokCopytruncate}
Parameter explanation Please refer to: http://blog.csdn.net/maosijunzi/article/details/78813573
3, execute the following command to test a
/usr/sbin/logrotate/etc/logrotate.conf
4, if not s
Configuration/usr/local/nginx/logs/*.log { daily dateext rotate 1 olddir /usr/local/nginx/other/logs missingok notifempty compress sharedscripts postrotate /bin/kill -USR1 $(cat /var/run/nginx.pid 2>/dev/null) 2>/dev/null ||: endscript }
dateext : The file suffix is a date format, that is, after the cut file is: xxx.log-20150529 (. gz), if the comment is dropped, the cut is incremented by the number, that is, the xxx.log-1 (. gz)
delaycompress option indicates * logrotate do not compress the most recent archive, and compression will take place in the next round-robin cycle. This is useful when you or any software still needs to read the latest archive.
Missingok: During log rotation, any errors will be ignored, such as "files cannot be found".
Notifempty: If the log file is empty, the round robin does not proceed.
Create 644 root root: Creates a completely new log
There are many log files on the Linux system, syslog message mail cron and so on, and application logs and access logs, which, under a lot of accesses, can grow rapidly, consume lots of private disk space and consume Io, The Access_log and catalina.out files of Nginx and Tomcat are now split by crontab using shell scripts on the wire.Today accidentally think of logrotate, small tried, or good, record ...Looking at the logs under the log directory, you
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.