CN106156355B - Log processing method and device - Google Patents

Log processing method and device Download PDF

Info

Publication number
CN106156355B
CN106156355B CN201610600559.7A CN201610600559A CN106156355B CN 106156355 B CN106156355 B CN 106156355B CN 201610600559 A CN201610600559 A CN 201610600559A CN 106156355 B CN106156355 B CN 106156355B
Authority
CN
China
Prior art keywords
daily record
record data
level
preset condition
program
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.)
Active
Application number
CN201610600559.7A
Other languages
Chinese (zh)
Other versions
CN106156355A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201610600559.7A priority Critical patent/CN106156355B/en
Publication of CN106156355A publication Critical patent/CN106156355A/en
Application granted granted Critical
Publication of CN106156355B publication Critical patent/CN106156355B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/217Database tuning

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a kind of log processing method and devices;Method includes: the daily record data for obtaining program and exporting in the process of running;Identify different stage belonging to institute's output journal data;The state for detecting program operation determines the preset condition that the state of described program operation is met;At least one the daily record data of the daily record data, second level based on the corresponding first level of the preset condition forms journal file of the corresponding described program from bringing into operation to meeting during the preset condition;The mistake that the journal file based on period described at least one generates described program detects.The problem of implementing the present invention, capable of efficiently checking program emerged in operation comprehensively, and save the storage resource of log.

Description

