CN1159649C - Automatic circular daily record information storing method and system - Google Patents

Automatic circular daily record information storing method and system Download PDF

Info

Publication number
CN1159649C
CN1159649C CNB001372181A CN00137218A CN1159649C CN 1159649 C CN1159649 C CN 1159649C CN B001372181 A CNB001372181 A CN B001372181A CN 00137218 A CN00137218 A CN 00137218A CN 1159649 C CN1159649 C CN 1159649C
Authority
CN
China
Prior art keywords
file
log information
log
journal file
rank
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.)
Expired - Fee Related
Application number
CNB001372181A
Other languages
Chinese (zh)
Other versions
CN1361489A (en
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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CNB001372181A priority Critical patent/CN1159649C/en
Publication of CN1361489A publication Critical patent/CN1361489A/en
Application granted granted Critical
Publication of CN1159649C publication Critical patent/CN1159649C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Abstract

The present invention discloses a log information automatic cycle storage method and a log information automatic cycle storage system formed by a log file manner. A timer module scans a log file in operation in a timed mode by stating various parameters of a pointer file and the log file to an initialized module, and the timer module sequentially and circularly opens other log files to operate the log files. When is written, log information can be preserved according to the requirements of stated grades and stated contents. The method and the system of the present invention are relatively independent in application, and the method and the system can be flexibly invoked. The debugging and the running of the method and the system can both achieve good effects in various computer application systems, particularly communication systems.

Description

A kind of Automatic Cycle storage means of log information
The present invention relates to the Automatic Cycle storage of the log information in the computer system, especially in communication system equipment to all kinds of log informations of system in real time, Automatic Cycle, by the importance information storage means.
Nearly all computer system all needs regularly or in real time to preserve log information, and this is the important means that system diagnoses.The method of present storage log information is very many, generally can be divided into two classes:
First kind method is to adopt the simple files storage; Second class methods are database storing.
The main implementation method of first kind method has:
1) all information of single file storage;
2) be stored in by date in a plurality of files, can store by the sky can also be by being stored in week in the different files;
3) by different application purpose information stores in a plurality of files;
4) be stored in a plurality of files by fixed size.
Though above-mentioned several method implements very simple, it has following shortcoming: have the possibility that surmounts disk storage space, cause the collapse of system easily; More than 4 kinds of implementation methods all can not safeguard automatically, need artificial regular update and maintenance; And first, second kind and the third method may make that also file is too big, cause the user normally to read.
The main realization of second class methods is: the mode by default in database is stored in log information in the table.
The advantage of this method is: inquiry log information easily.
Its shortcoming is:
1) possibility that surmounts disk storage space is also arranged, also need artificial regeneration and maintenance;
2) need the installation data library software, increased the price of system, reduced the performance of system, certain limitation is arranged in the use.
Various debugging and operation all need to preserve some important log informations in communication system, and wish to reduce as far as possible artificial the participation and safeguard.Use special database software to increase cost, it is too fat to move that system also seems.Has this just proposed a problem: a kind of relatively independent simple automatic, cycle storage method that also can realize log information in the usable range of broad can be arranged?
One of purpose of the present invention is to provide a kind of Automatic Cycle storage means of log information, can cover journal file the earliest automatically, effectively controls disk storage space, avoids the defective of aforementioned each class methods, and does not increase the operand of system, does not need manual maintenance.
The method of log information Automatic Cycle storage of the present invention, performing step is as follows:
One, system initialization
1) the required parameters of system is set, comprises the content of information of the total maximal value of maximal value, the journal file of each journal file, printing and the rank that needs to preserve log information;
The content of the information of printing is set, comprises: whether print source filename, whether print the row number of source file and whether print the current thread numbering.
Preserve the rank of log information and represent to preserve the system information of rank smaller or equal to setting value, every system information all has a level definition, and the importance that rank is more little is high more.
Reference number of a document when 2) obtaining subsystem and withdraw from according to pointer file, and open a journal file;
The pointer file of system is preserved the journal file numbering when withdrawing from the pointer file when logging off; When system moves, current journal file numbering is kept in the pointer file.
3) whether the size of checking the journal file open exceeds the journal file maximal value of setting;
4) if exceed, then close current journal file, and utilize circular file name generating algorithm to find next journal file name, open next file in the mode that empties;
5) preserving current journal file numbers in the pointer file;
6) start timer, and begin to preserve log information;
Two, the size of timing circularly monitoring journal file;
1) size of inspection current file, the maximum set value 21 of the odd-numbered day will file of setting when judging whether less than initialization, if less than maximum set value, then jump procedure 6) wait for that finish the interval time of a setting;
2), then close current journal file if more than or equal to maximum set value;
3) utilize circular file name generating algorithm to produce 1 new filename;
4) opening steps 3) in new file, and empty former meaningful;
5) in pointer file, preserve new file pointer;
6) finish the interval time of waiting for a setting, circulation enters regularly monitors flow process;
Three, real time record is preserved log information when entering regularly circularly monitoring;
The preservation rank of setting when 1) whether the rank of judging current system log message is smaller or equal to initialization is if the preservation rank of information is preserved rank, jump procedure 6 greater than the system that sets) wait for next bar log information of receiving system;
2) in order to guarantee thread-safe, at first utilize mutual exclusion techniques to lock;
3) get time, thread number then, according to current configuration requirement, the filename of date saved, thread number, source program, row number, information such as log content are in current journal file;
4) line feed, and refreshing file;
5) release steps 2) in added lock;
6) wait for next bar log information of receiving system, continue real-time judge and preserve log information.
Log information Automatic Cycle storage system of the present invention comprises initialization module, timer module, writes log pattern; Initialization module comprises the log information branch rank of needs preservation, the correlation parameter of journal file, the pointer value of pointer file is set, and is introduced into initialization module in the time of system start-up; When finish initialization required be provided with after begin to enter the action of writing log pattern and timer module simultaneously; Write in the log pattern to the safety that guarantees thread is provided with when writing daily record and add release, when writing daily record, get system information in real time by the rank preservation log information that is provided with in the initialization module; The journal file that writes is safeguarded in the timer module quantitative check, and when the journal file that writes surpassed set big or small, circulation emptied, opens next journal file.
Fig. 1 is an initialization flowchart in the log information Automatic Cycle storage means of the present invention;
Fig. 2 is timing circularly monitoring journey figure in the log information Automatic Cycle storage means of the present invention;
Fig. 3 writes the log information processing flow chart in the log information Automatic Cycle storage means of the present invention;
Fig. 4 is that the module of log information Automatic Cycle storage system of the present invention is formed synoptic diagram;
Below with reference to the flow process of Fig. 1, Fig. 2, Fig. 3, and in conjunction with the processing procedure of example explanation the inventive method, explanation earlier is in initialization and the method for relevant circular file name generation in the circularly monitoring regularly:
(1) user needs a given filename, form by two parts, as: " ABCD.EFG ", " ABCD " wherein is primary filename, and " EFG " is extended file name, and the new file of Sheng Chenging is by name so:
Primary filename+reference number of a document+". "+extended file name;
(2) reference number of a document be from 1 to the numbering maximal value, the numbering maximal value should be " maximal value that journal file is total " integral part divided by the result of " maximal value of individual log file ", the maximal value of numbering must be more than or equal to 2.If the maximal value of individual log file is that the total maximal value of 5M, journal file is 403M, then journal file numbering maximal value is 80, and promptly 403M/5M rounds.
(3) when reference number of a document greater than numbering during maximal value, reference number of a document comes back to 1.
Below only describe as follows with the concrete application of method and system of the present invention in the authentication and accounting server:
(1) system initialization, step 11: the initialization module that calls native system, the parameters that the system that is provided with is required, major parameter comprises: the content of need preserving the information of the total maximal value (being total storage space of daily record information) of rank, the basic name of journal file, the title of pointer file, the maximal value of individual log file, the journal file of log information, printing; Step 12: the journal file numbering when obtaining subsystem and withdraw from according to pointer file, and open this journal file; Step 13: whether the size of checking the journal file of opening exceeds the individual log file maximal value of setting, for example 5M; If do not exceed, then jump procedure 16, and system starts timer module automatically, begins to preserve log information; If exceed, then change step 14, close current journal file, and utilize circular file name generating algorithm to find next journal file name, open next journal file in the mode that empties, step 15: preserve current journal file and number in the pointer file step 16: start timer module, begin to preserve log information;
(2) size of timing circularly monitoring journal file, step 21: system is with the size of the current journal file of quantitative check during program run, and judge whether to need then write next file, if the maximum set value of the odd-numbered day will file that the size of current journal file is set during less than initialization, then jump procedure 26, otherwise change step 22, for example: if the current file pointer is " 3 ", substantially " Radius.log " by name of file, then current journal file is called " Radius3.log ", if timer is checked through the maximal value that the size of file " Radius3.log " surpasses single file, then change step 22: close current journal file Radius3.log, step 23: use the round-robin method, make that file pointer is " 4 ", obtain new journal file name Radius4.log, step 24: open file " Radius4.log " step 25 with the mode of emptying: record " 4 " this new journal file pointer value in pointer file; Step 26: finish the interval time of waiting for a setting, and circulation enters regularly monitors flow process;
(3) real time record is preserved log information when entering regularly circularly monitoring, can preserve information at any time during program run, only needs to use two parameters, for example:
PTRACE(3,″Message?no:″<<no);
First parameter " 3 " wherein represents that the preservation rank of this information is 3, if the preservation rank that the user is provided with when initialization is not then printed this information, otherwise printed this information less than 3." Message no: " in second parameter is a character string, and " no " is an integer variable.If the value of no is 3, then the result is:
2000/11/12?10:20:51?243?host.cpp(478)Message?no:3
Wherein " 243 " expression thread number this line code that has been 243 thread execution, 478th row of the code of this information at the host.cpp file printed in " host.cpp (478) " expression; Step 31: the preservation rank of setting when writing rank that log pattern judges current system log message whether smaller or equal to initialization, if the preservation rank of information is preserved rank greater than the system that sets, then jump procedure 36, otherwise change step 32; Step 32:, at first utilize mutual exclusion techniques to lock in order to guarantee thread-safe; Step 33: get time, thread number then, according to current configuration requirement, the filename of date saved, thread number, source program, row number, information such as log content are in current journal file; Step 34: line feed, and refreshing file; Step 35: added lock in the release steps 32; Step 36: receive next bar log information.
In step 11, the content of the information of printing is set, comprising: whether print source filename, whether print the row number of source file and whether print the current thread numbering.
In step 11, the rank that needs to preserve log information represents to preserve the system information of rank smaller or equal to setting value, and every system information all has a level definition, and the importance that rank is more little is high more.
Pointer file in the step 11 is preserved the journal file numbering when withdrawing from the pointer file when logging off; When system moves, current journal file numbering is kept in the pointer file.
The module composition synoptic diagram of system of the present invention shown in Figure 4 has been done detailed explanation in the above and has just been repeated no more herein;
Method of the present invention has adopted document storage mode, utilizes the round-robin way to realize the automatic renewal and the maintenance of log information.Because reference number of a document is saved hereof, make the numbering that can also write down current file after the system restart, and the numbering of file is a round-robin, be the oldest file so the system that guaranteed covers.
The log system that utilizes this method to realize also has following advantages:
(1) recycles memory space, do not need manual intervention, improved the reliability of system;
(2) different daily record ranks is set, can when debugging, preserves a lot of trace informations, when operation Preserve less trace information, can automatically preserve the information such as filename, line number of source program, increase Added the convenience that system uses;
(3) operating system platform is irrelevant, supports multithreading, makes system of the present invention relatively independent, is convenient to pipe Reason;
(4) calling interface is very simple, flexible.

