CN108287777A - A kind of method and device of record log - Google Patents

A kind of method and device of record log Download PDF

Info

Publication number
CN108287777A
CN108287777A CN201711442132.XA CN201711442132A CN108287777A CN 108287777 A CN108287777 A CN 108287777A CN 201711442132 A CN201711442132 A CN 201711442132A CN 108287777 A CN108287777 A CN 108287777A
Authority
CN
China
Prior art keywords
log
log information
types
current
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201711442132.XA
Other languages
Chinese (zh)
Inventor
王豪森
王颖
卢永列
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Inspur Genersoft Information Technology Co Ltd
Original Assignee
Shandong Inspur Genersoft Information Technology 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 Shandong Inspur Genersoft Information Technology Co Ltd filed Critical Shandong Inspur Genersoft Information Technology Co Ltd
Priority to CN201711442132.XA priority Critical patent/CN108287777A/en
Publication of CN108287777A publication Critical patent/CN108287777A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3096Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents wherein the means or processing minimize the use of computing system or of computing system component resources, e.g. non-intrusive monitoring which minimizes the probe effect: sniffing, intercepting, indirectly deriving the monitored data from other directly available data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3476Data logging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Computer Hardware Design (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention provides a kind of method and device of record log, this method, including:It is pre-configured with the configuration file of the daily record for intended application;When starting the intended application, daily record thread and journal queue are created, wherein the journal queue is used to store the externally input log information of the journal queue;It is executed using the daily record thread:The journal queue is detected in real time and whether there is log information, if it is, obtaining current log information from the journal queue, reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.The present invention provides a kind of method and devices of record log, can improve the runnability of application.

Description

A kind of method and device of record log
Technical field
The present invention relates to field of computer technology, more particularly to a kind of method and device of record log.
Background technology
Daily record corresponds to be very important for an application, by daily record it will be seen that the operating condition of application.
In the prior art, the record of the daily record of application is mainly realized by the main thread of application.That is, application Main thread records the daily record of application in the also oriented disk of major function in addition to complete application, and the process of record log needs Resource is occupied, and then main thread is caused this process to be influenced by record log when completing the major function of application, into And reduce the runnability of application.
Invention content
An embodiment of the present invention provides a kind of method and devices of record log, can improve the runnability of application.
On the one hand, an embodiment of the present invention provides a kind of methods of record log, including:
It is pre-configured with the configuration file of the daily record for intended application;
When starting the intended application, daily record thread and journal queue are created, wherein the journal queue is for storing The externally input log information of the journal queue;
It is executed using the daily record thread:
The journal queue is detected in real time and whether there is log information, is worked as if it is, being obtained from the journal queue Preceding log information reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.
Further,
The configuration file includes:For the corresponding storage class of the Log Types of each at least one Log Types Type, wherein each log information corresponds to the Log Types, and the storage class includes:Disk file type, number According to library type;
Described after obtaining current log information in the journal queue, further comprise:
Determine the corresponding current log type of the current log information;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
Determine the corresponding currently stored type of the current log type;
When the currently stored type is the disk file type,
It will be in the current log information persistent storage to disk file;
When the currently stored type is the type of database,
It will be in the current log information persistent storage to database.
Further,
This method further comprises:
It is the corresponding log folder of each module setting of the intended application in advance;
Described after obtaining current log information in the journal queue, further comprise:
Determine the current block for generating the current log information;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
According to the configuration file by the current log information persistent storage to the corresponding daily record of the current block In file.
Further,
This method further comprises:
Startup program is set in the beginning event of the intended application in advance;
It is described to create daily record thread and journal queue when starting the intended application, including:
When starting the intended application, the startup program in the beginning event is executed;
The daily record thread and the journal queue are created using the startup program.
Further,
This method further comprises:
Corresponding log interface is set for each described Log Types at least one Log Types in advance;
Further comprise:
When the intended application calls either objective log interface at least one log interface,
The log information of the corresponding target journaling type of the target journaling interface is obtained using the target journaling interface, The log information of the target journaling type is input in the journal queue.
Further,
The configuration file further comprises:The configuration information of log sheet in the database;
After the reading configuration file, further comprise:
The log sheet is generated according to the configuration information of the log sheet;
It is described by the current log information persistent storage to database, including:
By the current log information according in the configuration information persistent storage to the log sheet of the log sheet.
Further,
The storage class further comprises:All types;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
When the currently stored type is all types,
The current log information is distinguished in persistent storage to disk file and database.
Further,
It is described at least one Log Types include:The Log Types of Debugging message, the Log Types of information, warning letter One or more of the Log Types of the Log Types of breath, the Log Types of error message and fatal error message.
On the other hand, an embodiment of the present invention provides a kind of devices of record log, including:
Dispensing unit, for configuration pin to the configuration file of the daily record of intended application;
Creating unit, for when starting the intended application, creating daily record thread and journal queue, wherein the day Will queue is used to store the externally input log information of the journal queue;
Recording unit, for being executed using the daily record thread:
The journal queue is detected in real time and whether there is log information, is worked as if it is, being obtained from the journal queue Preceding log information reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.
Further,
The configuration file includes:For the corresponding storage class of the Log Types of each at least one Log Types Type, wherein each log information corresponds to the Log Types, and the storage class includes:Disk file type, number According to library type;
The recording unit is further used for described after obtaining current log information in the journal queue, really Determine the corresponding current log type of the current log information;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage When, it is specifically used for executing:
Determine the corresponding currently stored type of the current log type;
When the currently stored type is the disk file type,
It will be in the current log information persistent storage to disk file;
When the currently stored type is the type of database,
It will be in the current log information persistent storage to database.
Further,
The device further comprises:
First setting unit, for corresponding log folder to be arranged for each module of the intended application;
The recording unit is further used for described after obtaining current log information in the journal queue, really Surely the current block of the current log information is generated;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage When, it is specifically used for the current log information persistent storage to the current block corresponding day according to the configuration file In will file.
Further,
The device further comprises:
Second setting unit, for startup program to be arranged in the beginning event of the intended application;
The creating unit, for when starting the intended application, executing the startup journey in the beginning event Sequence;The daily record thread and the journal queue are created using the startup program.
Further,
The device further comprises:
Second setting unit, for corresponding daily record to be arranged for each described Log Types at least one Log Types Interface;
Further comprise:
Input unit, for calling either objective log interface at least one log interface when the intended application When, the log information of the corresponding target journaling type of the target journaling interface is obtained using the target journaling interface, by institute The log information for stating target journaling type is input in the journal queue.
Further,
The configuration file further comprises:The configuration information of log sheet in the database;
The recording unit was further used for after the reading configuration file, according to matching for the log sheet Confidence breath generates the log sheet;
The recording unit, execute it is described by the current log information persistent storage to database when, specifically For by the current log information according in the configuration information persistent storage to the log sheet of the log sheet.
Further,
The storage class further comprises:All types;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage When, it is specifically used for executing:
When the currently stored type is all types,
The current log information is distinguished in persistent storage to disk file and database.
Further,
It is described at least one Log Types include:The Log Types of Debugging message, the Log Types of information, warning letter One or more of the Log Types of the Log Types of breath, the Log Types of error message and fatal error message.
In embodiments of the present invention, when starting intended application, daily record thread is created, is deposited come persistence using daily record thread Log information is stored up, is realized without the main thread by intended application, the resource of the main thread without occupying intended application will not The runnability for influencing intended application improves the operation of intended application compared with using main thread come the scheme of record log Performance.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described, it should be apparent that, the accompanying drawings in the following description is the present invention Some embodiments for those of ordinary skill in the art without creative efforts, can also basis These attached drawings obtain other attached drawings.
Fig. 1 is a kind of flow chart of the method for record log that one embodiment of the invention provides;
Fig. 2 is the flow chart of the method for another record log that one embodiment of the invention provides;
Fig. 3 is a kind of schematic diagram of the device for record log that one embodiment of the invention provides;
Fig. 4 is the schematic diagram of the device for another record log that one embodiment of the invention provides.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is A part of the embodiment of the present invention, instead of all the embodiments, based on the embodiments of the present invention, those of ordinary skill in the art The every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
As shown in Figure 1, an embodiment of the present invention provides a kind of method of record log, this method may include following step Suddenly:
Step 101:It is pre-configured with the configuration file of the daily record for intended application;
Step 102:When starting the intended application, daily record thread and journal queue are created, wherein the journal queue Externally input log information for storing the journal queue;
Step 103:It is executed using the daily record thread:
The journal queue is detected in real time and whether there is log information, is worked as if it is, being obtained from the journal queue Preceding log information reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.
In embodiments of the present invention, when starting intended application, daily record thread is created, is deposited come persistence using daily record thread Log information is stored up, is realized without the main thread by intended application, the resource of the main thread without occupying intended application will not The runnability for influencing intended application improves the operation of intended application compared with using main thread come the scheme of record log Performance.
In an embodiment of the present invention, the configuration file includes:Described in each at least one Log Types The corresponding storage class of Log Types, wherein each log information corresponds to the Log Types, the storage class Including:Disk file type, type of database;
Described after obtaining current log information in the journal queue, further comprise:
Determine the corresponding current log type of the current log information;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
Determine the corresponding currently stored type of the current log type;
When the currently stored type is the disk file type,
It will be in the current log information persistent storage to disk file;
When the currently stored type is the type of database,
It will be in the current log information persistent storage to database.
In embodiments of the present invention, it is that each Log Types configures storage class by configuration file.Disk file type Refer to that log information is stored as disk file.Type of database refers to the table being stored as log information in database.
In one implementation, it in the input journal information into journal queue, also inputs each log information and corresponds to Log Types.The corresponding current log type of current log information is obtained from journal queue using daily record thread.
In an embodiment of the present invention, this method further comprises:
It is the corresponding log folder of each module setting of the intended application in advance;
Described after obtaining current log information in the journal queue, further comprise:
Determine the current block for generating the current log information;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
According to the configuration file by the current log information persistent storage to the corresponding daily record of the current block In file.
For an application, multiple modules can be stored, can be that a log folder is arranged in each module.
In one implementation, the information (example for the module for generating the log information can be carried in each log information Such as:The mark of module), the corresponding module of the log information can be determined by the information of the module carried in log information.
In an embodiment of the present invention, this method further comprises:
Startup program is set in the beginning event of the intended application in advance;
It is described to create daily record thread and journal queue when starting the intended application, including:
When starting the intended application, the startup program in the beginning event is executed;
The daily record thread and the journal queue are created using the startup program.
In embodiments of the present invention, startup program is arranged in the beginning event of intended application, when startup intended application When, beginning event will be run, and then startup program can be executed.When creating journal queue, a journal queue can be created It is shared for various log informations, at least two journal queues can also be created.
In an embodiment of the present invention, this method further comprises:
Corresponding log interface is set for each described Log Types at least one Log Types in advance;
Further comprise:
When the intended application calls either objective log interface at least one log interface,
The log information of the corresponding target journaling type of the target journaling interface is obtained using the target journaling interface, The log information of the target journaling type is input in the journal queue.
In embodiments of the present invention, at least one log interface is pre-set, intended application can need record log At least one log interface of call by location, specifically, when some module of intended application needs record log, which is At least one log interface can be called.When calling log interface, the Log Types of the daily record that can be recorded as needed select Select corresponding log interface.
For example, at least one Log Types include:The Log Types of Debugging message, the Log Types of information, The Log Types of the Log Types of warning message, the Log Types of error message and fatal error message, per middle Log Types pair The log interface answered is as follows:
SharpLog.SharpLoger.Debug (" record Debugging message ", " debugging ");
SharpLog.SharpLoger.Info (" record prompt message ", " prompt ");
SharpLog.SharpLoger.Error (" misregistration information ", " mistake ");
SharpLog.SharpLoger.Fatal (" record fatal error message ", " serious error ");
SharpLog.SharpLoger.Warn (" record warning message ", " warning ");
In an embodiment of the present invention, the configuration file further comprises:The configuration of log sheet in the database Information;
After the reading configuration file, further comprise:
The log sheet is generated according to the configuration information of the log sheet;
It is described by the current log information persistent storage to database, including:
By the current log information according in the configuration information persistent storage to the log sheet of the log sheet.
It in embodiments of the present invention, can be with the daily record for storing log information in configuration database by configuration file Table.The configuration information of log sheet specifically includes:The title of table, the major key field of table, the message field of table, the timestamp field of table Deng.
In an embodiment of the present invention, the storage class further comprises:All types;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
When the currently stored type is all types,
The current log information is distinguished in persistent storage to disk file and database.
In embodiments of the present invention, log information can be stored in disk file and database simultaneously.
In an embodiment of the present invention, the path of disk file can be configured by configuration file.
In an embodiment of the present invention, at least one Log Types include:Log Types, the message letter of Debugging message The Log Types of breath, the Log Types of warning message, the Log Types of error message and fatal error message Log Types in One or more.
Specifically, the Log Types of Debugging message correspond to the daily record of Debugging message, and the Log Types correspondence of information disappears The daily record of information is ceased, the Log Types of warning message correspond to the daily record of warning message, and the Log Types of error message correspond to mistake The daily record of information and the Log Types of fatal error message correspond to the daily record of fatal error message.
As shown in Fig. 2, an embodiment of the present invention provides a kind of method of record log, this method may include following step Suddenly:
Step 201:It is pre-configured with the configuration file of the daily record for intended application, configuration file includes:For at least In a kind of Log Types in the corresponding storage class of each Log Types and database log sheet configuration information, wherein it is every A log information corresponds to a Log Types, and storage class includes:Disk file type, type of database and all types.
For example, configuration file can be as shown in table 1.
Table 1
As can be seen from the above description, the daily record for whether recording some Log Types, example can also be configured by configuration file Such as:When setting debug to true, the daily record of Debugging message is stored, when setting debug to false, does not store debugging The daily record of information.
Based on the configuration file of table 1, storage class can be set in the following manner:It is with the Log Types of Debugging message Example, when debugStorageType is set as 0, storage class is all types, is arranged when by debugStorageType When being 1, storage class is disk file type, and when debugStorageType is set as 2, storage class is class database Type.
By the way that logLevelField is arranged, the corresponding Log Types of log information of log sheet storage can be set, such as: It sets logLevelField to the Log Types of Debugging message, then stores the daily record of Debugging message in the log sheet.
For example, tableName=logMsg, pkField=id can be set, that is to say, that the title of log sheet Major key field for logMsg, log sheet is id.
Step 202:Startup program is set in the beginning event of intended application in advance.
Since application can run beginning event first on startup, can be made by the way that startup program is arranged in beginning event It obtains startup program with the startup of intended application to start, and then the daily record of intended application can be recorded in time.
Step 203:When starting intended application, the startup program in beginning event is executed.
Step 204:Daily record thread and journal queue are created using startup program.
Daily record thread is created exclusively for record log by startup program, avoids remembering in using the main thread of intended application Record daily record.
Step 205:Journal queue is detected in real time using daily record thread and whether there is log information, if it is, executing step Rapid 206.
Step 206:Current log information is obtained from journal queue using daily record thread.
Specifically, when storing log information in journal queue, the log information in journal queue can be obtained one by one.
Step 207:The corresponding current log type of current log information is determined using daily record thread.
Step 208:Configuration file is read using daily record thread.
Step 209:Using daily record thread log sheet is generated according to the configuration information of log sheet.
Specifically, the configuration information of log sheet includes:The title of log sheet, the major key field of log sheet, log sheet disappear Cease field, timestamp field of log sheet etc..
Step 210:The corresponding currently stored type of current log type is determined using daily record thread.
Specifically, currently stored type is determined according to configuration file.
Step 211:When currently stored type is disk file type, by current log information persistent storage to disk In file.
Step 212:When currently stored type is type of database, current log information is matched into confidence according to log sheet It ceases in persistent storage to log sheet.
Step 213:When currently stored type is all types, by current log information persistent storage to disk file In, and by current log information according in the configuration information persistent storage to log sheet of log sheet.
Through the embodiment of the present invention, in the case of high concurrent, high flow capacity, when carrying out persistence daily record, it will not reduce and answer Response performance.
In an embodiment of the present invention, log information can be positioned by the daily record monitoring module of server-side, real-time searching, To ensure quick tracing-positioning system operating condition.
Based on configuration file shown in table 1, the configuration file can be configured by following code:
As shown in Figure 3, Figure 4, an embodiment of the present invention provides a kind of devices of record log.Device embodiment can pass through Software realization can also be realized by way of hardware or software and hardware combining.For hardware view, as shown in figure 3, for this A kind of hardware structure diagram of equipment where a kind of device for record log that inventive embodiments provide, in addition to processing shown in Fig. 3 Except device, memory, network interface and nonvolatile memory, the equipment in embodiment where device usually can also include Other hardware, such as it is responsible for the forwarding chip of processing message.For implemented in software, as shown in figure 4, anticipating as a logic Device in justice is to be read corresponding computer program instructions in nonvolatile memory by the CPU of equipment where it Operation is formed in memory.A kind of device of record log provided in this embodiment, including:
Dispensing unit 401, for configuration pin to the configuration file of the daily record of intended application;
Creating unit 402, for when starting the intended application, creating daily record thread and journal queue, wherein described Journal queue is used to store the externally input log information of the journal queue;
Recording unit 403, for being executed using the daily record thread:
The journal queue is detected in real time and whether there is log information, is worked as if it is, being obtained from the journal queue Preceding log information reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.
In an embodiment of the present invention, the configuration file includes:Described in each at least one Log Types The corresponding storage class of Log Types, wherein each log information corresponds to the Log Types, the storage class Including:Disk file type, type of database;
The recording unit is further used for described after obtaining current log information in the journal queue, really Determine the corresponding current log type of the current log information;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage When, it is specifically used for executing:
Determine the corresponding currently stored type of the current log type;
When the currently stored type is the disk file type,
It will be in the current log information persistent storage to disk file;
When the currently stored type is the type of database,
It will be in the current log information persistent storage to database.
In an embodiment of the present invention, which further comprises:
First setting unit, for corresponding log folder to be arranged for each module of the intended application;
The recording unit is further used for described after obtaining current log information in the journal queue, really Surely the current block of the current log information is generated;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage When, it is specifically used for the current log information persistent storage to the current block corresponding day according to the configuration file In will file.
In an embodiment of the present invention, which further comprises:
Second setting unit, for startup program to be arranged in the beginning event of the intended application;
The creating unit, for when starting the intended application, executing the startup journey in the beginning event Sequence;The daily record thread and the journal queue are created using the startup program.
In an embodiment of the present invention, which further comprises:
Second setting unit, for corresponding daily record to be arranged for each described Log Types at least one Log Types Interface;
Further comprise:
Input unit, for calling either objective log interface at least one log interface when the intended application When, the log information of the corresponding target journaling type of the target journaling interface is obtained using the target journaling interface, by institute The log information for stating target journaling type is input in the journal queue.
In an embodiment of the present invention, the configuration file further comprises:The configuration of log sheet in the database Information;
The recording unit was further used for after the reading configuration file, according to matching for the log sheet Confidence breath generates the log sheet;
The recording unit, execute it is described by the current log information persistent storage to database when, specifically For by the current log information according in the configuration information persistent storage to the log sheet of the log sheet.
In an embodiment of the present invention, the storage class further comprises:All types;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage When, it is specifically used for executing:
When the currently stored type is all types,
The current log information is distinguished in persistent storage to disk file and database.
In an embodiment of the present invention, at least one Log Types include:Log Types, the message letter of Debugging message The Log Types of breath, the Log Types of warning message, the Log Types of error message and fatal error message Log Types in One or more.
The contents such as the information exchange between each unit, implementation procedure in above-mentioned apparatus, due to implementing with the method for the present invention Example is based on same design, and particular content can be found in the narration in the method for the present invention embodiment, and details are not described herein again.
An embodiment of the present invention provides a kind of readable mediums, including execute instruction, when the processor of storage control executes The method that when executing instruction, the storage control executes any one record log provided in an embodiment of the present invention.
An embodiment of the present invention provides a kind of storage controls, including:Processor, memory and bus;
The memory is executed instruction for storing, and the processor is connect with the memory by the bus, when When the storage control operation, the processor executes executing instruction for the memory storage, so that the storage controls The method that device executes any one record log provided in an embodiment of the present invention.
The each embodiment of the present invention at least has the advantages that:
1, in embodiments of the present invention, when starting intended application, daily record thread is created, using daily record thread come persistence Log information is stored, is realized without the main thread by intended application, the resource of the main thread without occupying intended application, no The runnability that can influence intended application improves the fortune of intended application compared with using main thread come the scheme of record log Row performance.
2, in embodiments of the present invention, in the case of high concurrent, high flow capacity, when carrying out persistence daily record, can pass through The daily record thread for being specifically used to record log carrys out record log, will not reduce the response performance of application.
It should be noted that herein, such as first and second etc relational terms are used merely to an entity Or operation is distinguished with another entity or operation, is existed without necessarily requiring or implying between these entities or operation Any actual relationship or order.Moreover, the terms "include", "comprise" or its any other variant be intended to it is non- It is exclusive to include, so that the process, method, article or equipment including a series of elements includes not only those elements, But also include other elements that are not explicitly listed, or further include solid by this process, method, article or equipment Some elements.In the absence of more restrictions, the element limited by sentence " including one ", is not arranged Except there is also other identical factors in the process, method, article or apparatus that includes the element.
One of ordinary skill in the art will appreciate that:Realize that all or part of step of above method embodiment can pass through The relevant hardware of program instruction is completed, and program above-mentioned can be stored in computer-readable storage medium, the program When being executed, step including the steps of the foregoing method embodiments is executed;And storage medium above-mentioned includes:ROM, RAM, magnetic disc or light In the various media that can store program code such as disk.
Finally, it should be noted that:The foregoing is merely presently preferred embodiments of the present invention, is merely to illustrate the skill of the present invention Art scheme, is not intended to limit the scope of the present invention.Any modification for being made all within the spirits and principles of the present invention, Equivalent replacement, improvement etc., are included within the scope of protection of the present invention.

Claims (10)

1. a kind of method of record log, which is characterized in that
It is pre-configured with the configuration file of the daily record for intended application;
Including:
When starting the intended application, daily record thread and journal queue are created, wherein the journal queue is described for storing The externally input log information of journal queue;
It is executed using the daily record thread:
The journal queue is detected in real time and whether there is log information, works as the day before yesterday if it is, being obtained from the journal queue Will information reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.
2. according to the method described in claim 1, it is characterized in that,
The configuration file includes:For the corresponding storage class of the Log Types of each at least one Log Types, Wherein, each log information corresponds to the Log Types, and the storage class includes:Disk file type, data Library type;
Described after obtaining current log information in the journal queue, further comprise:
Determine the corresponding current log type of the current log information;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
Determine the corresponding currently stored type of the current log type;
When the currently stored type is the disk file type,
It will be in the current log information persistent storage to disk file;
When the currently stored type is the type of database,
It will be in the current log information persistent storage to database.
3. according to the method described in claim 1, it is characterized in that,
Further comprise:
It is the corresponding log folder of each module setting of the intended application in advance;
Described after obtaining current log information in the journal queue, further comprise:
Determine the current block for generating the current log information;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
According to the configuration file by the current log information persistent storage to the corresponding journal file of the current block In folder.
4. according to any method in claim 1-3, which is characterized in that
Further comprise:
Startup program is set in the beginning event of the intended application in advance;
It is described to create daily record thread and journal queue when starting the intended application, including:
When starting the intended application, the startup program in the beginning event is executed;
The daily record thread and the journal queue are created using the startup program.
5. according to the method described in claim 2, it is characterized in that,
Further comprise:
Corresponding log interface is set for each described Log Types at least one Log Types in advance;
Further comprise:
When the intended application calls either objective log interface at least one log interface,
The log information that the corresponding target journaling type of the target journaling interface is obtained using the target journaling interface, by institute The log information for stating target journaling type is input in the journal queue;
And/or
The configuration file further comprises:The configuration information of log sheet in the database;
After the reading configuration file, further comprise:
The log sheet is generated according to the configuration information of the log sheet;
It is described by the current log information persistent storage to database, including:
By the current log information according in the configuration information persistent storage to the log sheet of the log sheet;
And/or
The storage class further comprises:All types;
It is described that persistent storage is carried out to current log information according to the configuration file, including:
When the currently stored type is all types,
The current log information is distinguished in persistent storage to disk file and database;
And/or
It is described at least one Log Types include:The Log Types of Debugging message, the Log Types of information, warning message One or more of the Log Types of Log Types, the Log Types of error message and fatal error message.
6. a kind of device of record log, which is characterized in that including:
Dispensing unit, for configuration pin to the configuration file of the daily record of intended application;
Creating unit, for when starting the intended application, creating daily record thread and journal queue, wherein the daily record team Arrange the externally input log information for storing the journal queue;
Recording unit, for being executed using the daily record thread:
The journal queue is detected in real time and whether there is log information, works as the day before yesterday if it is, being obtained from the journal queue Will information reads the configuration file, and persistent storage is carried out to current log information according to the configuration file.
7. device according to claim 6, which is characterized in that
The configuration file includes:For the corresponding storage class of the Log Types of each at least one Log Types, Wherein, each log information corresponds to the Log Types, and the storage class includes:Disk file type, data Library type;
The recording unit is further used for described after obtaining current log information in the journal queue, determines institute State the corresponding current log type of current log information;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage when, tool Body is for executing:
Determine the corresponding currently stored type of the current log type;
When the currently stored type is the disk file type,
It will be in the current log information persistent storage to disk file;
When the currently stored type is the type of database,
It will be in the current log information persistent storage to database.
8. device according to claim 6, which is characterized in that
Further comprise:
First setting unit, for corresponding log folder to be arranged for each module of the intended application;
The recording unit is further used for described after obtaining current log information in the journal queue, determines life At the current block of the current log information;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage when, tool Body is used for according to the configuration file that the current log information persistent storage is literary to the corresponding daily record of the current block In part folder.
9. according to any device in claim 6-8, which is characterized in that
Further comprise:
Second setting unit, for startup program to be arranged in the beginning event of the intended application;
The creating unit, for when starting the intended application, executing the startup program in the beginning event;Profit The daily record thread and the journal queue are created with the startup program.
10. device according to claim 7, which is characterized in that
Further comprise:
Second setting unit connects for being directed to the corresponding daily record of the Log Types setting of each at least one Log Types Mouthful;
Further comprise:
Input unit is used for when the intended application calls either objective log interface at least one log interface, The log information that the corresponding target journaling type of the target journaling interface is obtained using the target journaling interface, by the mesh The log information of mark Log Types is input in the journal queue;
And/or
The configuration file further comprises:The configuration information of log sheet in the database;
The recording unit, is further used for after the reading configuration file, matches confidence according to the log sheet Breath generates the log sheet;
The recording unit, execute it is described by the current log information persistent storage to database when, be specifically used for By the current log information according in the configuration information persistent storage to the log sheet of the log sheet;
And/or
The storage class further comprises:All types;
The recording unit, execute it is described according to the configuration file to current log information carry out persistent storage when, tool Body is for executing:
When the currently stored type is all types,
The current log information is distinguished in persistent storage to disk file and database;
And/or
It is described at least one Log Types include:The Log Types of Debugging message, the Log Types of information, warning message One or more of the Log Types of Log Types, the Log Types of error message and fatal error message.
CN201711442132.XA 2017-12-27 2017-12-27 A kind of method and device of record log Pending CN108287777A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711442132.XA CN108287777A (en) 2017-12-27 2017-12-27 A kind of method and device of record log

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711442132.XA CN108287777A (en) 2017-12-27 2017-12-27 A kind of method and device of record log

Publications (1)

Publication Number Publication Date
CN108287777A true CN108287777A (en) 2018-07-17

Family

ID=62832343

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711442132.XA Pending CN108287777A (en) 2017-12-27 2017-12-27 A kind of method and device of record log

Country Status (1)

Country Link
CN (1) CN108287777A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134658A (en) * 2019-04-09 2019-08-16 平安科技(深圳)有限公司 Log monitoring method, device, computer equipment and storage medium
CN110716908A (en) * 2019-09-29 2020-01-21 捷开通讯(深圳)有限公司 Log information writing method, system, storage medium and mobile terminal
CN111949472A (en) * 2019-05-17 2020-11-17 北京京东尚科信息技术有限公司 Method and device for recording application logs

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101087210A (en) * 2007-05-22 2007-12-12 网御神州科技(北京)有限公司 High-performance Syslog processing and storage method
CN101425034A (en) * 2008-08-11 2009-05-06 深圳市金蝶中间件有限公司 Log recording method and log system
CN105022751A (en) * 2014-04-28 2015-11-04 深圳华智融科技有限公司 Log recording method and system as well as log reproduction method and system
CN106156069A (en) * 2015-03-31 2016-11-23 北京畅游天下网络技术有限公司 Log system and log recording method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101087210A (en) * 2007-05-22 2007-12-12 网御神州科技(北京)有限公司 High-performance Syslog processing and storage method
CN101425034A (en) * 2008-08-11 2009-05-06 深圳市金蝶中间件有限公司 Log recording method and log system
CN105022751A (en) * 2014-04-28 2015-11-04 深圳华智融科技有限公司 Log recording method and system as well as log reproduction method and system
CN106156069A (en) * 2015-03-31 2016-11-23 北京畅游天下网络技术有限公司 Log system and log recording method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134658A (en) * 2019-04-09 2019-08-16 平安科技(深圳)有限公司 Log monitoring method, device, computer equipment and storage medium
CN110134658B (en) * 2019-04-09 2024-05-03 平安科技(深圳)有限公司 Log monitoring method, device, computer equipment and storage medium
CN111949472A (en) * 2019-05-17 2020-11-17 北京京东尚科信息技术有限公司 Method and device for recording application logs
CN110716908A (en) * 2019-09-29 2020-01-21 捷开通讯(深圳)有限公司 Log information writing method, system, storage medium and mobile terminal

Similar Documents

Publication Publication Date Title
US9069668B2 (en) Diagnosing distributed applications using application logs and request processing paths
US6334193B1 (en) Method and apparatus for implementing user-definable error handling processes
CN104809202B (en) A kind of method and apparatus of database synchronization
CN109299150A (en) A kind of configurable multi-data source adaptation rule engine solution
US20080065928A1 (en) Technique for supporting finding of location of cause of failure occurrence
CN108287777A (en) A kind of method and device of record log
CN110321383A (en) Big data platform method of data synchronization, device, computer equipment and storage medium
Jin et al. Efficient board-level functional fault diagnosis with missing syndromes
CN105159819B (en) A kind of method and system for recording kernel exception stack and Debugging message
CN105389314B (en) A kind of journal file inquiry system and querying method
CN106682036A (en) Data exchange system and exchange method thereof
CN109783315A (en) A kind of database platform automation method for inspecting and system
CN107704604A (en) A kind of information persistence method, server and computer-readable recording medium
JP4383484B2 (en) Message analysis apparatus, control method, and control program
CN106372160A (en) Distributive database and management method
JP5525225B2 (en) Failure cause analysis system and program
CN107844506A (en) A kind of method and device for realizing database and the data syn-chronization of caching
CN107682173B (en) Automatic fault positioning method and system based on transaction model
CN110231921A (en) Log Method of printing, device, equipment and computer readable storage medium
CN110309206A (en) Order information acquisition method and system
JP2013077124A (en) Software test case generation device
CN106156069B (en) Log system and log recording method
JP2013025632A (en) Disk controller, disk device abnormality detection method and program
CN116126619A (en) Database node information processing method and device
KR102275635B1 (en) Apparatus and method for detecting anomaly through function call pattern analysis

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180717