Cronolog use (log management)

Source: Internet
Author: User
Tags locale apache access log
In UNIX daemon programs, using log files to record the use of information or error messages is the most common method. In addition to the system itself, syslog can implement automatic rotation, most of the time log does not achieve automatic rotation, which often leads to a large log file, in the search, historical records processing and statistics, etc. to bring a lot of inconvenient to live.

Cronolog is a compact and efficient log file processing tool that enables automatic generation of periodic log files by rules. Let's take a sample of the handling of the Apache access log and the Tomcat run log.


A Installation

1. Download the source package to www.cronolog.org (currently 1.62) and extract it to a directory;

2. Su-root;cd/path/to/cronolog;./configure;make make install―― installs the Cronolog to/usr/local/sbin and installs the appropriate man pages. Recommended Strip/usr/local/sbin/cronolog to further reduce its file size (approximately 20 k).

Two Basic way of Use

Cronolog is generally a way of piping to work, using the following form:

# Loggenerator | Cronolog Log_file_pattern

Where Loggenerator is the program that generates the log, and Log_file_pattern is the path to the log file, where you can add the time-related pattern characters that Cronolog supports, such as/www/log/%y/%m/%d/ Access.log. The patter is a% character followed by a special character, as described below:

Escape character:

%% character

N Line Wrapping

T horizontal tab


Time field:

H-hour (00..23)

I-hour (01..12)

P The AM or PM logo under the locale

M min (00..59)

S sec (00..61, which allows for leap seconds)

X the locale time indicator (e.g.: "15:12:47")

Z time zone. If the time zone is not sure, it is meaningless

Date field:

A the locale of the working day (e.g.: Sun. Sat)

A the full name of the working day under the locale (e.g.: Sunday. Satur-ay)

b The short name of the month (e.g: locale). DEC)

B the full name of the month under the locale (e.g.: January. December)

c The date and time under the locale (e.g.: "Sun Dec 14:12:47 GMT 1996")

D Days in the month (01.. 31)

J Days in the year (001.. 366)

M months (01.. 12)

U the number of weeks in the year, in Sunday as the beginning of the week, the first week, including the week of Sunday (00..53)

W the number of weeks in the year, with Monday as the beginning of the week, the first week of which includes the week of Sunday (00..53)

W Number of workdays (0.6, 0 for Sunday)

X the date indicated under the locale (e.g. "13/04/97")

Y two-digit year (00.. 99)

Y Four-digit year (1970.. 2038)


Three How Apache logs are used

Edit the httpd.conf file to include the

Customlog/usr/local/apache/logs/access_log combined this line, instead:

Customlog "|/usr/local/sbin/cronolog/usr/local/apache/logs/%y_week_%u/access_log" combined
Note that the double quotes are required because this is a pipe operation.  The configuration described above will be in the Apache logs directory, creating a weekly directory like 2002_week_50, and then writing the Apache access log to the Access_log file in combined format. Cronolog will automatically complete the catalog generation, switching on time at the periodic boundary point.

Four How Tomcat logs are used

At present, most of the system tomcat in the boot, most of the XXX or portal and other non-root users, with Nohup Command_line & to Start, The output information such as Tomcat's debug will automatically be written to the Nohup.out file in the Tomcat's current directory. The time is long the file will become very large, to deal with and clearly bring trouble. The following methods are used: Cronolog

Create a Runlog directory under the user home for the Tomcat run log;

You will start the script or monitor the following command in the script:

CD $HOME/tomcat3/bin;

Nohup./startup.sh

Change into:

CD $HOME/tomcat3/bin

Nohup./startup.sh 2>&1 | /usr/local/sbin/cronolog/path/to/runlog/tomcat-%y%m%d.log &


This can be in the corresponding Runlog directory, the Daily generation of a Tomcat run log, for future inspection and error to bring great benefits.

It can be said that, as long as there is log place, Cronolog can always play its role-hope to be able to bring benefits to our work

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.