[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN101645031A - Method for dynamically outputting log file according to time - Google Patents

Method for dynamically outputting log file according to time Download PDF

Info

Publication number
CN101645031A
CN101645031A CN200910054235A CN200910054235A CN101645031A CN 101645031 A CN101645031 A CN 101645031A CN 200910054235 A CN200910054235 A CN 200910054235A CN 200910054235 A CN200910054235 A CN 200910054235A CN 101645031 A CN101645031 A CN 101645031A
Authority
CN
China
Prior art keywords
file
time
log file
sequence number
output
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN200910054235A
Other languages
Chinese (zh)
Inventor
郝黎明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Casco Signal Ltd
Original Assignee
Casco Signal Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Casco Signal Ltd filed Critical Casco Signal Ltd
Priority to CN200910054235A priority Critical patent/CN101645031A/en
Publication of CN101645031A publication Critical patent/CN101645031A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to a method for dynamically outputting a log file according to time, comprising the following steps: file naming rules are defined, and time information is set in a file name; time granularity is defined, and the granularity of an output log file is defined according to the size and the output frequency of an output log; a size threshold M of the file is defined, and the sizeof each output log file can not be bigger than the threshold M; the file name and a file sequence number are obtained; and the log file is output, and the log is output into the log file. Compared with the prior art, the invention has the advantages that the method adopts a dynamic thought, provides the method for dynamically outputting the log file according to the time, describes each log filefrom the angle of the time, provides a new method for outputting the log file, is convenient to fast position the log according to the time, improves the log retrieval efficiency, and provides a faster positioning approach for event analysis in a software system running process.

Description

A kind of method of dynamically outputting log file according to time
Technical field
The present invention relates to the method for outputting log file, relate in particular to a kind of method of dynamically outputting log file according to time.
Background technology
In software systems, need journal function to come institute's event in the logging software system operational process.Some present log patterns have Log4cpp, Log4j, Log4cxx etc., and these modules provide unified daily record input interface, by one or more daily record output managers daily record are outputed to file, log server, or position such as database.The function of rollback outputting log file only is provided when in these modules daily record being outputed to file, has promptly set maximal value M and maximum exportable journal file number C, the outputting log file according to the following rules of each log file size:
(1) size of Shu Chu each journal file is no more than M;
(2) number of Shu Chu journal file is not more than C;
(3) journal file of each output has a sequence number, and sequence number increases progressively successively by the sequencing of its output, and sequence number is since 1;
(4) when the output of certain file is full (file size will above M time) be if the file number then outputs to a new journal file, and makes its sequence number add 1 less than C at this moment;
(5) when the output of certain file is full, if this moment, the file number was C, then delete sequence number and be 1 file, and each makes sequence number subtract 1 greater than the sequence number of 1 file, output sequence number is the file of C.
When outputting log file, often need to control the time of outputting log file, for example every journal file of output in one hour, so that raising is by the efficient of time retrieve log file.The rollback outputting log file is to consider that from the number aspect of the size of each journal file and journal file it can not satisfy the demand.In this case,, proposed a kind of method of dynamically outputting log file according to time, found there is not the method for this respect at present through the file retrieval in order to address the above problem.
Summary of the invention
Purpose of the present invention is exactly in order to overcome the defective that above-mentioned prior art exists, a kind of method of high-efficiency reliable dynamically outputting log file according to time to be provided.
Purpose of the present invention can be achieved through the following technical solutions: a kind of method of dynamically outputting log file according to time is characterized in that this method comprises:
(1) defined file naming rule, setting comprises temporal information in filename;
(2) definition time granularity, according to the size and the output frequency of output journal, the granularity of definition outputting log file;
(3) defined file size threshold value, defined file size threshold value M, the log file size of each output can not be worth M greater than this;
(4) obtain filename and file sequence number;
(5) outputting log file outputs to daily record in the journal file.
Described acquisition filename and file sequence number comprise:
A. according to journal file naming rule, time granularity, and the current time calculate the filename of the current journal file that will export;
B. if the log file size of current output surpasses threshold value M, then create new file, make its sequence number add 1.
Described according to journal file naming rule, time granularity, and the filename that the current time calculates the current journal file that will export comprises:
The computing method of hour character string are:
HH = HH C * 60 + MM C k * k 60
The computing method of minute character string are:
MM = HH C * 60 + MM C k * k mod ( 60 )
HHC in the above-mentioned formula and MMC are respectively hourage and the number of minutes of current time, and above-mentioned HH, MM are defined as and round.
Describedly obtain to such an extent that the method for file sequence number comprises:
A. the sequence number that makes current file is 1;
B. check whether this document exists;
C. if exist, judge that then whether this document size is greater than threshold value M; If do not exist, then create this file;
D. if file size less than threshold value M, is then exported this document; Otherwise sequence number increases by 1, and turns back to b.
Compared with prior art, advantage of the present invention comprises:
(1) adopts dynamic thought, a kind of method of dynamically outputting log file according to time is provided, from the angle of time each journal file is described, a kind of method of new outputting log file not only is provided, and be convenient to by time location daily record fast, the recall precision that improved daily record is for the event analysis in the software systems operational process provides the approach of locating faster;
(2) combine the thought that in the rollback outputting log file each file size is limited, effectively prevented the excessive possibility that causes the output efficiency step-down of file, this method is still counted initiative aspect the journal function of software systems.
Description of drawings
Fig. 1 is the process flow diagram of the method for a kind of dynamically outputting log file according to time of the present invention.
Embodiment
The present invention will be further described below in conjunction with specific embodiment.
As shown in Figure 1: a kind of method of dynamically outputting log file according to time, this method comprises:
(1) defined file naming rule, setting comprises temporal information in filename;
(2) definition time granularity, according to the size and the output frequency of output journal, the granularity of definition outputting log file;
(3) defined file size threshold value, defined file size threshold value M, the log file size of each output can not be worth M greater than this;
(4) obtain filename and file sequence number;
A. according to journal file naming rule, time granularity, and the current time calculate the filename of the current journal file that will export;
The computing method of hour character string are:
HH = HH C * 60 + MM C k * k 60
The computing method of minute character string are:
MM = HH C * 60 + MM C k * k mod ( 60 )
HHC in the above-mentioned formula and MMC are respectively hourage and the number of minutes of current time, and above-mentioned HH, MM are defined as and round;
Describedly obtain to such an extent that the method for file sequence number comprises:
A. the sequence number that makes current file is 1;
B. check whether this document exists;
C. if exist, judge that then whether this document size is greater than threshold value M; If do not exist, then create this file;
D. if file size less than threshold value M, is then exported this document; Otherwise sequence number increases by 1, and turns back to b;
B. if the log file size of current output surpasses threshold value M, then create new file, make its sequence number add 1;
(5) outputting log file outputs to daily record in the journal file.
Embodiment 1
(1) defined file naming rule.Contain temporal information in the journal file name, establishing its form is YYYYMMDDHHMM, and for example the form in 1: 1 on the 1st January in 2009 is 200901010101; Prefix and suffix character string are remembered respectively and are made PRE and APP in the filename; Sequence number note in the filename is made SEQ.If the filename form is PRE ‖ YYYYMMDDHHMMSS ‖ SEQ ‖ APP, wherein ‖ is traditional string of binary characters connector;
(2) definition time granularity.If created new journal file every k minute, 0<k≤1440 wherein, the cycle of promptly creating file is no more than one day, if k>1440, this method is expanded getting final product;
(3) defined file size threshold value.If the log file size threshold value is M, wherein M>0;
(4) obtain filename.At first, calculate time character string in the filename according to current time and defined time granularity, concrete computing method are as follows:
HH = HH C * 60 + MM C k * k 60 - - - ( 1 )
MM = HH C * 60 + MM C k * k mod ( 60 ) - - - ( 2 )
HHC in formula (1) and (2) and MMC be respectively the current time hour and the number of minutes, its division is defined as here and rounds.Suppose that the current time is 13: 49, when time granularity k=5, HH=13, MM=45; When time granularity k=120, HH=12, MM=0.
Sequence number calculation process in the filename is as follows:
The sequence number that makes current file is 1;
Check whether this document exists;
If exist, judge that then whether this document size is greater than threshold value M; If do not exist, then create this file;
If file size less than threshold value M, is then exported this document, otherwise sequence number increases by 1, turns back to b).
(5) outputting log file.Daily record is outputed in the journal file.