Claims (4)

1. the Automatic Cycle storage means of a log information is characterized in that,
The concrete steps that realize are as follows:
One, system initialization
1) the required parameters of system is set, comprises the content of information of the total maximal value of maximal value, the journal file of each journal file, printing and the rank (11) that needs to preserve log information;
Reference number of a document when 2) obtaining subsystem and withdraw from according to pointer file is opened a journal file (12);
3) whether the size of checking the journal file open exceeds the journal file maximal value (13) of setting, if do not exceed then jump procedure 6), then change step 4) if exceed;
4) if exceed, then close current journal file, and utilize circular file name generating algorithm to find next journal file name, open next file (14) in the mode that empties;
5) preserve current journal file and number (15) in the pointer file;
6) start timer, and begin to preserve log information (16);
Two, the size of timing circularly monitoring journal file;
1) check the size of current file, the maximum set value (21) of the odd-numbered day will file of setting when judging whether less than initialization, if less than maximum set value, then jump procedure 6) finish interval time of waiting for a setting (26);
2), then close current journal file (22) if more than or equal to maximum set value;
3) utilize circular file name generating algorithm to produce 1 new filename (23);
4) opening steps 3) in new file, and empty former meaningful (24);
5) in pointer file, preserve new file pointer (25);
6) finish (26) interval time of waiting for a setting, circulation enters regularly monitors flow process (21);
Three, real time record is preserved log information when entering regularly circularly monitoring;
The preservation rank of setting when 1) whether the rank of judging current system log message is smaller or equal to initialization (31), if the preservation rank of current log information is preserved rank greater than the system that sets, jump procedure 6) waits for next bar log information (36) of receiving system, otherwise change step 2);
2), at first utilize mutual exclusion techniques lock (32) in order to guarantee thread-safe;
3) get time, thread number then, according to current configuration requirement, the filename of date saved, thread number, source program, row number, information (33) in current journal file such as log content;
4) line feed, and refreshing file (34);
5) release steps 2) in added lock (35);
6) wait for next bar log information (36) of receiving system, continue real-time judge and preserve log information (31).
2. the Automatic Cycle storage means of a kind of log information according to claim 1, it is characterized in that, the content of the information of printing is set in described initialization, comprises: whether print source filename, whether print the row number of source file and whether print the current thread numbering.
3. the Automatic Cycle storage means of a kind of log information according to claim 1, it is characterized in that, the rank of preserving log information in described initialization represents to preserve the system information of rank smaller or equal to setting value, every system information all has a level definition, and the importance that rank is more little is high more.
4. the Automatic Cycle storage means of a kind of log information according to claim 1 is characterized in that, the pointer file of system in described initialization is preserved the journal file numbering when withdrawing from the pointer file when logging off; When system moves, current journal file numbering is kept in the pointer file.
CNB001372181A 2000-12-28 2000-12-28 Automatic circular daily record information storing method and system Expired - Fee Related CN1159649C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB001372181A CN1159649C (en) 2000-12-28 2000-12-28 Automatic circular daily record information storing method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB001372181A CN1159649C (en) 2000-12-28 2000-12-28 Automatic circular daily record information storing method and system