Log processing method and device
Technical field
The present invention relates to the computer program technologies more particularly to log processing method and device of computer field.
Background technique
The exploitation of program (or system), test with and during actual motion, the log of logging program operation is extremely Close it is important, log can be used for being monitored the operating status of program and in program mal carry out problem investigation.
The various information in program operation process, the large size more complex for function are remembered in storage in log for applying The operation of record program can generate the very big log of data volume, this results in the need for comparable memory space to store log, storage sea On the one hand the log of amount can occupy a large amount of storage resource, and for the demand for saving storage resource, it can may only store recently The log of a period of time.This leads to following problems occur:
1) it due to not carrying out full dose storage to log, can only be asked based on the running log of nearest a period of time Topic investigation, and the historical problem of more long time (not storing the corresponding log of this time) can not be checked;
2) log for only storing a period of time, causes the problem lower for the frequency of occurrences to be also difficult to check in time.
Even if 3) the log that only storage program is run for a period of time recently, still can occupy a large amount of memory space, meanwhile, Also the efficiency for affecting investigation problem is handled the log of magnanimity.
Summary of the invention
The embodiment of the present invention provides a kind of log processing method and device, can efficiently check program emerged in operation comprehensively The problem of, and save the storage resource of log.
The technical solution of the embodiment of the present invention is achieved in that
In a first aspect, the embodiment of the present invention provides a kind of log processing method, which comprises
Obtain the daily record data that program exports in the process of running;
Identify different stage belonging to institute's output journal data;
The state for detecting program operation determines the preset condition that the state of described program operation is met;
The log number of the daily record data, second level based on the corresponding first level of the preset condition At least one according to, form journal file of the corresponding described program from bringing into operation to meeting during the preset condition;
The mistake that the journal file based on period described at least one generates described program detects.
Optionally, the daily record data for obtaining program and exporting in the process of running, comprising:
Call the daily record data of log device example record described program output;
It is described to identify different stage belonging to institute's output journal data, comprising:
Go out the daily record data of at least one following rank based on the rank keyword recognition that the daily record data carries: Debugging level;Error level;Levels of information;Alarm level.
Optionally, the state of the detection program operation determines the preset condition that the state of described program operation is met, Include:
When detecting that exception exits during described program operation, determines that the operating status of described program meets and operate normally The preset condition of end;
It detects when being exited extremely during described program operation, determine what the operating status satisfaction of described program exited extremely Preset condition.
Optionally, the preset condition that the state based on described program operation is met, is based on the preset condition pair At least one the daily record data of the first level answered, described daily record data of second level form the corresponding journey Journal file of the sequence from bringing into operation to meeting during the preset condition, comprising:
The journal file is written into the daily record data of the second level, when the operating status of described program meets When the preset condition exited extremely, the journal file is written into the daily record data of the first level, forms corresponding institute State journal file of the program from bringing into operation to meeting during the preset condition.
Optionally, described when the operating status of described program meets the preset condition exited extremely, by the first order The journal file, the corresponding described program of formation preset condition from bringing into operation to meeting is written in other daily record data During journal file, comprising:
The daily record data stacking of the first level identified from the daily record data exported is stored;
When the operating status of described program meets the preset condition exited extremely, stacking is read with the sequence that last in, first out Simultaneously the journal file is written in the daily record data of the first level of storage, forms correspondence described program from bringing into operation to expiring Journal file during the foot preset condition;
Empty the daily record data of the first level of stacking storage.
Optionally, the preset condition that the state based on described program operation is met, is based on the preset condition pair At least one the daily record data of the first level answered, described daily record data of second level form the corresponding journey Journal file of the sequence from bringing into operation to meeting during the preset condition, comprising:
The journal file is written into the daily record data of the second level, when the operating status of described program meets When operating normally the preset condition terminated, based on the daily record data for the second level that the journal file is written, shape Journal file at corresponding described program from bringing into operation to meeting during the preset condition.
Optionally, described when the operating status of described program meets the preset condition for operating normally and terminating, based on write-in The daily record data of the second level of the journal file, comprising:
The daily record data stacking of the first level identified from the daily record data exported is stored;
When the operating status of described program meets the preset condition for operating normally and terminating, described the of stacking storage is emptied The other daily record data of level-one;
Based on the daily record data for the second level that the journal file is written, corresponding described program is formed from starting to transport Row is to the journal file met during the preset condition.
Optionally, the first level is debugging level, at least one described following rank of second level: error level; Levels of information;Alarm level.
Second aspect, the embodiment of the present invention provide a kind of log processing device, and described device includes:
Acquiring unit, the daily record data exported in the process of running for obtaining program;
Recognition unit, for identification different stage belonging to institute's output journal data out;
It is pre- to determine that the state of described program operation is met for detecting the state of program operation for first detection unit If condition;
Log unit, for the daily record data based on the corresponding first level of the preset condition, the second level At least one other described daily record data, the corresponding described program of formation is from bringing into operation to meeting during the preset condition Journal file;
Second detection unit, the mistake that described program is generated for the journal file based on period described at least one Accidentally detected.
Optionally, the acquiring unit is also used to call the daily record data of log device example record described program output;
The recognition unit is also used to go out following rank at least based on the rank keyword recognition that the daily record data carries One of the daily record data: debugging level;Error level;Levels of information;Alarm level.
Optionally, the first detection unit determines when being also used to detect that exception exits during described program operation The operating status of described program meets the preset condition for operating normally and terminating;It detects and is exited extremely during described program operation When, determine that the operating status of described program meets the preset condition that exits extremely.
Optionally, the log unit is also used to that the log text is written the daily record data of the second level into Part, when the operating status of described program meets the preset condition exited extremely, by the daily record data of the first level The journal file is written, forms log text of the corresponding described program from bringing into operation to meeting during the preset condition Part.
Optionally, the log unit was also used to the day of the first level identified from the daily record data exported Will data stacking storage;When the operating status of described program meets the preset condition exited extremely, with the sequence that last in, first out It reads the daily record data of the first level of stacking storage and the journal file is written, form corresponding described program from the beginning of It runs to the journal file met during the preset condition;Empty the daily record data of the first level of stacking storage.
Optionally, the log unit is also used to that the log text is written the daily record data of the second level into Part, when the operating status of described program meets the preset condition for operating normally and terminating, based on the institute that the journal file is written The daily record data of second level is stated, the corresponding described program of formation is from bringing into operation to meeting during the preset condition Journal file.
Optionally, the log unit was also used to the day of the first level identified from the daily record data exported Will data stacking storage;When the operating status of described program meets the preset condition for operating normally and terminating, stacking storage is emptied The first level daily record data;Based on the daily record data for the second level that the journal file is written, formation pair Answer journal file of the described program from bringing into operation to meeting during the preset condition.
The third aspect, the embodiment of the present invention provide a kind of log processing device, and described device includes: that processor and storage are situated between Matter;The instruction executed for the processor is stored in the storage medium, the executable instruction is for causing the processing Device executes operation below:
Obtain the daily record data that program exports in the process of running;
Identify different stage belonging to institute's output journal data;
The state for detecting program operation determines the preset condition that the state of described program operation is met;
The log number of the daily record data, second level based on the corresponding first level of the preset condition At least one according to, form journal file of the corresponding described program from bringing into operation to meeting during the preset condition;
The mistake that the journal file based on period described at least one generates described program detects.
Fourth aspect, the embodiment of the present invention provide a kind of storage medium, are stored with executable instruction in the storage medium, The executable instruction is for executing log processing method provided in an embodiment of the present invention.
The embodiment of the present invention has the advantages that
1) journal file selectively is formed using the daily record data of more than one ranks, relatively utilizes the complete of program output Portion's daily record data forms journal file and obviously saves storage resource.It can also be deposited even if in the case where storage resource is extremely limited Store up the long-term running journal file of program.Thus, it is possible to based on program longtime running (for example, from program cloud platform it is online with During coming or during the entire test of program) journal file, it is lower to occurrence frequency in program operation process Mistake is checked, it is of course also possible to which the historical problem occurred to the operation of program earlier time is checked.
2) it according to the daily record data formation journal file of more than one ranks of the state dynamic select of program operation, not only saves Memory space is saved, and the daily record data based on the corresponding rank selection appropriate level of preset condition forms journal file, compared with base Journal file is formed in the daily record data of the fixed output a certain kind of program or several ranks, more can satisfy and mistake is checked to program Demand.
Detailed description of the invention
Fig. 1 is that the log to program provided in the embodiment of the present invention carries out the schematic diagram of roller processing;
Fig. 2 is an optional hardware structural diagram of log processing device in the embodiment of the present invention;
Fig. 3 is an optional application scenarios schematic diagram of log processing device in the embodiment of the present invention;
Fig. 4 is an optional flow diagram of log processing method in the embodiment of the present invention;
Fig. 5 is the optional flow diagram that journal file is formed in the embodiment of the present invention;
Fig. 6 is an optional logical functional structure schematic diagram of log processing device in the embodiment of the present invention.
Specific embodiment
The present invention is further described in detail below with reference to the accompanying drawings and embodiments.It should be appreciated that mentioned herein Embodiment is only used to explain the present invention, is not intended to limit the present invention.In addition, embodiment provided below is for implementing Section Example of the invention, rather than provide and implement whole embodiments of the invention, creation is not paid in those skilled in the art Property labour under the premise of, recombinate resulting embodiment to the technical solution of following embodiment and based on real to invention institute The other embodiments applied all belong to the scope of protection of the present invention.
It should be noted that in embodiments of the present invention, the terms "include", "comprise" or its any other variant are intended to Cover non-exclusive inclusion, so that including the method for a series of elements or device not only includes wanting of being expressly recited Element, but also including other elements that are not explicitly listed, or further include for implementation method or device intrinsic want Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including the element Method or device in there is also other relevant factor (such as the step in method or units in device).
Noun involved in the embodiment of the present invention and term are suitable for following explanation.
Function: in all kinds of programming languages, function is a kind of process, also referred to as subprogram, it executes a specified fortune It calculates or operates.Function has intrinsic function or canonical function, external function namely user-defined function etc..It can be by program or main letter Number calls.For example, in C language, the form of function is divided to without joining and have two classes of ginseng.Functional value is not taken back or taken back without ginseng function. There is ginseng function to have transmitting data (variable) between calling and being called.
Stack: (stack) also known as storehouse are a kind of data structures, and last in, first out, that is, finally enter the data of stack bullet at first Out.It is a kind of limited linear list of operation, limitation is to be only allowed in one end of table to be inserted into and deleted operation.This one end quilt The other end is relatively called stack bottom by referred to as stack top.It also referred to as pushes on to stack insertion new element, stacking or pop down, newly Element is put into the upper surface of stack top element, makes new stack top element;It also referred to as pops or pops off from a stack deletion element, It is that stack top element is deleted, and the element for keeping its adjacent becomes new stack top element.
Log: the result in each stage that logging program executes.
Variable: variable refer in the operational process of program at any time can changed amount, it is corresponding with constant.
In an embodiment of the invention, the running log as shown in Figure 1 to program is provided and carries out roller processing Scheme, referring to Fig. 1, each table represents the log that program is run in a cycle, in log database, only records nearest one In section time such as N (value of N is according to the actual situation such as available memory space, the length for the time for needing to monitor) a period The log of program operation: with the passage of program runtime, newest log (solid line table mark is written in log database Know), and outmoded log (dotted line table mark) is deleted, so that the data volume of the log stored in log database will not Occurs ever-increasing situation at any time.
If using log processing scheme shown in fig. 1, the prior art has at least the following problems:
1) log in log database be deleted after, then can not to program the corresponding period the operation problem It is checked.
2) problem lower for the frequency of occurrences, the log for being based only on nearest N number of period can not be checked comprehensively, be led The problem of cause can not be to program is checked in time.
It is needed in many cases from the log of longer time span to the operation monitoring of program or the investigation of problem, The time span of the log stored in log database is limited, and which increases the difficulty checked to program operation problem, causes The low problem of some occurrence frequencies can not be by timely investigation discovery, if to producing in the operational process of program in program operation process Raw log carries out full dose storage, then will lead to and occupy a large amount of storage resource, be equally difficult to carry out.
3) for some large-scale, complicated programs, the log in N number of period is only stored in log database immediately, Also a large amount of memory space can be occupied in log database, what the data of the log of magnanimity caused to run program using log The efficiency that problem is checked.
In view of the above-mentioned problems, the embodiment of the present invention provides log processing method, device and storage medium, by transporting to program The log exported in capable process carries out classification other places reason, when the operating status of program meets preset condition, according to it is default The daily record data of condition corresponding level forms journal file, by the corresponding rank of preset condition to the program for being in particular state The rank of required daily record data carries out dynamic control when carrying out mistake investigation, and so there is no need to utilize all rank always Daily record data forms journal file, even if forming journal file to program long-term running daily record data, can also reach section The effect of storage resource has been saved, meanwhile, it can also ensure that the journal file to be formed includes enough to the wrong row of program progress The daily record data looked into.
The embodiment of the present invention can provide the log processing device of log processing method and application log processing method, day Will processing unit can realize that Fig. 2 shows log processing devices 10 using the computing resource in server or server cluster An optional hardware structural diagram, comprising: processor 11, input/output interface 12 (such as display, keyboard, touch One or more of screen, Speaker Microphone), storage medium 13 and network interface 14, network interface is for supporting and outside The data of portion's equipment are transmitted, and component can be through 15 connection communication of system bus.
It should be pointed out that Fig. 2 shows log processing device 10 hardware configuration be all not it is required, can basis Actual conditions omit the hardware configuration of implementation section, alternatively, the hardware configuration of extension.In addition, hardware knot shown in Figure 2 Different physical locations is arranged in same physical location concentrated setting, or distribution in structure, and set-up mode flexibly selects as needed It selects.
The optional application scenarios schematic diagram of one of log processing device is as shown in figure 3, in Fig. 3, log processing device It is embodied as the server 10 for implementing log processing method, server 10 is flat by 30 program and cloud to cloud platform The log exported during the program operation of platform 40 carries out classification other places reason, meets preset condition in the operating status of program When, according to forming journal file with the daily record data of preset condition corresponding level and be stored in log database 20.It is needing When program is checked in the mistake that a certain period occurs based on the journal file in log database 20, below in conjunction with specific Flow diagram be illustrated.
One optional flow diagram of the log processing method shown referring to fig. 4, comprising the following steps:
Step 101, the daily record data that program exports in the process of running is obtained.
By taking Fig. 3 as an example, server 10 is called in log device (Logger) example record cloud platform 30 and cloud platform 40 The daily record data of program output, log device is the core component of log processing.With 5 kinds of normal levels (Level), comprising:
1) debugging level (static Level DEBUG)
DEBUG Level points out fine granularity message event, has effect to debugging routine.
2) levels of information (static Level INFO)
INFO level shows that message highlights the operational process of program on coarse grain level.
3) alarm level (static Level WARN)
WARN level shows the situation that will appear latent fault.
4) error level (static Level ERROR)
Although ERROR level points out that error event occurs, but still does not influence continuing to run for program.
5) severity level (static Level FATAL)
FATAL level points out that each grave error event will will lead to exiting for program.
In addition, there are two available special log ranks:
static Level ALL
ALL Level is the lowest class, is used to open all logs.
static Level OFF
OFF Level is highest level, for closing all logs.
The behavior of log device (Logger) is graduate.It is opened by the daily record data of appropriate level in control program It closes, can control the rank of the daily record data of program output, in the embodiment of the present invention, control program exports the log of all ranks Data, and it is selectively forming the journal file of log data.
Step 102, different stage belonging to institute's output journal data is identified.
By taking Fig. 3 as an example, the rank keyword that server is carried based on the program output journal data in cloud platform 30, identification The daily record data of above-mentioned rank out, similarly, server 10 are carried based on the daily record data of the program output in cloud platform 40 Keyword recognition goes out the rank of corresponding daily record data.
Step 103, the state of detection program operation determines the preset condition that the state of program operation is met.
Illustratively, preset condition is that program exception exits, normal program operation terminates.
In one embodiment, preset condition exits for program exception, correspondingly, when the state for detecting program operation is When exception exits, then decision procedure meets the preset condition exited extremely at this time.
In another embodiment, preset condition terminates for normal program operation, correspondingly, when in the operational process of program When not exporting the daily record data of FATAL rank, then it can be determined that program meets the preset condition of journey end of run.
Step 104, the preset condition that the state based on program operation is met, is based on the corresponding first level of preset condition Daily record data, at least one the daily record data of second level, form corresponding program from bringing into operation to preset condition is met The journal file of period.
Step 105, it is illustrated in conjunction with the example that different preset conditions forms corresponding journal file.
Example 1) preset condition exits for program exception
By taking Fig. 3 as an example, when abnormal the case where exiting occurs in the program in cloud platform 30, it is based on the debugging level (first order It is pre- to meeting from bringing into operation to form corresponding program for the daily record data of daily record data and severity level (second level) not) If the journal file during condition, here, severity level is any one rank that debugging level is removed in rank above-mentioned, such as Error level, levels of information, alarm level etc..
In one embodiment, when bringing into operation from program, once get the log number of the severity level of program output According to then by the daily record data write-in journal file of severity level.Also, when program exception exits (also with regard to the operating status of program When meeting the preset condition exited extremely), journal file is also written into the daily record data of debugging level, to be based on debugging level Daily record data and severity level daily record data, the phase of corresponding program preset condition to meeting from bringing into operation is collectively formed Between journal file.
Illustratively, corresponding journal file is written into the daily record data of debugging level when program exception exits in order to be lifted at Efficiency, before program does not exit extremely or program not running terminates, by program output debugging level daily record data with The mode of stack stores, i.e., after the daily record data that stores first read (last in, first out), while importance level being written in journal file Other daily record data when program exception exits, then reads from stack the debugging level of stacking storage with the mode that last in, first out Daily record data form corresponding program from bringing into operation to satisfaction in conjunction with the daily record data for the debugging level for having been written into log Journal file during preset condition.
Mode based on stack can be lifted at the efficiency needed to journal file write-in debugging level daily record data, meanwhile, Since the daily record data of severity level is synchronously written journal file, this guarantees the efficiency that journal file generates, especially In the case of being very big for the data volume of the daily record data of output, the delay for generating journal file can be significantly reduced.
In view of program generate daily record data data volume it is very big, from stack read debugging level daily record data it Afterwards, the daily record data that the first level of stacking storage can be emptied, to save storage resource.
Example 2) preset condition terminates for normal program operation
By taking Fig. 3 as an example, when abnormal the case where exiting occurs in the program in cloud platform 40, it is based on the severity level (second level Daily record data not) forms journal file of the corresponding program from bringing into operation to meeting during preset condition, here, important Rank is that any one rank of debugging level, such as error level, levels of information, alarm level are removed in rank above-mentioned.
In one embodiment, when bringing into operation from program, once get the log number of the severity level of program output According to, then journal file is written into the daily record data of severity level, until the end of the program, when program is exited there is no abnormal (when the preset condition for operating normally and terminating also being met with regard to the operating status of program), due to the program feelings that there is no exiting extremely Condition, therefore the daily record data for being not needed upon debugging level forms journal file, can be based only upon the daily record data of severity level Journal file of the corresponding program from bringing into operation to meeting during preset condition is formed, due to not by the log of debugging level Journal file is written in data, therefore significantly reduces the data volume of journal file.
Illustratively, before program does not exit extremely or program not running terminates, by the debugging level of program output Daily record data is stored in a manner of stack, i.e., after the daily record data that stores first read (last in, first out), while in journal file The daily record data of severity level is written, meanwhile, the log hand of the severity level of program output is synchronously written journal file, in this way At the end of normal program operation, due to do not need using debugging level daily record data formed journal file, then can empty into The daily record data of the first level of stack storage to save storage resource, and utilizes the severity level for having been written into journal file Daily record data, form journal file of the corresponding program from bringing into operation to meeting during preset condition, that is to say, that in journey At the end of sort run journey, the synchronized generation of corresponding journal file does not need to carry out additional processing again, improves log The formation efficiency of file can be obviously improved treatment effeciency for the program for generating a large amount of daily record datas.
Step 105, the mistake generated based on the journal file during at least one to program is detected.
Illustratively, aforementioned step is based in the wrong investigation of daily record data progress being operating abnormally during exiting using program Suddenly the daily record data for being stored with the debugging level during program is run in corresponding journal file is obtained, therefore program can be gone out The reason of existing mistake is accurately checked.
Illustratively, the wrong investigation of daily record data progress during terminating is being operated normally using program, is being based on aforementioned step Suddenly the daily record data for being stored with the severity level during program is run in corresponding journal file is obtained, therefore program can be gone out The existing investigation such as alarm level, error level.
The example for forming journal file in conjunction with one is illustrated, referring to one of the formation journal file shown in Fig. 5 Optional flow diagram obtains the daily record data of program output after running program, to the rank of the daily record data of output into Row judgement, if debugging level daily record data (such as variable, function name, function result etc.) if by the daily record data of debugging level Stacking storage, then records the daily record data of severity level if the daily record data of severity level, that is, write-in log File.
Meanwhile whether the operation for detecting program there is exception, if there is exception, needs the debugging level for storing stacking Daily record data journal file is written, form journal file of the program between this runtime.
If exception occurs in the operation that program is not detected, continues the daily record data for obtaining program output, judge whether to adjust It tries the daily record data of rank and performs corresponding processing, until meeting following one:
1) it detects that normal program operation terminates, utilizes the daily record data shape for the severity level that journal file has been recorded The journal file this time run at program.
2) it detects that program exception exits, the daily record data of the debugging level of stacking storage is popped, journal file is written, The journal file of program this time operation is formed together with the daily record data for the severity level having been written into journal file.
The case where inventor has found in the practice of the invention, and program exception exits in practical application is generally compared with program The number that operating normally terminates will lack, and therefore, the day of debugging level and severity level only be utilized at the end of program is operating abnormally Will data, which form journal file, will save significantly on storage resource, thus can also be with even if in the case where storage resource is extremely limited Store the long-term running journal file of program.It in turn, can be based on program longtime running (for example, online in cloud platform from program Since during or the entire test of program during) journal file, it is lower to occurrence frequency in program operation process Mistake checked, it is of course also possible to program earlier time operation occur historical problem check.
The functional structure of aforementioned log processing device is illustrated, referring to one of the log processing device shown in Fig. 6 Optional logical functional structure schematic diagram, it should be pointed out that the logical functional structure of log processing device shown in Fig. 6 is only It is merely exemplary, based on the logical functional structure shown in Fig. 6, those skilled in the art can carry out part to unit therein Merging or carry out further splitting and reorganizing.
In addition, each unit in logical functional structure shown in Fig. 6 can the realization of the hardware configuration as shown in Fig. 1.
In Fig. 6, log processing device 50 includes: acquiring unit 51, recognition unit 52, first detection unit 53, log Unit 54 and second detection unit 55, are below illustrated each unit.
Acquiring unit 51, the daily record data exported in the process of running for obtaining program, such as call log device example The daily record data of logging program output.
By taking Fig. 3 as an example, server 10 is called in log device (Logger) example record cloud platform 30 and cloud platform 40 The daily record data of program output, log device is the core component of log processing.With 5 kinds of normal levels (Level), comprising:
1) debugging level (static Level DEBUG)
2) levels of information (static Level INFO)
INFO level shows that message highlights the operational process of program on coarse grain level.
3) alarm level (static Level WARN)
4) error level (static Level ERROR)
5) severity level (static Level FATAL)
By the switch of the daily record data of appropriate level in control program, the grade of the daily record data of program output can control Not, in the embodiment of the present invention, control program exports the daily record data of all ranks, and is selectively forming log data Journal file.
Recognition unit 52, different stage belonging to institute's output journal data out for identification, for example, being taken based on daily record data The rank keyword recognition of band goes out the daily record data of at least one following rank: debugging level;Error level;Levels of information;It accuses Alert rank.
By taking Fig. 3 as an example, the rank keyword that recognition unit 52 is carried based on the program output journal data in cloud platform 10, Identify the daily record data of above-mentioned rank, similarly, daily record data of the recognition unit 52 based on the program output in cloud platform 30 The keyword recognition of carrying goes out the rank of corresponding daily record data.
First detection unit 53 determines that the state of program operation is met default for detecting the state of program operation Condition.
Illustratively, preset condition is that program exception exits, normal program operation terminates.
In one embodiment, preset condition exits for program exception, correspondingly, when first detection unit 53 detects journey When the state of sort run is abnormal exits, then decision procedure meets the preset condition exited extremely at this time.
In another embodiment, preset condition terminates for normal program operation, correspondingly, when first detection unit 53 is examined When measuring the daily record data for not exporting FATAL rank in the operational process of program, then it can be determined that program meets journey operation knot The preset condition of beam.
Log unit 54, the log number for daily record data, second level based on the corresponding first level of preset condition At least one according to, form journal file of the corresponding program from bringing into operation to meeting during preset condition.
Second detection unit 55, the mistake for being generated based on the journal file during at least one to program are examined It surveys.
In one embodiment, first detection unit 53 detects whether preset condition meets in this manner: Yu Jian It is abnormal when exiting during measuring program operation, determine that the operating status of program meets the preset condition for operating normally and terminating;Inspection When exiting extremely during measuring program operation, determine that the operating status of program meets the preset condition exited extremely.
It is illustrated in conjunction with example of the different preset conditions to the formation of journal file.
Example 1) preset condition exits for program exception
In one embodiment, work as program for journal file to be written in the daily record data of second level in log unit 54 Operating status when meeting the preset condition exited extremely, journal file is written into the daily record data of first level, is formed and is corresponded to Journal file of the program from bringing into operation to meeting during preset condition.
Illustratively, log unit 54 stores the daily record data of first level in a manner of stack: will be from the log exported The daily record data stacking of the first level identified in data stores;When the operating status of program meets the default item exited extremely When part, the daily record data of the first level of stacking storage is read with the sequence that last in, first out and journal file is written, is formed and is corresponded to Journal file of the program from bringing into operation to meeting during preset condition;Empty the log number of the first level of stacking storage According to.
Mode based on stack can be lifted at the efficiency needed to journal file write-in debugging level daily record data, meanwhile, Since the daily record data of severity level is synchronously written journal file, this guarantees the efficiency that journal file generates, especially In the case of being very big for the data volume of the daily record data of output, the delay for generating journal file can be significantly reduced.
In addition, it is very big in view of the data volume of the daily record data of program generation, in the log number for reading debugging level from stack According to the daily record data for the first level that stacking storage later, can be emptied, to save storage resource.
Example 2) preset condition terminates for normal program operation
In one embodiment, log unit 54 are also used to the daily record data of second level journal file is written, work as journey When the operating status of sequence meets the preset condition for operating normally and terminating, the log number of the second level based on write-in journal file According to journal file of the corresponding program of formation from bringing into operation to meeting during preset condition.
In one embodiment, when bringing into operation from program, once log unit 54 gets the importance level of program output Then journal file is written in the daily record data of severity level by other daily record data, until the end of the program, when program is not sent out Raw exception exits (when also meeting the preset condition for operating normally and terminating with regard to the operating status of program), since there is no different for program The case where often exiting, therefore the daily record data for being not needed upon debugging level forms journal file, can be based only upon severity level Daily record data form journal file of the corresponding program from bringing into operation to meeting during preset condition, due to there is no will to debug Journal file is written in the daily record data of rank, therefore significantly reduces the data volume of journal file.
Illustratively, log unit 54 stores the daily record data of first level in a manner of stack, does not exit extremely in program Or before program not running terminates, log unit 54 stores the daily record data for the debugging level that program exports in a manner of stack, The daily record data first stored is first read (last in, first out), while the daily record data of severity level being written in journal file, Meanwhile the log hand of the severity level of program output is synchronously written journal file, in this way at the end of normal program operation, by Journal file is formed in not needing the daily record data using debugging level, then can empty the log number of the first level of stacking storage According to, to save storage resource, and using the daily record data for the severity level for having been written into journal file, formed corresponding program from It brings into operation to the journal file met during preset condition, that is to say, that at the end of program runs journey, corresponding day The synchronized generation of will file, does not need to carry out additional processing again, improves the formation efficiency of journal file, big for generating For the program for measuring daily record data, treatment effeciency can be obviously improved.
Second detection unit 55, the mistake for being generated based on the journal file during at least one to program are examined It surveys.
Illustratively, aforementioned step is based in the wrong investigation of daily record data progress being operating abnormally during exiting using program Suddenly the daily record data for being stored with the debugging level during program is run in corresponding journal file is obtained, therefore program can be gone out The reason of existing mistake is accurately checked.
Illustratively, the wrong investigation of daily record data progress during terminating is being operated normally using program, is being based on aforementioned step Suddenly the daily record data for being stored with the severity level during program is run in corresponding journal file is obtained, therefore program can be gone out The existing investigation such as alarm level, error level.
The embodiment of the present invention at least realize it is following the utility model has the advantages that
1) journal file selectively is formed using the daily record data of more than one ranks, relatively utilizes the complete of program output Portion's daily record data forms journal file and obviously saves storage resource.It can also be deposited even if in the case where storage resource is extremely limited Store up the long-term running journal file of program.Thus, it is possible to based on program longtime running (for example, from program cloud platform it is online with During coming or during the entire test of program) journal file, it is lower to occurrence frequency in program operation process Mistake is checked, it is of course also possible to which the historical problem occurred to the operation of program earlier time is checked.
2) it according to the daily record data formation journal file of more than one ranks of the state dynamic select of program operation, not only saves Memory space is saved, and the daily record data based on the corresponding rank selection appropriate level of preset condition forms journal file, relatively makes The daily record data of the fixed output a certain kind of program or several ranks forms journal file, more can satisfy to program investigation mistake Demand.
If the module integrated described in the embodiment of the present invention is realized in the form of software function module and as independent production Product when selling or using, also can store in a computer readable storage medium.Based on this understanding, in the art Technical staff it should be appreciated that the embodiment of the present invention can provide as method, system or computer program product.Therefore, of the invention The form of complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used.Moreover, The present invention can be used real in the computer-usable storage medium that one or more includes wherein computer usable program code The form for the computer program product applied, the storage medium include but is not limited to USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk storage, CD-ROM, Optical memory etc..
The present invention be according to the method for the embodiment of the present invention, the flow chart of equipment (system) and computer program product and/ Or block diagram describes.It should be understood that each process that can be realized by computer program instructions in flowchart and/or the block diagram and/ Or the combination of the process and/or box in box and flowchart and/or the block diagram.It can provide these computer program instructions To general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices processor to generate one A machine so that by the instruction that the processor of computer or other programmable data processing devices executes generate for realizing The device for the function of being specified in one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates, Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one The step of function of being specified in a box or multiple boxes.
Although the embodiment of the present invention has been described, once a person skilled in the art knows basic creative general It reads, then additional changes and modifications can be made to these embodiments.So it includes embodiment that the following claims are intended to be interpreted as And fall into all change and modification of the scope of the invention.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.