Claims (4)

1. the method for a dynamically outputting log file according to time is characterized in that, this method comprises:
(1) defined file naming rule, setting comprises temporal information in filename;
(2) definition time granularity, according to the size and the output frequency of output journal, the granularity of definition outputting log file;
(3) defined file size threshold value, defined file size threshold value M, the log file size of each output can not be worth M greater than this;
(4) obtain filename and file sequence number;
(5) outputting log file outputs to daily record in the journal file.
2. the method for a kind of dynamically outputting log file according to time according to claim 1 is characterized in that, described acquisition filename and file sequence number comprise:
A. according to journal file naming rule, time granularity, and the current time calculate the filename of the current journal file that will export;
B. if the log file size of current output surpasses threshold value M, then create new file, make its sequence number add 1.
3. the method for a kind of dynamically outputting log file according to time according to claim 2 is characterized in that, and is described according to journal file naming rule, time granularity, and the filename that the current time calculates the current journal file that will export comprises:
The computing method of hour character string are:
HH = HH C * 60 + MM C k * k 60
The computing method of minute character string are:
MM = HH C * 60 + MM C k * k mod ( 60 )
HHC in the above-mentioned formula and MMC are respectively hourage and the number of minutes of current time, and above-mentioned HH, MM are defined as and round.
4. the method for a kind of dynamically outputting log file according to time according to claim 1 is characterized in that, describedly obtains to such an extent that the method for file sequence number comprises:
A. the sequence number that makes current file is 1;
B. check whether this document exists;
C. if exist, judge that then whether this document size is greater than threshold value M; If do not exist, then create this file;
D. if file size less than threshold value M, is then exported this document; Otherwise sequence number increases by 1, and turns back to b.
CN200910054235A 2009-06-30 2009-06-30 Method for dynamically outputting log file according to time Pending CN101645031A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910054235A CN101645031A (en) 2009-06-30 2009-06-30 Method for dynamically outputting log file according to time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910054235A CN101645031A (en) 2009-06-30 2009-06-30 Method for dynamically outputting log file according to time