Publications (2)

Publication Number Publication Date
CN1361489A CN1361489A (en) 2002-07-31
CN1159649C true CN1159649C (en) 2004-07-28

Family

ID=4597715

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB001372181A Expired - Fee Related CN1159649C (en) 2000-12-28 2000-12-28 Automatic circular daily record information storing method and system

Country Status (1)

Country Link
CN (1) CN1159649C (en)

Families Citing this family (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
NZ521983A (en) * 2002-10-14 2005-05-27 Maximum Availability Ltd Journaling changes to system objects such as programs in the IBM OS/400 operating system
CN1295613C (en) * 2002-10-24 2007-01-17 华为技术有限公司 Method for general windows program to operate journal information record
US7831974B2 (en) * 2002-11-12 2010-11-09 Intel Corporation Method and apparatus for serialized mutual exclusion
CN100342332C (en) * 2004-09-20 2007-10-10 华为技术有限公司 Method of realizing equipment porating final software edition printed information
CN100361454C (en) * 2005-04-27 2008-01-09 华为技术有限公司 Method for obtaining of daily information from network element equipment by network management server
CN100372307C (en) * 2005-06-02 2008-02-27 华为技术有限公司 Method for managing system log
CN101009699B (en) * 2006-01-25 2010-09-08 北京鼎信高科信息技术有限公司 Transparent local security environment system and its implementation method
CN101256564B (en) * 2007-12-25 2010-06-02 深圳市同洲电子股份有限公司 Method for operating circular file
CN101272276B (en) * 2008-04-22 2011-10-26 深圳国人通信有限公司 Log management implementing method
CN101324903B (en) * 2008-07-24 2013-02-13 深圳市同洲电子股份有限公司 Method for changing circulation file into circulation linear file and access operation method thereof
CN101894161B (en) * 2010-07-22 2012-11-14 北京天融信科技有限公司 Recurring event access method and device for real-time monitoring
CN102096626A (en) * 2010-12-27 2011-06-15 意法·爱立信半导体(北京)有限公司 Mobile terminal and processing method of test log thereof
CN102141955B (en) * 2011-03-30 2013-12-25 东方通信股份有限公司 Linux-based kernel log system and realization method thereof
CN103309858B (en) * 2012-03-06 2016-04-13 深圳市腾讯计算机系统有限公司 A kind of method of multithreading log management and device
CN102902764B (en) * 2012-09-25 2016-05-11 北京奇虎科技有限公司 A kind of method and apparatus of log recording
CN103092745B (en) * 2013-01-22 2016-04-13 中兴通讯股份有限公司 The control method of system journal record and device
CN104714878B (en) * 2013-12-11 2017-11-21 阿里巴巴集团控股有限公司 A kind of method and device of collector journal data
CN103645983B (en) * 2013-12-17 2016-05-18 山东中创软件工程股份有限公司 A kind of generation method and device of journal file
CN103984622B (en) * 2014-04-18 2018-01-02 烽火通信科技股份有限公司 The blog management method and device of GPON ONU equipments based on Linux
CN104935469A (en) * 2015-06-30 2015-09-23 浪潮(北京)电子信息产业有限公司 Distributive storage method and system for log information
CN105260315B (en) * 2015-11-13 2018-04-06 上海斐讯数据通信技术有限公司 A kind of method of the debugging log in embedded system process
CN106250496A (en) * 2016-08-02 2016-12-21 北京集奥聚合科技有限公司 A kind of method and system of the data collection in journal file
CN106815045A (en) * 2016-12-19 2017-06-09 苏州唐氏机械制造有限公司 The method that versions of data updates
CN107016054A (en) * 2017-03-03 2017-08-04 京信通信技术(广州)有限公司 A kind of method and device of log information storage
CN109753488B (en) * 2019-01-04 2021-03-23 烽火通信科技股份有限公司 HTTP-based server operation log management method and system
CN117708138A (en) * 2024-02-05 2024-03-15 力高(山东)新能源技术股份有限公司 Data storage method, component, equipment and medium based on energy storage system database

Also Published As

Publication number Publication date
CN1361489A (en) 2002-07-31

Similar Documents

Publication Publication Date Title
CN1159649C (en) Automatic circular daily record information storing method and system
US7406485B2 (en) Shared scans utilizing query monitor during query execution to improve buffer cache utilization across multi-stream query environments
CN1171147C (en) Automatic continued software/adaptor generator
CN1845120A (en) Automatic analysis system and method for malicious code
Lake et al. Solving large retrograde analysis problems using a network of workstations
CN1234551A (en) Method and apparatus of dynamically optimizing byte coding programme
CN1331817A (en) Method and appts. for concurrent DBMS table operations
CN1282085C (en) Method of parallel regulating multi-task of imbedding system
US20110167248A1 (en) Efficient resumption of co-routines on a linear stack
CN1552022A (en) File archival
US7765524B2 (en) Method and system for global constant management
CN1448867A (en) Method for accessing database system uniformly
CN1786925A (en) TTCN-3 testing system basedon C++ mapping and its testing method
Pennello Very fast LR parsing
CN112099798B (en) Method and device for counting time consumption of public function execution, storage medium and terminal
CN1716246A (en) Multi-column multi-data type internationalized sort extension method for WEB applications
CN101046761A (en) Device and method for fetching snapshot data
CN1976320A (en) Data access control method and system
CN1492361A (en) Processing method for embedded data bank searching
CN1896957A (en) Method for leaking memory of positioning virtual operation system
CN1295778C (en) Method for verifying consistency of chip hardware behavior and software simulation behavior
CN101055542A (en) Symbol debug method and system in cross integration development environment
CN1295613C (en) Method for general windows program to operate journal information record
CN1156860A (en) Computer system
CN111427695A (en) Concurrent scheduling device for storage process in distributed database

Legal Events

Date Code Title Description
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
ASS Succession or assignment of patent right

Owner name: SHENZHENG CITY ZTE CO., LTD.

Free format text: FORMER OWNER: SHENZHENG CITY ZTE CO., LTD. SHANGHAI SECOND INSTITUTE

Effective date: 20010912

C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20010912

Address after: 518057, Guangdong province Shenzhen Nanshan District hi tech Industrial Park, science and technology south road, ZTE building A block 6 floor of the legal department

Applicant after: Zhongxing Communication Co., Ltd., Shenzhen City

Address before: 200233 No. 396, Shanghai, Guilin Road

Applicant before: Shanghai Inst. of No.2, Zhongxing Communication Co., Ltd., Shenzhen City

C06 Publication
PB01 Publication
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20040728

Termination date: 20171228