Claims (11)

1. a kind of log processing method, which is characterized in that the described method includes:
Obtain the daily record data that program exports in the process of running;
Identify different stage belonging to institute's output journal data;
The state for detecting described program operation determines the preset condition that the state of described program operation is met;
The daily record data of the daily record data, second level based on the corresponding first level of the preset condition at least it One, form journal file of the corresponding described program from bringing into operation to meeting during the preset condition;
The mistake that the journal file based on period described at least one generates described program detects;
The preset condition that the state based on described program operation is met, is based on the preset condition corresponding described first At least one the daily record data of rank, described daily record data of second level form corresponding described program from bringing into operation To the journal file met during the preset condition, comprising:
The journal file is written into the daily record data of the second level, when the operating status of described program meets exception When the preset condition exited, the journal file is written into the daily record data of the first level, forms the corresponding journey Journal file of the sequence from bringing into operation to meeting during the preset condition;
Alternatively,
The journal file is written into the daily record data of the second level, when the operating status of described program meets normally When the preset condition of end of run, based on the daily record data for the second level that the journal file is written, formation pair Answer journal file of the described program from bringing into operation to meeting during the preset condition.
2. the method according to claim 1, wherein
The daily record data for obtaining program and exporting in the process of running, comprising:
Call the daily record data of log device example record described program output;
It is described to identify different stage belonging to institute's output journal data, comprising:
Go out the daily record data of at least one following rank: debugging based on the rank keyword recognition that the daily record data carries Rank;Error level;Levels of information;Alarm level.
3. the method according to claim 1, wherein the state of the detection program operation, determines described program The preset condition that the state of operation is met, comprising:
When detecting that exception exits during described program operation, determining that the operating status of described program meets to operate normally terminates Preset condition;
Detect during described program operation when exiting extremely, determine the operating status of described program meet exit extremely it is default Condition.
4. the method according to claim 1, wherein described when the operating status of described program meets abnormal exit Preset condition when, the journal file is written into the daily record data of the first level, formed corresponding described program from It brings into operation to the journal file met during the preset condition, comprising:
The daily record data stacking of the first level identified from the daily record data exported is stored;
When the operating status of described program meets the preset condition exited extremely, stacking storage is read with the sequence that last in, first out The first level daily record data and the journal file is written, form corresponding described program from bringing into operation to meeting State the journal file during preset condition;
Empty the daily record data of the first level of stacking storage.
5. the method according to claim 1, wherein described operate normally when the operating status of described program meets When the preset condition of end, the daily record data based on the second level that the journal file is written, comprising:
The daily record data stacking of the first level identified from the daily record data exported is stored;
When the operating status of described program meets the preset condition for operating normally and terminating, the first order of stacking storage is emptied Other daily record data;
Based on the daily record data for the second level that the journal file is written, formed corresponding described program from bring into operation to Meet the journal file during the preset condition.
6. the method according to claim 1, wherein
The first level is debugging level, at least one described following rank of second level: error level;Levels of information;It accuses Alert rank.
7. a kind of log processing device, which is characterized in that described device includes:
Acquiring unit, the daily record data exported in the process of running for obtaining program;
Recognition unit, for identification different stage belonging to the output journal data out;
First detection unit determines the default item that the state of described program operation is met for detecting the state of program operation Part;
Log unit, for based on the corresponding first level of the preset condition the daily record data, described in second level At least one daily record data forms log text of the corresponding described program from bringing into operation to meeting during the preset condition Part;
Second detection unit, for the journal file based on period described at least one to described program generate mistake into Row detection;
The log unit works as described program for the journal file to be written in the daily record data of the second level Operating status when meeting the preset condition exited extremely, the log text is written into the daily record data of the first level Part forms journal file of the corresponding described program from bringing into operation to meeting during the preset condition;
Alternatively,
For the journal file to be written in the daily record data of the second level, when the operating status of described program meets When operating normally the preset condition terminated, based on the daily record data for the second level that the journal file is written, shape Journal file at corresponding described program from bringing into operation to meeting during the preset condition.
8. device according to claim 7, which is characterized in that
The acquiring unit is also used to call the daily record data of log device example record described program output;
The recognition unit is also used to go out at least one following rank based on the rank keyword recognition that the daily record data carries The daily record data: debugging level;Error level;Levels of information;Alarm level.
9. device according to claim 7, which is characterized in that
The first detection unit determines described program when being also used to detect that exception exits during described program operation Operating status meets the preset condition for operating normally and terminating;Detect during described program operation when exiting extremely, determine described in The operating status of program meets the preset condition exited extremely.
10. device according to claim 7, which is characterized in that
The log unit is also used to deposit the daily record data stacking of the first level identified from the daily record data exported Storage;When the operating status of described program meets the preset condition exited extremely, stacking storage is read with the sequence that last in, first out The first level daily record data and the journal file is written, form corresponding described program from bringing into operation to meeting State the journal file during preset condition;Empty the daily record data of the first level of stacking storage.
11. device according to claim 7, which is characterized in that
The log unit is also used to deposit the daily record data stacking of the first level identified from the daily record data exported Storage;When the operating status of described program meets the preset condition for operating normally and terminating, the first order of stacking storage is emptied Other daily record data;Based on the daily record data for the second level that the journal file is written, formed corresponding described program from It brings into operation to the journal file met during the preset condition.
CN201610600559.7A 2016-07-27 2016-07-27 Log processing method and device Active CN106156355B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610600559.7A CN106156355B (en) 2016-07-27 2016-07-27 Log processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610600559.7A CN106156355B (en) 2016-07-27 2016-07-27 Log processing method and device