Publications (1)

Publication Number Publication Date
CN101645031A true CN101645031A (en) 2010-02-10

Family

ID=41656925

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910054235A Pending CN101645031A (en) 2009-06-30 2009-06-30 Method for dynamically outputting log file according to time

Country Status (1)

Country Link
CN (1) CN101645031A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102096626A (en) * 2010-12-27 2011-06-15 意法·爱立信半导体(北京)有限公司 Mobile terminal and processing method of test log thereof
CN102820983A (en) * 2011-11-18 2012-12-12 金蝶软件(中国)有限公司 Method for collecting system abnormality information, and manager
CN103309873A (en) * 2012-03-09 2013-09-18 阿里巴巴集团控股有限公司 Method and device for processing data, and system
CN104252406B (en) * 2013-06-28 2017-04-05 华为技术有限公司 The method and device of data processing
CN106815045A (en) * 2016-12-19 2017-06-09 苏州唐氏机械制造有限公司 The method that versions of data updates
CN106815124A (en) * 2015-12-01 2017-06-09 北京国双科技有限公司 Journal file treating method and apparatus
CN107526674A (en) * 2017-08-31 2017-12-29 郑州云海信息技术有限公司 A kind of method and apparatus of embedded system log recording
CN105142045B (en) * 2015-08-19 2018-07-31 上海斐讯数据通信技术有限公司 PON performance datas processing system and method
US10621224B2 (en) * 2015-12-17 2020-04-14 Huizhou Tcl Mobile Communication Co., Ltd. Method for automatically naming photos based on mobile terminal, system, and mobile terminal

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102096626A (en) * 2010-12-27 2011-06-15 意法·爱立信半导体(北京)有限公司 Mobile terminal and processing method of test log thereof
CN102820983A (en) * 2011-11-18 2012-12-12 金蝶软件(中国)有限公司 Method for collecting system abnormality information, and manager
CN102820983B (en) * 2011-11-18 2016-04-13 金蝶软件(中国)有限公司 System exception information collecting method and manager
CN103309873A (en) * 2012-03-09 2013-09-18 阿里巴巴集团控股有限公司 Method and device for processing data, and system
CN104252406B (en) * 2013-06-28 2017-04-05 华为技术有限公司 The method and device of data processing
CN105142045B (en) * 2015-08-19 2018-07-31 上海斐讯数据通信技术有限公司 PON performance datas processing system and method
CN106815124A (en) * 2015-12-01 2017-06-09 北京国双科技有限公司 Journal file treating method and apparatus
US10621224B2 (en) * 2015-12-17 2020-04-14 Huizhou Tcl Mobile Communication Co., Ltd. Method for automatically naming photos based on mobile terminal, system, and mobile terminal
CN106815045A (en) * 2016-12-19 2017-06-09 苏州唐氏机械制造有限公司 The method that versions of data updates
CN107526674A (en) * 2017-08-31 2017-12-29 郑州云海信息技术有限公司 A kind of method and apparatus of embedded system log recording

Similar Documents

Publication Publication Date Title
CN101645031A (en) Method for dynamically outputting log file according to time
CN112507029B (en) Data processing system and data real-time processing method
CN102541942B (en) Data bulk transfer system and method thereof
CN102999480B (en) The method and system of Edit Document
CN104461551A (en) Parallel data processing based big data processing system
CN111949850B (en) Multi-source data acquisition method, device, equipment and storage medium
CN112818013B (en) Time sequence database query optimization method, device, equipment and storage medium
CN112860662B (en) Automatic production data blood relationship establishment method, device, computer equipment and storage medium
CN116841973A (en) Data intelligent compression method and system for embedded database
CN103023802A (en) Web-cluster-oriented low energy consumption scheduling system and method
CN102479211B (en) Mass data processing system and method on basis of database
CN103793500A (en) Master data synchronization method based on increments
CN101894161B (en) Recurring event access method and device for real-time monitoring
CN108595480B (en) Big data ETL tool system based on cloud computing and application method
Liu et al. Study on application of CYCBD based on PSO in fault feature extraction of rolling bearing
US9092338B1 (en) Multi-level caching event lookup
CN101609449A (en) A kind of fast comparison system for data blocks based on Bloom Filter
CN202524426U (en) Enterprise cloud computing service application system
CN111556108A (en) Cloud platform-based electric power big data acquisition system and method
CN110647396A (en) Method for realizing intelligent application of end cloud cooperative low-power consumption and limited bandwidth
CN103617113A (en) File version displaying method based on time axis
CN103823812A (en) System data management method
CN102376021A (en) Book management system
CN114610508A (en) Front-end big data calculation processing method and system
CN203457135U (en) Gray code counter device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Open date: 20100210