Publications (2)

Publication Number Publication Date
CN106156355A CN106156355A (en) 2016-11-23
CN106156355B true CN106156355B (en) 2019-02-01

Family

ID=58060987

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610600559.7A Active CN106156355B (en) 2016-07-27 2016-07-27 Log processing method and device

Country Status (1)

Country Link
CN (1) CN106156355B (en)

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649735B (en) * 2016-12-23 2020-01-10 腾讯科技(深圳)有限公司 Method and device for recording log data
CN108984362A (en) * 2017-05-31 2018-12-11 北京京东尚科信息技术有限公司 Log collection method and device, storage medium, electronic equipment
CN107678908B (en) * 2017-06-23 2020-07-31 平安科技(深圳)有限公司 Log recording method and device, computer equipment and storage medium
CN110109915B (en) * 2018-01-18 2024-01-05 伊姆西Ip控股有限责任公司 Method, apparatus and computer program product for managing hash tables
CN109144965A (en) * 2018-08-30 2019-01-04 百度在线网络技术(北京)有限公司 A kind of log processing method, device, equipment and medium
CN109361546B (en) * 2018-11-05 2022-03-29 视联动力信息技术股份有限公司 Program early warning method and device based on video network
CN110851415A (en) * 2019-11-13 2020-02-28 广州小鹏汽车科技有限公司 Log data processing method and device of vehicle-mounted system
CN113094225B (en) * 2020-01-09 2024-03-01 北京搜狗科技发展有限公司 Abnormal log monitoring method and device and electronic equipment
CN113434473A (en) * 2021-06-28 2021-09-24 上海浦东发展银行股份有限公司 Distributed log processing method, device, medium and electronic equipment
CN117130993A (en) * 2023-07-14 2023-11-28 华能信息技术有限公司 Efficient log cleaning method based on Web middleware
CN117093630B (en) * 2023-10-17 2024-01-26 无锡车联天下信息技术有限公司 Dynamic output method for abnormal log of vehicle-mounted system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101183333A (en) * 2007-12-12 2008-05-21 腾讯科技(深圳)有限公司 Method for outputting diary of debugging program, device and system
CN101464908A (en) * 2009-01-14 2009-06-24 北京北方微电子基地设备工艺研究中心有限责任公司 Log recording method and device
US7949746B1 (en) * 2007-05-02 2011-05-24 Sprint Spectrum L.P. Logging system for logging operation of a network platform
CN104253704A (en) * 2013-06-28 2014-12-31 腾讯科技(深圳)有限公司 Terminal log reporting method, device and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7949746B1 (en) * 2007-05-02 2011-05-24 Sprint Spectrum L.P. Logging system for logging operation of a network platform
CN101183333A (en) * 2007-12-12 2008-05-21 腾讯科技(深圳)有限公司 Method for outputting diary of debugging program, device and system
CN101464908A (en) * 2009-01-14 2009-06-24 北京北方微电子基地设备工艺研究中心有限责任公司 Log recording method and device
CN104253704A (en) * 2013-06-28 2014-12-31 腾讯科技(深圳)有限公司 Terminal log reporting method, device and system

Also Published As

Publication number Publication date
CN106156355A (en) 2016-11-23

Similar Documents

Publication Publication Date Title
CN106156355B (en) Log processing method and device
CN109189750B (en) Operation method, data analysis system and the storage medium of data analysis workflow
CN107480039B (en) Small file read-write performance test method and device for distributed storage system
CN105550113B (en) Web test method and test machine
CN108768728A (en) O&M task processing method, device, computer equipment and storage medium
CN109299178B (en) Model application method and data analysis system
JP2018045403A (en) Abnormality detection system and abnormality detection method
CN108205424A (en) Data migration method, device and electronic equipment based on disk
CN107861864A (en) Automated testing method, system and computer-readable recording medium
CN111881014B (en) System test method, device, storage medium and electronic equipment
CN110795357A (en) Program monitoring method and device
CN106610896A (en) Adaptive pressure testing method and device
CN113641526B (en) Alarm root cause positioning method and device, electronic equipment and computer storage medium
CN107679423A (en) Partition integrity inspection method and device
CN117234859B (en) Performance event monitoring method, device, equipment and storage medium
CN109558315A (en) The determination method, device and equipment of test scope
JP2009277110A (en) Software test/development support device, and program for device
US11681511B2 (en) Systems and methods for building and deploying machine learning applications
CN107239377A (en) The method and apparatus for obtaining Java Virtual Machine running status
CN115757138A (en) Method and device for determining script abnormal reason, storage medium and electronic equipment
CN114579252A (en) Method, system, storage medium and equipment for monitoring application state
CN112596750B (en) Application testing method and device, electronic equipment and computer readable storage medium
CN107590039A (en) A kind of continuous test method, device and storage medium
CN109800170B (en) Test method, test equipment and readable storage medium based on API test platform
CN114546793A (en) Log generation method and device and computer readable storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant