WO2018233170A1 - Method, device, computer device, and storage medium for recording a log - Google Patents

Method, device, computer device, and storage medium for recording a log Download PDF

Info

Publication number
WO2018233170A1
WO2018233170A1 PCT/CN2017/108061 CN2017108061W WO2018233170A1 WO 2018233170 A1 WO2018233170 A1 WO 2018233170A1 CN 2017108061 W CN2017108061 W CN 2017108061W WO 2018233170 A1 WO2018233170 A1 WO 2018233170A1
Authority
WO
WIPO (PCT)
Prior art keywords
log
function module
level
error information
historical
Prior art date
Application number
PCT/CN2017/108061
Other languages
French (fr)
Chinese (zh)
Inventor
陈杰
吴海波
姜云鹏
凌剑
马向东
丁杰
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2018233170A1 publication Critical patent/WO2018233170A1/en

Links

Images

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
    • G06F11/3072Monitoring arrangements determined by the means or processing involved in reporting the monitored data where the reporting involves data filtering, e.g. pattern matching, time or event triggered, adaptive or policy-based reporting
    • G06F11/3082Monitoring arrangements determined by the means or processing involved in reporting the monitored data where the reporting involves data filtering, e.g. pattern matching, time or event triggered, adaptive or policy-based reporting the data filtering being achieved by aggregating or compressing the monitored 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

Definitions

  • the present application relates to the field of computer processing, and in particular, to a log recording method, apparatus, computer device, and storage medium.
  • Logging plays an important role both in the development phase and in the testing phase.
  • One of the most important functions is to locate the problem by logging when an exception occurs.
  • the traditional log record uses the same log record granularity regardless of the state of the function modules in the server.
  • the traditional log records are often granular in granularity, resulting in the need to consume a large amount of resources for large log records.
  • a log recording method, apparatus, computer device, and storage medium are provided.
  • a logging method comprising:
  • Corresponding log records are performed according to the log level corresponding to each function module.
  • a logging device comprising:
  • An identifier obtaining module configured to acquire a function identifier corresponding to a function module running in the server
  • An extraction module configured to extract, according to the function identifier, a historical log record corresponding to each function module
  • a statistics module configured to collect historical error information corresponding to each function module according to historical log records corresponding to each function module
  • a determining module configured to determine, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record;
  • the recording module is configured to perform corresponding log records according to the log level corresponding to each function module.
  • a computer apparatus comprising a memory and a processor, the memory storing computer readable instructions, the computer readable instructions being executed by the processor such that the processor performs the following steps:
  • Corresponding log records are performed according to the log level corresponding to each function module.
  • One or more non-transitory readable storage mediums storing computer readable instructions, when executed by one or more processors, cause the one or more processors to perform the steps of: acquiring The function identifier corresponding to the function module running in the server;
  • Corresponding log records are performed according to the log level corresponding to each function module.
  • FIG. 1 is a schematic diagram showing the internal structure of a computer device in an embodiment
  • FIG. 2 is a flow chart of a logging method in an embodiment
  • FIG. 3 is a flow chart of a logging method in another embodiment
  • FIG. 5 is a flowchart of a method for performing corresponding log recording according to a log level corresponding to each functional module in an embodiment
  • Figure 6 is a block diagram showing the structure of a log recording apparatus in an embodiment
  • Figure 7 is a block diagram showing the structure of a log recording apparatus in another embodiment
  • Figure 8 is a block diagram showing the structure of a log recording apparatus in still another embodiment.
  • FIG. 1 is a schematic diagram of an internal structure of a computer device in an embodiment, and the computer device may be a server.
  • the computer device includes a processor, a non-volatile storage medium, an internal memory, and a network interface connected by a system bus.
  • the non-volatile storage medium of the computer device can store an operating system and computer readable instructions that, when executed, cause the processor to perform a logging method.
  • the processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device.
  • the internal memory can store computer readable instructions that, when executed by the processor, cause the processor to perform a logging method.
  • the network interface of the computer device is used for network communication.
  • FIG. 1 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device to which the solution of the present application is applied.
  • the specific computer device may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
  • a logging method comprising:
  • Step 202 Acquire a function identifier corresponding to a function module running in the server.
  • a function module refers to a program for implementing a certain functional task.
  • the function module may be abnormal during operation. In order to troubleshoot the cause of the abnormality, it is necessary to log in advance when the function module is running.
  • the log record is used to record the running status of the function module. For example, the record runs. Errors, warnings, etc., to facilitate subsequent troubleshooting based on the log records.
  • a server can often run multiple function modules.
  • Log records correspond to function modules.
  • Each function module corresponds to a corresponding log record program.
  • the function identifier is used to uniquely identify a function module. By obtaining the function identifier corresponding to the function module running in the server, it is convenient to find the corresponding historical log record according to the function identifier.
  • Step 204 Acquire a historical log record corresponding to each function module according to the function identifier.
  • the historical log record refers to the record of the operation of the previous function module
  • the log record information includes the error information that has appeared, and the error message can be further classified into a fatal error. Serious errors and common errors, of course, will also include some warning information and general information as well as various configuration information.
  • Each function module corresponds to a log record.
  • the function identifier of the function module is associated with the corresponding log record in advance, so that the history log record corresponding to the corresponding function module can be obtained according to the function identifier.
  • Step 206 Record historical error information corresponding to each functional module according to historical log records corresponding to each functional module.
  • the history log records the previous operation of the function module, including the error information that has appeared before.
  • the historical error information that occurred before the function module is counted by obtaining the history record corresponding to the function module.
  • the statistical history error information is used to know the pros and cons of the function module, and the pros and cons are used to evaluate the probability of a problem with the function module.
  • the historical log record for a long time has little effect on evaluating the pros and cons of the current functional module, it is possible to obtain only the historical log records of the most recent period (for example, nearly three months), that is, You only need to obtain historical log records in the preset time period, and then count the number of error messages in the historical log records during the preset time period.
  • the errors are first classified according to the severity of the error, and then the number of errors corresponding to each type of error is counted. For example, the types of errors are classified into fatal errors, severe errors, and common errors according to their severity, and then the number of occurrences of each type of error is counted separately.
  • Step 208 Determine a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record.
  • the corresponding log level may be determined according to the advantages and disadvantages of the functional modules.
  • the log level reflects the fineness of the log record. The higher the level, the finer the corresponding log record, and the more resources are consumed. The lower the level, the coarser the granularity of the corresponding log record, and the less resources are consumed. If the function module is better, it means that the function module has few problems, so only need to record less logs, that is, the corresponding log level can be set to a lower level; if the function module is relatively poor, the function module runs.
  • the probability of the problem is relatively large, and the corresponding need to record more detailed
  • the log that is, the log level, needs to be used at a higher level to facilitate subsequent problem location.
  • most of the functional modules in the server are in a stable state, and the probability of failure is small, and only a small amount of log information needs to be recorded. Therefore, resource consumption can be greatly reduced by performing targeted logging according to functional modules.
  • the correspondence between the historical error information and the log level may be directly set. The more the historical error information, the higher the corresponding log level.
  • the goodness of the function module may be first calculated according to the preset calculation rule according to the historical error information, and then the corresponding log level is determined according to the calculated goodness.
  • Step 210 Perform corresponding log records according to the log level corresponding to each function module.
  • the log records are classified in advance, and the level of detail of the log records corresponding to different levels is different.
  • the level of logging is top-down compatible, and high-level logging is compatible with low-level logging.
  • the log level is divided into 10 levels. The first level corresponds to closing all log information; the second level corresponds to only recording fatal error information; the third level corresponds to recording serious errors and fatal error messages; The level corresponds to record common error, severe error and fatal error information; the fifth level corresponds to record warning information, normal error, serious error and fatal error information; and so on, until the 10th level records all information.
  • high-level logging is compatible with all low-level logging, the higher the level, the finer the recording.
  • the log level is divided according to the fineness of the record in advance, and the log recording rule corresponding to each level is set.
  • the highest level of the logging rule is to record all the information
  • the lowest level of the logging rule is to not record any information.
  • the corresponding log record can be performed according to the log record rule corresponding to the log level.
  • the foregoing log recording method determines the pros and cons of the corresponding function module according to the historical error information appearing in the historical log record corresponding to the function module. If the historical error record corresponding to the historical log record of the function module is less, the function module is relatively good. Low-level log records can be used, which greatly reduces the amount of log records. If there are many historical error messages in the function module, it indicates that the function module is more prone to problems, so high-level log records are required, and high-level log records are Refers to the recording of more detailed log records for subsequent location of the problem. In fact, most of the functional modules in the server are in a good stable state, and the probability of occurrence of problems is very small. Only a small amount of log information needs to be recorded, so the method of hierarchical recording according to the advantages and disadvantages of the functional modules can be greatly reduced. LF.
  • another logging method comprising:
  • Step 302 Acquire a function identifier corresponding to a function module running in the server.
  • Step 304 Obtain a history log record corresponding to each function module according to the function identifier.
  • Step 306 Record historical error information corresponding to each functional module according to historical log records corresponding to each functional module.
  • Step 307 Acquire a running time corresponding to each function module.
  • Step 308 Determine a log level corresponding to each function module according to historical error information and a running time length corresponding to each function module, and the log level reflects the fineness of the log record. The higher the level, the finer the log record.
  • Step 310 Perform corresponding log records according to the log level corresponding to each function module.
  • the probability of the problem of the function module can be better determined. If the probability of the function module is small, then the log level can be set to a lower level. If there is a problem with the function module. The probability is large, so you can set it to a higher log level. When the general function is just online (that is, the running time is short), you need to refine the log. Set the logging level to the highest level. After the function has stabilized (after a long period of operation), set the log to a lower level, such as logging only fatal error messages.
  • the goodness and stability of the functional module are evaluated by acquiring error information and running time in the historical log record corresponding to the function module. If the function module has high degree of goodness and stability, the probability of a problem with the function module is very low. Only a small amount of logs need to be recorded. If the function module has poor performance and stability, then it needs to be recorded. Detailed log. Specifically, the weights corresponding to the goodness and the stability, and the respective corresponding scoring standards may be set in advance, and then the scores of the functional modules corresponding to the function modules are calculated, and the corresponding log ranks are determined according to the scores, and then The determined log level is recorded accordingly. By evaluating the probability of a problem with the function module by double-cribing the function module, the corresponding log level is determined, which can better save resource consumption and not affect the subsequent positioning of the problem.
  • the method before the step of acquiring the function identifier corresponding to the function module included in the server, the method further includes:
  • Step 200 Detect the type of the operating environment in which the server is currently located.
  • the running environment of the server is different, and the corresponding log level dividing rules may be different. Therefore, the log level dividing rules corresponding to each environment are separately set according to different operating environments.
  • the operating environment of the server can be divided into a development environment, a test environment, and a production environment. Different environment types have different standards for log level division. Therefore, before obtaining the function identifier corresponding to the function module included in the server, the type of the running environment where the server is currently located is first detected. It is convenient to determine the corresponding log classification rules according to the type of environment. There are various ways to detect the current operating environment of the server. For example, different servers can be pre-configured to be responsible for different tasks.
  • the A server is responsible for the corresponding test
  • the B server is responsible for the corresponding production
  • the C server is responsible for the corresponding development.
  • the environment type of the server can be directly determined. For example, if the extracted server identifier is the identifier of the A server, the corresponding environment type is the test environment.
  • the server ID is used to uniquely identify a server.
  • Step 202 Determine a log level division rule corresponding to the running environment type according to the running environment type.
  • the rules for dividing the log levels determined by different environment types are different, and the correspondence between the environment types and the log level dividing rules is set in advance.
  • the environment type and the log may be used according to the environment type and the log.
  • the correspondence between the hierarchical rules determines the corresponding log ranking rules. For example, if it is a production environment, it can be divided into 10 levels. If it is a test environment, it can be divided into seven levels of trace
  • the rules for dividing the classification level of the log are different due to different operating environments of the server. Therefore, the correspondence between the environment type and the log classification rule needs to be set in advance, so that the functional modules can be correspondingly targeted.
  • the log records are more conducive to saving resources while ensuring the normal operation of the function modules.
  • the step of counting the historical error information corresponding to each function module according to the historical log record corresponding to each function module comprises: counting each error type and corresponding error according to the historical log record corresponding to each function module.
  • the number of information; determining the log level corresponding to each function module according to the error information corresponding to each function module, and the step of the log level reflecting the fineness of the log record includes: according to the type of error information corresponding to each function module and the corresponding error information The quantity calculates the log level corresponding to each function module.
  • the history error information includes the type of error and the corresponding amount of error information. Error types can be classified into fatal errors, serious errors, and normal errors based on severity. Count the number of each error type, calculate the goodness of the function module according to the error type corresponding to the function module and the corresponding error information quantity, you can set the total score in advance, and then set the weight of different error types, according to the weight and the corresponding error information. The product of the quantity is then multiplied by the total score of the set and multiplied by the corresponding weight to obtain the corresponding score of the representative goodness.
  • the step of performing corresponding log records according to the log level corresponding to each function module includes:
  • Step 210A Determine a log record rule corresponding to each function module according to a correspondence between a preset log level and a log record rule.
  • Step 210B Perform corresponding log records according to the log record rule corresponding to each function module.
  • the log records are hierarchically divided according to the fineness of the log record, and the log record rules corresponding to each level after the division are set, and the log record rule specifies the granularity of the corresponding log record, for example, If the highest level of logging rule is to record all information, the lowest level of logging rules is to not record any information.
  • the corresponding log record can be performed according to the log record rule corresponding to the log level.
  • a logging device comprising:
  • the identifier obtaining module 602 is configured to obtain a function identifier corresponding to the function module running in the server;
  • the extracting module 604 is configured to extract, according to the function identifier, a historical log record corresponding to each function module;
  • the statistics module 606 is configured to collect statistics according to historical log records corresponding to each function module. Historical error information corresponding to the function modules;
  • the determining module 608 is configured to determine, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record;
  • the recording module 610 is configured to perform corresponding log records according to a log level corresponding to each function module.
  • the foregoing logging device further includes:
  • the time length obtaining module 607 is configured to obtain a running time corresponding to each function module
  • the determining module 608 is further configured to determine a log level corresponding to each function module according to historical error information and a running time length corresponding to each function module, where the log level reflects the fineness of the log record, and the higher the level, the more the log record fine.
  • the foregoing logging device further includes:
  • the detecting module 600 is configured to detect a type of the operating environment in which the server is currently located;
  • the rule determining module 601 is configured to determine a log level dividing rule corresponding to the running environment type according to the running environment type.
  • the statistic module 606 is further configured to count each error type and corresponding error information according to the historical log records corresponding to each function module; the determining module 608 is further configured to use each function module.
  • the corresponding error information type and the corresponding number of error information are used to calculate the log level corresponding to each function module.
  • the log level reflects the fineness of the log record. The higher the level, the finer the log record.
  • the recording module 610 is further configured to determine a log record rule corresponding to each function module according to a preset correspondence between a log level and a log record rule, and perform a corresponding log according to a log record rule corresponding to each function module. recording.
  • the network interface may be an Ethernet card or a wireless network card.
  • the above modules may be embedded in the hardware in the processor or in the memory in the server, or may be stored in the memory in the server, so that the processor calls the corresponding operations of the above modules.
  • the processor can be a central processing unit (CPU,), a microprocessor, a microcontroller, or the like.
  • the above logging device can be implemented in the form of a computer readable instruction that can be executed on a computer device as shown in FIG.
  • the embodiment of the present application provides a computer device.
  • the internal structure of the computer device may correspond to the structure shown in FIG. 1. That is, the computer device may be a server or a terminal, and includes a series of computers stored in the memory.
  • the readable instructions when the computer readable instructions are executed by the processor, may implement the method of logging as set forth in various embodiments of the present application.
  • a computer device includes a memory, a processor, and computer readable instructions stored on the memory and operative on the processor, the processor implementing the computer readable instructions to implement the following steps Obtaining a function identifier corresponding to the function module running in the server; extracting a history log record corresponding to each function module according to the function identifier; and collecting a history corresponding to each function module according to the historical log record corresponding to each function module
  • the error information is determined according to the historical error information, and the log level corresponding to each function module is determined, and the log level reflects the fineness of the log record; corresponding log records are performed according to the log level corresponding to each function module.
  • the method when the processor executes the computer readable instructions, the method further includes: acquiring a running time corresponding to each functional module; and determining, by the processor, the determining according to the historical error information
  • the log level corresponding to each function module, the step of reflecting the fineness of the log record includes: determining the log level corresponding to each function module according to the historical error information and the running time corresponding to each function module, and the log level is reflected The granularity of the log record, the higher the level, the finer the log record.
  • the processor before the acquiring the function identifier corresponding to the function module included in the server, the processor is further configured to: perform: detecting a type of the running environment where the server is currently located; according to the type of the operating environment Determining a log level division rule corresponding to the type of the running environment.
  • the step of, according to the history log record corresponding to each function module, the historical error information corresponding to each function module is performed by the processor, including: according to the history log corresponding to each function module Recording each type of error and the corresponding number of error information; determining, by the processor, each function according to error information corresponding to each function module
  • the log level corresponding to the module, the log level reflecting the fineness of the log record includes: calculating the log level corresponding to each function module according to the type of the error information corresponding to each function module and the corresponding number of error information, and the log level reflects The granularity of logging, the higher the level, the finer the logging.
  • the step of performing corresponding log recording according to the log level corresponding to each function module performed by the processor includes: determining, according to a preset correspondence between a log level and a log record rule, a corresponding function module Logging rules; corresponding log records according to the logging rules corresponding to each functional module.
  • a computer readable storage medium having stored thereon computer readable instructions that, when executed by a processor, implement the steps of: obtaining a function identifier corresponding to a function module running in a server; The function identifier extracts a history log record corresponding to each function module; and records historical error information corresponding to each function module according to the history log corresponding to each function module; and determines each function module according to the historical error information.
  • the log level reflects the fineness of the log record; the corresponding log record is performed according to the log level corresponding to each function module.
  • the method when the processor executes the computer readable instructions, the method further includes: acquiring a running time corresponding to each functional module; and determining, by the processor, the determining according to the historical error information
  • the log level corresponding to each function module, the step of reflecting the fineness of the log record includes: determining the log level corresponding to each function module according to the historical error information and the running time corresponding to each function module, and the log level is reflected The granularity of the log record, the higher the level, the finer the log record.
  • the processor before the acquiring the function identifier corresponding to the function module included in the server, the processor is further configured to: perform: detecting a type of the running environment where the server is currently located; according to the type of the operating environment Determining a log level division rule corresponding to the type of the running environment.
  • the processor performs a calendar according to each function module.
  • the step of recording, by the history log, the historical error information corresponding to each function module comprises: counting each error type and the corresponding amount of error information according to the historical log record corresponding to each function module;
  • the error information corresponding to each function module determines a log level corresponding to each function module, and the step of the log level reflecting the fineness of the log record includes: calculating according to the type of error information corresponding to each function module and the corresponding number of error information
  • the log level corresponding to each function module, the log level reflects the fineness of the log record. The higher the level, the finer the log record.
  • the step of performing corresponding log recording according to the log level corresponding to each function module performed by the processor includes: determining, according to a preset correspondence between a log level and a log record rule, a corresponding function module Logging rules; corresponding log records according to the logging rules corresponding to each functional module.
  • the foregoing storage medium may be a non-volatile storage medium such as a magnetic disk or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A method for recording a log comprises: obtaining function identifiers corresponding to function modules running in a server (202); extracting, according to the function identifiers, a historical log record corresponding to each of the function modules (204); performing calculation, according to the historical log record corresponding to each of the function modules, on historical error information corresponding to each of the function modules (206); determining, according to the historical error information, a log level corresponding to each of the function modules, the log level representing the level of detail of a log record (208); and correspondingly recording a log according to the log level corresponding to each of the function modules (210).

Description

日志记录方法、装置、计算机设备及存储介质Log recording method, device, computer device and storage medium
本申请要求于2017年6月23日提交中国专利局、申请号为2017104889969、发明名称为“日志记录方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese Patent Application filed on June 23, 2017, the Chinese Patent Application No. 2017104889969, entitled "Logging Method, Apparatus, Computer Equipment, and Storage Medium", the entire contents of which are incorporated by reference. In this application.
技术领域Technical field
本申请涉及计算机处理领域,特别是涉及一种日志记录方法、装置、计算机设备及存储介质。The present application relates to the field of computer processing, and in particular, to a log recording method, apparatus, computer device, and storage medium.
背景技术Background technique
日志记录无论是在程序开发阶段还是运行阶段亦或是在测试阶段都有着很重要的作用,其中一个最重要的作用是当出现异常时可以通过记录的日志来定位问题。传统的日志记录不管服务器中的功能模块处于哪种状态都采用同样的日志记录粒度,且传统的日志记录采用的记录粒度往往比较精细,导致需要消耗大量的资源进行大量日志的记录。Logging plays an important role both in the development phase and in the testing phase. One of the most important functions is to locate the problem by logging when an exception occurs. The traditional log record uses the same log record granularity regardless of the state of the function modules in the server. The traditional log records are often granular in granularity, resulting in the need to consume a large amount of resources for large log records.
发明内容Summary of the invention
根据本申请的各种实施例,提供一种日志记录方法、装置、计算机设备及存储介质。According to various embodiments of the present application, a log recording method, apparatus, computer device, and storage medium are provided.
一种日志记录方法,包括:A logging method comprising:
获取服务器中运行的功能模块所对应的功能标识;Obtaining the function identifier corresponding to the function module running in the server;
根据所述功能标识提取每个功能模块对应的历史日志记录;Extracting a history log record corresponding to each function module according to the function identifier;
根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息; And collecting historical error information corresponding to each function module according to historical log records corresponding to each function module;
根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及Determining a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record;
根据每个功能模块对应的日志等级进行相应的日志记录。Corresponding log records are performed according to the log level corresponding to each function module.
一种日志记录装置,包括:A logging device comprising:
标识获取模块,用于获取服务器中运行的功能模块所对应的功能标识;An identifier obtaining module, configured to acquire a function identifier corresponding to a function module running in the server;
提取模块,用于根据所述功能标识提取每个功能模块对应的历史日志记录;An extraction module, configured to extract, according to the function identifier, a historical log record corresponding to each function module;
统计模块,用于根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;a statistics module, configured to collect historical error information corresponding to each function module according to historical log records corresponding to each function module;
确定模块,用于根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及a determining module, configured to determine, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record;
记录模块,用于根据每个功能模块对应的日志等级进行相应的日志记录。The recording module is configured to perform corresponding log records according to the log level corresponding to each function module.
一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行以下步骤:A computer apparatus comprising a memory and a processor, the memory storing computer readable instructions, the computer readable instructions being executed by the processor such that the processor performs the following steps:
获取服务器中运行的功能模块所对应的功能标识;Obtaining the function identifier corresponding to the function module running in the server;
根据所述功能标识提取每个功能模块对应的历史日志记录;Extracting a history log record corresponding to each function module according to the function identifier;
根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;And collecting historical error information corresponding to each function module according to historical log records corresponding to each function module;
根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及Determining a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record;
根据每个功能模块对应的日志等级进行相应的日志记录。Corresponding log records are performed according to the log level corresponding to each function module.
一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:获取服务器中运行的功能模块所对应的功能标识; One or more non-transitory readable storage mediums storing computer readable instructions, when executed by one or more processors, cause the one or more processors to perform the steps of: acquiring The function identifier corresponding to the function module running in the server;
根据所述功能标识提取每个功能模块对应的历史日志记录;Extracting a history log record corresponding to each function module according to the function identifier;
根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;And collecting historical error information corresponding to each function module according to historical log records corresponding to each function module;
根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及Determining a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record;
根据每个功能模块对应的日志等级进行相应的日志记录。Corresponding log records are performed according to the log level corresponding to each function module.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征、目的和优点将从说明书、附图以及权利要求书变得明显。Details of one or more embodiments of the present application are set forth in the accompanying drawings and description below. Other features, objects, and advantages of the invention will be apparent from the description and appended claims.
附图说明DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present application. Other drawings may also be obtained from those of ordinary skill in the art in light of the inventive work.
图1为一个实施例中计算机设备的内部结构示意图;1 is a schematic diagram showing the internal structure of a computer device in an embodiment;
图2为一个实施例中日志记录方法的流程图;2 is a flow chart of a logging method in an embodiment;
图3为另一个实施例中日志记录方法的流程图;3 is a flow chart of a logging method in another embodiment;
图4为又一个实施例中日志记录方法的流程图;4 is a flow chart of a log recording method in still another embodiment;
图5为一个实施例中根据每个功能模块对应的日志等级进行相应的日志记录的方法流程图;FIG. 5 is a flowchart of a method for performing corresponding log recording according to a log level corresponding to each functional module in an embodiment; FIG.
图6为一个实施例中日志记录装置的结构框图;Figure 6 is a block diagram showing the structure of a log recording apparatus in an embodiment;
图7为另一个实施例中日志记录装置的结构框图;Figure 7 is a block diagram showing the structure of a log recording apparatus in another embodiment;
图8为又一个实施例中日志记录装置的结构框图。Figure 8 is a block diagram showing the structure of a log recording apparatus in still another embodiment.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及 实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the objects, technical solutions and advantages of the present application more clear, the following The present application will be further described in detail. It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
图1为一个实施例中计算机设备的内部结构示意图,该计算机设备可以为服务器。参照图1,该计算机设备包括通过系统总线连接的处理器、非易失性存储介质、内存储器和网络接口。其中,该计算机设备的非易失性存储介质可存储操作系统和计算机可读指令,该计算机可读指令被执行时,可使得处理器执行一种日志记录方法。该计算机设备的处理器用于提供计算和控制能力,支撑整个计算机设备的运行。该内存储器中可储存有计算机可读指令,该计算机可读指令被处理器执行时,可使得处理器执行一种日志记录方法。计算机设备的网络接口用于进行网络通信。本领域技术人员可以理解,图1中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。FIG. 1 is a schematic diagram of an internal structure of a computer device in an embodiment, and the computer device may be a server. Referring to Figure 1, the computer device includes a processor, a non-volatile storage medium, an internal memory, and a network interface connected by a system bus. Wherein, the non-volatile storage medium of the computer device can store an operating system and computer readable instructions that, when executed, cause the processor to perform a logging method. The processor of the computer device is used to provide computing and control capabilities to support the operation of the entire computer device. The internal memory can store computer readable instructions that, when executed by the processor, cause the processor to perform a logging method. The network interface of the computer device is used for network communication. It will be understood by those skilled in the art that the structure shown in FIG. 1 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device to which the solution of the present application is applied. The specific computer device may It includes more or fewer components than those shown in the figures, or some components are combined, or have different component arrangements.
如图2所示,在一个实施例中,提出了一种日志记录方法,该方法包括:As shown in FIG. 2, in one embodiment, a logging method is proposed, the method comprising:
步骤202,获取服务器中运行的功能模块所对应的功能标识。Step 202: Acquire a function identifier corresponding to a function module running in the server.
在本实施例中,功能模块是指用于实现某个功能任务的程序。功能模块在运行时有可能会发生异常,为了对发生异常产生的原因进行排查,需要预先在该功能模块运行时进行日志记录,日志记录用于记录功能模块的运行情况,比如,记录运行时出现的错误、警告等,便于后续根据日志记录查找问题所在。一个服务器中往往可以运行多个功能模块,日志记录是与功能模块对应的,每个功能模块都会对应一个相应的日志记录程序。功能标识用于唯一标识一个功能模块。通过获取服务器中运行的功能模块所对应的功能标识,便于后续根据功能标识查找相应的历史日志记录。In this embodiment, a function module refers to a program for implementing a certain functional task. The function module may be abnormal during operation. In order to troubleshoot the cause of the abnormality, it is necessary to log in advance when the function module is running. The log record is used to record the running status of the function module. For example, the record runs. Errors, warnings, etc., to facilitate subsequent troubleshooting based on the log records. A server can often run multiple function modules. Log records correspond to function modules. Each function module corresponds to a corresponding log record program. The function identifier is used to uniquely identify a function module. By obtaining the function identifier corresponding to the function module running in the server, it is convenient to find the corresponding historical log record according to the function identifier.
步骤204,根据功能标识获取每个功能模块对应的历史日志记录。Step 204: Acquire a historical log record corresponding to each function module according to the function identifier.
在本实施例中,历史日志记录是指对之前功能模块的运行情况进行的记录,日志记录的信息包括出现过的错误信息,错误信息又可以分为致命错误、 严重错误和普通错误,当然也会包括一些警告信息和一般信息以及各种配置信息等。每个功能模块都会对应一个日志记录,为了便于日志查询,预先将功能模块的功能标识与相应的日志记录进行关联存储,这样根据功能标识就可以获取到相应功能模块对应的历史日志记录。In this embodiment, the historical log record refers to the record of the operation of the previous function module, and the log record information includes the error information that has appeared, and the error message can be further classified into a fatal error. Serious errors and common errors, of course, will also include some warning information and general information as well as various configuration information. Each function module corresponds to a log record. In order to facilitate log query, the function identifier of the function module is associated with the corresponding log record in advance, so that the history log record corresponding to the corresponding function module can be obtained according to the function identifier.
步骤206,根据每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息。Step 206: Record historical error information corresponding to each functional module according to historical log records corresponding to each functional module.
在本实施例中,历史日志记录记载了功能模块之前的运行情况,包括之前出现过的错误信息。通过获取功能模块对应的历史记录统计该功能模块之前出现的历史错误信息。统计历史错误信息是为了获知该功能模块运行的优劣性,优劣性用于评估功能模块出现问题的概率。在一个实施例中,由于时间久远的历史日志记录对于评估当前功能模块的优劣性的作用不大,所以可以只获取最近一段时间段内(比如,近三个月)的历史日志记录,即只需要获取预设时间段内的历史日志记录,然后统计该预设时间段内历史日志记录中出现错误信息的次数。为了更精确根据历史错误信息对功能模块的优劣性进行评估,在一个实施例中,首先根据错误的严重程度将错误进行分类,然后统计每一类错误类型对应出现的错误次数。比如,将错误类型按照严重程度分为致命错误、严重错误和普通错误三类,然后分别统计每一类错误对应出现的次数。In this embodiment, the history log records the previous operation of the function module, including the error information that has appeared before. The historical error information that occurred before the function module is counted by obtaining the history record corresponding to the function module. The statistical history error information is used to know the pros and cons of the function module, and the pros and cons are used to evaluate the probability of a problem with the function module. In one embodiment, since the historical log record for a long time has little effect on evaluating the pros and cons of the current functional module, it is possible to obtain only the historical log records of the most recent period (for example, nearly three months), that is, You only need to obtain historical log records in the preset time period, and then count the number of error messages in the historical log records during the preset time period. In order to more accurately evaluate the pros and cons of the functional modules based on historical error information, in one embodiment, the errors are first classified according to the severity of the error, and then the number of errors corresponding to each type of error is counted. For example, the types of errors are classified into fatal errors, severe errors, and common errors according to their severity, and then the number of occurrences of each type of error is counted separately.
步骤208,根据历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度。Step 208: Determine a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record.
在本实施例中,由于不同功能模块的优劣性不同,为了能够节省资源消耗,可以根据功能模块的优劣性来确定相应的日志等级。日志等级反映的是日志记录的精细度,等级越高,相应的日志记录的越精细,对应消耗的资源越多;等级越低,相应的日志记录的粒度越粗,对应消耗的资源越少。如果功能模块比较优良,说明该功能模块很少出现问题,那么只需要记录较少的日志,即可以将相应的日志等级设置为较低的等级;如果功能模块比较差,说明该功能模块运行出现问题的概率比较大,相应的就需要记录比较详细的 日志,即日志等级需要采用较高的等级,便于后续进行问题的定位。事实上,服务器中的功能模块大部分都处于稳定状态,出现故障的概率很小,只需要记录少量日志信息。所以通过根据功能模块有针对性地进行日志记录,可以大大减少资源消耗。In this embodiment, because the advantages and disadvantages of different functional modules are different, in order to save resource consumption, the corresponding log level may be determined according to the advantages and disadvantages of the functional modules. The log level reflects the fineness of the log record. The higher the level, the finer the corresponding log record, and the more resources are consumed. The lower the level, the coarser the granularity of the corresponding log record, and the less resources are consumed. If the function module is better, it means that the function module has few problems, so only need to record less logs, that is, the corresponding log level can be set to a lower level; if the function module is relatively poor, the function module runs. The probability of the problem is relatively large, and the corresponding need to record more detailed The log, that is, the log level, needs to be used at a higher level to facilitate subsequent problem location. In fact, most of the functional modules in the server are in a stable state, and the probability of failure is small, and only a small amount of log information needs to be recorded. Therefore, resource consumption can be greatly reduced by performing targeted logging according to functional modules.
具体地,通过获取功能模块对应的历史错误信息判断功能模块的优劣性,如果历史日志记录中出现的错误信息比较少,说明该功能模块的性能比较优良,如果错误信息比较多,那么就说明该功能模块的性能相对较差,容易出现问题。在一个实施例中,可以直接设置历史错误信息与日志等级之间的对应关系,历史错误信息越多,相应的日志等级越高。在另一个实施例中,还可以首先根据历史错误信息按照预设的计算规则计算功能模块的优良度,然后根据计算得到的优良度确定相应的日志等级。Specifically, judging the pros and cons of the function module by obtaining the historical error information corresponding to the function module, if the error information appearing in the history log record is relatively small, the performance of the function module is relatively good, and if the error information is relatively large, then the description is The performance of this function module is relatively poor and prone to problems. In an embodiment, the correspondence between the historical error information and the log level may be directly set. The more the historical error information, the higher the corresponding log level. In another embodiment, the goodness of the function module may be first calculated according to the preset calculation rule according to the historical error information, and then the corresponding log level is determined according to the calculated goodness.
步骤210,根据每个功能模块对应的日志等级进行相应的日志记录。Step 210: Perform corresponding log records according to the log level corresponding to each function module.
在本实施例中,预先对日志记录进行等级划分,不同级别对应的日志记录的详细程度不同,日志等级越高,需要记录的日志越详细,日志等级越低,记录的日志越粗糙。日志记录的级别是由上而下兼容,高等级的日志记录兼容低等级的日志记录。比如,日志级别分为10个级别,第一级别对应的是关闭所有的日志信息;第二级别对应的是只记录致命错误信息;第三级别对应的是记录严重错误和致命错误信息;第四级别对应的是记录普通错误、严重错误和致命错误信息;第五等级对应的是记录警告信息、普通错误、严重错误和致命错误信息;依次类推,直到第10等级记录所有信息。也就是说,高等级的日志记录兼容所有低等级的日志记录,等级越高,记录的越精细。具体地,预先根据记录的精细度对日志等级划分,并设置每个等级对应的日志记录规则,比如,最高等级的日志记录规则是记录所有信息,最低等级的日志记录规则是不记录任何信息。确定了每个功能模块对应的日志等级后,就可以根据日志等级对应的日志记录规则进行相应的日志记录。通过根据功能模块的优劣性来确定相应的日志等级,有利于节省资源消耗,同时也能够保证后续对问题的定位。 In this embodiment, the log records are classified in advance, and the level of detail of the log records corresponding to different levels is different. The higher the log level, the more detailed the logs to be recorded, and the lower the log level, the coarser the recorded logs. The level of logging is top-down compatible, and high-level logging is compatible with low-level logging. For example, the log level is divided into 10 levels. The first level corresponds to closing all log information; the second level corresponds to only recording fatal error information; the third level corresponds to recording serious errors and fatal error messages; The level corresponds to record common error, severe error and fatal error information; the fifth level corresponds to record warning information, normal error, serious error and fatal error information; and so on, until the 10th level records all information. That is, high-level logging is compatible with all low-level logging, the higher the level, the finer the recording. Specifically, the log level is divided according to the fineness of the record in advance, and the log recording rule corresponding to each level is set. For example, the highest level of the logging rule is to record all the information, and the lowest level of the logging rule is to not record any information. After the log level corresponding to each function module is determined, the corresponding log record can be performed according to the log record rule corresponding to the log level. By determining the corresponding log level according to the advantages and disadvantages of the function module, it is beneficial to save resource consumption, and at the same time, to ensure the subsequent positioning of the problem.
上述日志记录方法,根据功能模块对应的历史日志记录中出现的历史错误信息来判断相应功能模块的优劣性,如果功能模块对应的历史日志记录中历史错误信息较少,说明该功能模块比较优良,可以采用低等级的日志记录,大大减少了日志的记录量,如果功能模块中历史错误信息比较多,说明该功能模块比较容易出现问题,那么需要高等级的日志记录,高等级的日志记录是指记录比较详细的日志记录,便于后续进行问题的定位。事实上,服务器中的大部分功能模块都处于优良稳定状态,出现问题的概率很小,只需要记录少量的日志信息即可,所以根据功能模块的优劣性采用分等级记录的方法可以大大减少资源消耗。The foregoing log recording method determines the pros and cons of the corresponding function module according to the historical error information appearing in the historical log record corresponding to the function module. If the historical error record corresponding to the historical log record of the function module is less, the function module is relatively good. Low-level log records can be used, which greatly reduces the amount of log records. If there are many historical error messages in the function module, it indicates that the function module is more prone to problems, so high-level log records are required, and high-level log records are Refers to the recording of more detailed log records for subsequent location of the problem. In fact, most of the functional modules in the server are in a good stable state, and the probability of occurrence of problems is very small. Only a small amount of log information needs to be recorded, so the method of hierarchical recording according to the advantages and disadvantages of the functional modules can be greatly reduced. LF.
如图3所示,在一个实施例中,提出了另一种日志记录方法,该方法包括:As shown in FIG. 3, in one embodiment, another logging method is proposed, the method comprising:
步骤302,获取服务器中运行的功能模块所对应的功能标识。Step 302: Acquire a function identifier corresponding to a function module running in the server.
步骤304,根据功能标识获取每个功能模块对应的历史日志记录。Step 304: Obtain a history log record corresponding to each function module according to the function identifier.
步骤306,根据每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息。Step 306: Record historical error information corresponding to each functional module according to historical log records corresponding to each functional module.
步骤307,获取每个功能模块对应的运行时长。Step 307: Acquire a running time corresponding to each function module.
步骤308,根据每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。Step 308: Determine a log level corresponding to each function module according to historical error information and a running time length corresponding to each function module, and the log level reflects the fineness of the log record. The higher the level, the finer the log record.
步骤310,根据每个功能模块对应的日志等级进行相应的日志记录。Step 310: Perform corresponding log records according to the log level corresponding to each function module.
在本实施例中,为了能够更好的确定功能模块对应的日志等级,除了要统计历史错误信息来确定功能模块的优劣性外,还需要获取功能模块的运行时长,这里的运行时长是指总的运行时长,运行时长越长,其相应的稳定性越高。根据功能模块对应的历史错误信息和运行时长能够更好的确定功能模块出现问题的概率大小,如果功能模块出现问题的概率较小,那么就可以设置为较低的日志等级,如果功能模块出现问题的概率较大,那么可以设置为较高的日志等级。一般功能刚上线时(即运行时长较短),需要细化日志,可 将日志记录的等级设为最高级,功能趋于稳定后(运行较长一段时间后),可将日志设置为较低的等级,比如只记录出现的致命错误信息。In this embodiment, in order to better determine the log level corresponding to the function module, in addition to statistical error information to determine the pros and cons of the function module, it is also necessary to obtain the running time of the function module, where the running time refers to The total running time, the longer the running time, the higher the corresponding stability. According to the historical error information and runtime of the function module, the probability of the problem of the function module can be better determined. If the probability of the function module is small, then the log level can be set to a lower level. If there is a problem with the function module. The probability is large, so you can set it to a higher log level. When the general function is just online (that is, the running time is short), you need to refine the log. Set the logging level to the highest level. After the function has stabilized (after a long period of operation), set the log to a lower level, such as logging only fatal error messages.
在本实施例中,通过获取功能模块对应的历史日志记录中的错误信息和运行时长来评估功能模块的优良度和稳定度。如果功能模块的优良度和稳定度都很高,说明该功能模块出现问题的概率很低,只需要记录少量日志即可,如果功能模块的优良度和稳定度都比较差,那么就需要记录较为详细的日志。具体地,可以预先设置优良度和稳定度对应的权值,以及各自相应的评分标准,然后计算得到功能模块对应的反映功能模块优劣的分数值,根据分数值确定相应的日志等级,进而根据确定的日志等级进行相应的日志记录。通过对功能模块进行双重标准来评价功能模块出现问题的概率,从而确定相应的日志等级,能够更好的节省资源消耗,同时也不影响后续对问题的定位。In this embodiment, the goodness and stability of the functional module are evaluated by acquiring error information and running time in the historical log record corresponding to the function module. If the function module has high degree of goodness and stability, the probability of a problem with the function module is very low. Only a small amount of logs need to be recorded. If the function module has poor performance and stability, then it needs to be recorded. Detailed log. Specifically, the weights corresponding to the goodness and the stability, and the respective corresponding scoring standards may be set in advance, and then the scores of the functional modules corresponding to the function modules are calculated, and the corresponding log ranks are determined according to the scores, and then The determined log level is recorded accordingly. By evaluating the probability of a problem with the function module by double-cribing the function module, the corresponding log level is determined, which can better save resource consumption and not affect the subsequent positioning of the problem.
如图4所示,在一个实施例中,在获取服务器中包含的功能模块所对应的功能标识的步骤之前还包括:As shown in FIG. 4, in an embodiment, before the step of acquiring the function identifier corresponding to the function module included in the server, the method further includes:
步骤200,检测服务器当前所处的运行环境类型。Step 200: Detect the type of the operating environment in which the server is currently located.
在本实施例中,服务器所处的运行环境不同,其相应的日志等级划分规则会有所不同,所以需要根据不同的运行环境,分别设置与每一种环境对应的日志等级划分规则。服务器的运行环境可以分为开发环境、测试环境和生产环境。不同环境类型对日志等级划分的标准有所不同,所以在获取服务器包含的功能模块所对应的功能标识的步骤之前,首先检测服务器当前所处的运行环境类型。便于根据环境类型来确定相应的日志等级划分规则。检测服务器当前所处运行环境的方法有多种,比如,可以预先设置不同的服务器负责不同的任务,假设设置A服务器负责相应的测试,B服务器负责相应的生产,C服务器负责相应的开发。那么后续根据提取到的服务器的标识就可以直接确定服务器所处的环境类型。比如,如果提取到的服务器标识为A服务器的标识,那么相应的环境类型为测试环境。服务器标识用于唯一标识一台服务器。 In this embodiment, the running environment of the server is different, and the corresponding log level dividing rules may be different. Therefore, the log level dividing rules corresponding to each environment are separately set according to different operating environments. The operating environment of the server can be divided into a development environment, a test environment, and a production environment. Different environment types have different standards for log level division. Therefore, before obtaining the function identifier corresponding to the function module included in the server, the type of the running environment where the server is currently located is first detected. It is convenient to determine the corresponding log classification rules according to the type of environment. There are various ways to detect the current operating environment of the server. For example, different servers can be pre-configured to be responsible for different tasks. It is assumed that the A server is responsible for the corresponding test, the B server is responsible for the corresponding production, and the C server is responsible for the corresponding development. Then, according to the identifier of the extracted server, the environment type of the server can be directly determined. For example, if the extracted server identifier is the identifier of the A server, the corresponding environment type is the test environment. The server ID is used to uniquely identify a server.
步骤202,根据运行环境类型确定与运行环境类型对应的日志等级划分规则。Step 202: Determine a log level division rule corresponding to the running environment type according to the running environment type.
在本实施例中,不同环境类型确定的日志等级的划分规则不同,预先设置环境类型与日志等级划分规则之间的对应关系,在确定了服务器的运行环境类型后,就可以根据环境类型和日志等级划分规则之间的对应关系确定相应的日志等级划分规则。比如,如果是生产环境,可以划分为10个等级,如果是测试环境,则可以划分为trace|debug|info|warn|error|fatal|none七个级别,其中,从trace到none级别越来越低。None表示为不记录,trace为全纪录日志。当历史日志记录中出现的错误信息比较高时,说明需要细化调试,可相应记录为trace或debug。当历史日志记录中出现的错误信息比较低时,可以将级别设为fatal或者none。In this embodiment, the rules for dividing the log levels determined by different environment types are different, and the correspondence between the environment types and the log level dividing rules is set in advance. After determining the running environment type of the server, the environment type and the log may be used according to the environment type and the log. The correspondence between the hierarchical rules determines the corresponding log ranking rules. For example, if it is a production environment, it can be divided into 10 levels. If it is a test environment, it can be divided into seven levels of trace|debug|info|warn|error|fatal|none, where the level from trace to none is getting more and more low. None means no record, and trace is a full record log. When the error message appears in the history log record is high, it indicates that the debugging needs to be refined, and it can be recorded as trace or debug. When the error message that appears in the history log record is low, you can set the level to fatal or none.
在本实施例中,由于服务器运行环境的不同,对日志分类等级的划分规则有所不同,所以需要预先设置环境类型与日志等级划分规则之间的对应关系,便于有针对性对功能模块进行相应的日志记录,从而更加有利于在节省资源的同时也能保证功能模块的正常运行。In this embodiment, the rules for dividing the classification level of the log are different due to different operating environments of the server. Therefore, the correspondence between the environment type and the log classification rule needs to be set in advance, so that the functional modules can be correspondingly targeted. The log records are more conducive to saving resources while ensuring the normal operation of the function modules.
在一个实施例中,根据每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息的步骤包括:根据每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;根据每个功能模块对应的错误信息确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度的步骤包括:根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级。In an embodiment, the step of counting the historical error information corresponding to each function module according to the historical log record corresponding to each function module comprises: counting each error type and corresponding error according to the historical log record corresponding to each function module. The number of information; determining the log level corresponding to each function module according to the error information corresponding to each function module, and the step of the log level reflecting the fineness of the log record includes: according to the type of error information corresponding to each function module and the corresponding error information The quantity calculates the log level corresponding to each function module.
在本实施例中,历史错误信息包括错误类型和相应的错误信息数量。错误类型根据严重程度可分为致命错误、严重错误和普通错误。统计每种错误类型对应的数量,根据功能模块对应的错误类型和相应的错误信息数量计算功能模块的优良度,可以预先设置总分,然后设置不同错误类型的权重,根据权重和相应的错误信息数量的乘积,然后用设置的总分减去各个错误类型乘以相应的权重得到相应的代表优良度的分数值。比如,总分设置为Z,致 命错误出现次数为X1次,严重错误出现的次数为X2次,普通错误出现的次数为X3次,设置致命错误的权重为A,严重错误的权重为B,普通错误的权重为C,那么相应的优良度=Z-(A*X1+B*X2+C*X3),其中权重A>B>C。然后根据计算得到的优良度确定相应的日志等级,预先设置优良度与日志等级之间的对应关系,优良度越高,相应的日志等级越低。In the present embodiment, the history error information includes the type of error and the corresponding amount of error information. Error types can be classified into fatal errors, serious errors, and normal errors based on severity. Count the number of each error type, calculate the goodness of the function module according to the error type corresponding to the function module and the corresponding error information quantity, you can set the total score in advance, and then set the weight of different error types, according to the weight and the corresponding error information. The product of the quantity is then multiplied by the total score of the set and multiplied by the corresponding weight to obtain the corresponding score of the representative goodness. For example, the total score is set to Z, resulting in The number of occurrences of life errors is X1 times, the number of occurrences of serious errors is X2 times, the number of occurrences of common errors is X3 times, the weight of setting fatal errors is A, the weight of serious errors is B, and the weight of ordinary errors is C, then corresponding The degree of goodness = Z-(A*X1+B*X2+C*X3), where the weight A>B>C. Then, according to the calculated goodness, the corresponding log level is determined, and the correspondence between the goodness and the log level is set in advance, and the higher the degree of goodness, the lower the corresponding log level.
如图5所示,在一个实施例中,根据每个功能模块对应的日志等级进行相应的日志记录的步骤包括:As shown in FIG. 5, in one embodiment, the step of performing corresponding log records according to the log level corresponding to each function module includes:
步骤210A,根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则。 Step 210A: Determine a log record rule corresponding to each function module according to a correspondence between a preset log level and a log record rule.
步骤210B,根据每个功能模块对应的日志记录规则进行相应的日志记录。 Step 210B: Perform corresponding log records according to the log record rule corresponding to each function module.
在本实施例中,预先根据日志记录的精细度将日志记录进行了等级的划分,设置划分后的每一个等级对应的日志记录规则,日志记录规则规定了相应的日志记录的颗粒度,比如,如果日志等级为最高等级的日志记录规则是记录所有信息,最低等级的日志记录规则是不记录任何信息。确定了每个功能模块对应的日志等级后,就可以根据日志等级对应的日志记录规则进行相应的日志记录。通过根据功能模块的优劣性来确定相应的日志等级,进而进行相应的日志记录,有利于节省资源消耗,同时也能够保证后续对问题的定位。在一个实施例中,进行日志记录时将不同错误类型的日志分开记录存储,便于后续根据错误类型进行快速查找。In this embodiment, the log records are hierarchically divided according to the fineness of the log record, and the log record rules corresponding to each level after the division are set, and the log record rule specifies the granularity of the corresponding log record, for example, If the highest level of logging rule is to record all information, the lowest level of logging rules is to not record any information. After the log level corresponding to each function module is determined, the corresponding log record can be performed according to the log record rule corresponding to the log level. By determining the corresponding log level according to the advantages and disadvantages of the function module, and corresponding log recording, it is beneficial to save resource consumption, and at the same time, can ensure the subsequent positioning of the problem. In one embodiment, the logs of different error types are separately recorded and stored during the log recording, so that the subsequent quick search according to the error type is facilitated.
如图6所示,在一个实施例中,提出了一种日志记录装置,该装置包括:As shown in FIG. 6, in one embodiment, a logging device is proposed, the device comprising:
标识获取模块602,用于获取服务器中运行的功能模块所对应的功能标识;The identifier obtaining module 602 is configured to obtain a function identifier corresponding to the function module running in the server;
提取模块604,用于根据所述功能标识提取每个功能模块对应的历史日志记录;The extracting module 604 is configured to extract, according to the function identifier, a historical log record corresponding to each function module;
统计模块606,用于根据所述每个功能模块对应的历史日志记录统计每 个功能模块对应的历史错误信息;The statistics module 606 is configured to collect statistics according to historical log records corresponding to each function module. Historical error information corresponding to the function modules;
确定模块608,用于根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;The determining module 608 is configured to determine, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record;
记录模块610,用于根据每个功能模块对应的日志等级进行相应的日志记录。The recording module 610 is configured to perform corresponding log records according to a log level corresponding to each function module.
如图7所示,在一个实施例中,上述日志记录装置还包括:As shown in FIG. 7, in an embodiment, the foregoing logging device further includes:
时长获取模块607,用于获取每个功能模块对应的运行时长;The time length obtaining module 607 is configured to obtain a running time corresponding to each function module;
所述确定模块608还用于根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The determining module 608 is further configured to determine a log level corresponding to each function module according to historical error information and a running time length corresponding to each function module, where the log level reflects the fineness of the log record, and the higher the level, the more the log record fine.
如图8所示,在一个实施例中,上述日志记录装置还包括:As shown in FIG. 8, in one embodiment, the foregoing logging device further includes:
检测模块600,用于检测服务器当前所处的运行环境类型;The detecting module 600 is configured to detect a type of the operating environment in which the server is currently located;
规则确定模块601,用于根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。The rule determining module 601 is configured to determine a log level dividing rule corresponding to the running environment type according to the running environment type.
在一个实施例中,统计模块606还用于根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;所述确定模块608还用于根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。In an embodiment, the statistic module 606 is further configured to count each error type and corresponding error information according to the historical log records corresponding to each function module; the determining module 608 is further configured to use each function module. The corresponding error information type and the corresponding number of error information are used to calculate the log level corresponding to each function module. The log level reflects the fineness of the log record. The higher the level, the finer the log record.
在一个实施例中,记录模块610还用于根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则,根据每个功能模块对应的日志记录规则进行相应的日志记录。In an embodiment, the recording module 610 is further configured to determine a log record rule corresponding to each function module according to a preset correspondence between a log level and a log record rule, and perform a corresponding log according to a log record rule corresponding to each function module. recording.
上述日志记录装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。其中,网络接口可以是以太网卡或无线网卡等。上述各模块可以硬件形式内嵌于或独立于服务器中的处理器中,也可以以软件形式存储于服务器中的存储器中,以便于处理器调用执行以上各个模块对应的操作。该处理器可以为中央处理单元(CPU、)、微处理器、单片机等。 Each of the above-described logging devices can be implemented in whole or in part by software, hardware, and combinations thereof. The network interface may be an Ethernet card or a wireless network card. The above modules may be embedded in the hardware in the processor or in the memory in the server, or may be stored in the memory in the server, so that the processor calls the corresponding operations of the above modules. The processor can be a central processing unit (CPU,), a microprocessor, a microcontroller, or the like.
上述日志记录装置可以实现为一种计算机可读指令的形式,计算机可读指令可以在如图1所示的计算机设备上运行。The above logging device can be implemented in the form of a computer readable instruction that can be executed on a computer device as shown in FIG.
本申请实施例提出了一种计算机设备,计算机设备的内部结构可对应于如图1所示的结构,即该计算机设备既可以是服务器也可以是终端,其包括一系列存储于存储器上的计算机可读指令,当该计算机可读指令被处理器执行时,可以实现本申请各实施例提出的日志记录的方法。在一个实施例中,计算机设备包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现以下步骤:获取服务器中运行的功能模块所对应的功能标识;根据所述功能标识提取每个功能模块对应的历史日志记录;根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;根据每个功能模块对应的日志等级进行相应的日志记录。The embodiment of the present application provides a computer device. The internal structure of the computer device may correspond to the structure shown in FIG. 1. That is, the computer device may be a server or a terminal, and includes a series of computers stored in the memory. The readable instructions, when the computer readable instructions are executed by the processor, may implement the method of logging as set forth in various embodiments of the present application. In one embodiment, a computer device includes a memory, a processor, and computer readable instructions stored on the memory and operative on the processor, the processor implementing the computer readable instructions to implement the following steps Obtaining a function identifier corresponding to the function module running in the server; extracting a history log record corresponding to each function module according to the function identifier; and collecting a history corresponding to each function module according to the historical log record corresponding to each function module The error information is determined according to the historical error information, and the log level corresponding to each function module is determined, and the log level reflects the fineness of the log record; corresponding log records are performed according to the log level corresponding to each function module.
在一个实施例中,所述处理器执行所述计算机可读指令时还用于实现以下步骤:获取每个功能模块对应的运行时长;所述处理器所执行的根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度的步骤包括:根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。In an embodiment, when the processor executes the computer readable instructions, the method further includes: acquiring a running time corresponding to each functional module; and determining, by the processor, the determining according to the historical error information The log level corresponding to each function module, the step of reflecting the fineness of the log record includes: determining the log level corresponding to each function module according to the historical error information and the running time corresponding to each function module, and the log level is reflected The granularity of the log record, the higher the level, the finer the log record.
在一个实施例中,所述在获取服务器中包含的功能模块所对应的功能标识之前,所述处理器还用于执行以下步骤:检测服务器当前所处的运行环境类型;根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。In an embodiment, before the acquiring the function identifier corresponding to the function module included in the server, the processor is further configured to: perform: detecting a type of the running environment where the server is currently located; according to the type of the operating environment Determining a log level division rule corresponding to the type of the running environment.
在一个实施例中,所述处理器所执行的根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息的步骤包括:根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;所述处理器所执行的根据所述每个功能模块对应的错误信息确定每个功 能模块对应的日志等级,日志等级反映了日志记录的精细度的步骤包括:根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。In an embodiment, the step of, according to the history log record corresponding to each function module, the historical error information corresponding to each function module is performed by the processor, including: according to the history log corresponding to each function module Recording each type of error and the corresponding number of error information; determining, by the processor, each function according to error information corresponding to each function module The log level corresponding to the module, the log level reflecting the fineness of the log record includes: calculating the log level corresponding to each function module according to the type of the error information corresponding to each function module and the corresponding number of error information, and the log level reflects The granularity of logging, the higher the level, the finer the logging.
在一个实施例中,所述处理器所执行的根据每个功能模块对应的日志等级进行相应的日志记录的步骤包括:根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则;根据每个功能模块对应的日志记录规则进行相应的日志记录。In an embodiment, the step of performing corresponding log recording according to the log level corresponding to each function module performed by the processor includes: determining, according to a preset correspondence between a log level and a log record rule, a corresponding function module Logging rules; corresponding log records according to the logging rules corresponding to each functional module.
在一个实施例中,提出了一种计算机可读存储介质,其上存储有计算机可读指令,该指令被处理器执行时实现以下步骤:获取服务器中运行的功能模块所对应的功能标识;根据所述功能标识提取每个功能模块对应的历史日志记录;根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;根据每个功能模块对应的日志等级进行相应的日志记录。In one embodiment, a computer readable storage medium is provided having stored thereon computer readable instructions that, when executed by a processor, implement the steps of: obtaining a function identifier corresponding to a function module running in a server; The function identifier extracts a history log record corresponding to each function module; and records historical error information corresponding to each function module according to the history log corresponding to each function module; and determines each function module according to the historical error information. Corresponding log level, the log level reflects the fineness of the log record; the corresponding log record is performed according to the log level corresponding to each function module.
在一个实施例中,所述处理器执行所述计算机可读指令时还用于实现以下步骤:获取每个功能模块对应的运行时长;所述处理器所执行的根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度的步骤包括:根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。In an embodiment, when the processor executes the computer readable instructions, the method further includes: acquiring a running time corresponding to each functional module; and determining, by the processor, the determining according to the historical error information The log level corresponding to each function module, the step of reflecting the fineness of the log record includes: determining the log level corresponding to each function module according to the historical error information and the running time corresponding to each function module, and the log level is reflected The granularity of the log record, the higher the level, the finer the log record.
在一个实施例中,所述在获取服务器中包含的功能模块所对应的功能标识之前,所述处理器还用于执行以下步骤:检测服务器当前所处的运行环境类型;根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。In an embodiment, before the acquiring the function identifier corresponding to the function module included in the server, the processor is further configured to: perform: detecting a type of the running environment where the server is currently located; according to the type of the operating environment Determining a log level division rule corresponding to the type of the running environment.
在一个实施例中,所述处理器所执行的根据所述每个功能模块对应的历 史日志记录统计每个功能模块对应的历史错误信息的步骤包括:根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;所述处理器所执行的根据所述每个功能模块对应的错误信息确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度的步骤包括:根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。In an embodiment, the processor performs a calendar according to each function module. The step of recording, by the history log, the historical error information corresponding to each function module comprises: counting each error type and the corresponding amount of error information according to the historical log record corresponding to each function module; The error information corresponding to each function module determines a log level corresponding to each function module, and the step of the log level reflecting the fineness of the log record includes: calculating according to the type of error information corresponding to each function module and the corresponding number of error information The log level corresponding to each function module, the log level reflects the fineness of the log record. The higher the level, the finer the log record.
在一个实施例中,所述处理器所执行的根据每个功能模块对应的日志等级进行相应的日志记录的步骤包括:根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则;根据每个功能模块对应的日志记录规则进行相应的日志记录。In an embodiment, the step of performing corresponding log recording according to the log level corresponding to each function module performed by the processor includes: determining, according to a preset correspondence between a log level and a log record rule, a corresponding function module Logging rules; corresponding log records according to the logging rules corresponding to each functional module.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,该计算机程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,前述的存储介质可为磁碟、光盘等非易失性存储介质。A person skilled in the art can understand that all or part of the process of implementing the above embodiment method can be completed by a computer program to instruct related hardware, and the computer program can be stored in a computer readable storage medium. When executed, the flow of an embodiment of the methods as described above may be included. The foregoing storage medium may be a non-volatile storage medium such as a magnetic disk or an optical disk.
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above-described embodiments may be arbitrarily combined. For the sake of brevity of description, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction between the combinations of these technical features, All should be considered as the scope of this manual.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。 The above-mentioned embodiments are merely illustrative of several embodiments of the present application, and the description thereof is more specific and detailed, but is not to be construed as limiting the scope of the invention. It should be noted that a number of variations and modifications may be made by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the scope of the invention should be determined by the appended claims.

Claims (20)

  1. 一种日志记录方法,包括:A logging method comprising:
    获取服务器中运行的功能模块所对应的功能标识;Obtaining the function identifier corresponding to the function module running in the server;
    根据所述功能标识提取每个功能模块对应的历史日志记录;Extracting a history log record corresponding to each function module according to the function identifier;
    根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;And collecting historical error information corresponding to each function module according to historical log records corresponding to each function module;
    根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及Determining a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record;
    根据每个功能模块对应的日志等级进行相应的日志记录。Corresponding log records are performed according to the log level corresponding to each function module.
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 further comprising:
    获取每个功能模块对应的运行时长;Obtain the running time corresponding to each function module;
    所述根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度包括:Determining, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record, including:
    根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The log level corresponding to each function module is determined according to the historical error information and the running time corresponding to each function module, and the log level reflects the fineness of the log record. The higher the level, the finer the log record.
  3. 根据权利要求1所述的方法,其特征在于,所述在获取服务器中包含的功能模块所对应的功能标识之前还包括:The method according to claim 1, wherein the obtaining the function identifier corresponding to the function module included in the server further comprises:
    检测服务器当前所处的运行环境类型;Detect the type of operating environment the server is currently in;
    根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。Determining a log level division rule corresponding to the running environment type according to the running environment type.
  4. 根据权利要求1所述的方法,其特征在于,所述根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息包括:The method according to claim 1, wherein the historical error information corresponding to each function module according to the historical log record corresponding to each function module comprises:
    根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;Counting each type of error and the corresponding amount of error information according to historical log records corresponding to each function module;
    所述根据所述每个功能模块对应的错误信息确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度包括: Determining, according to the error information corresponding to each function module, a log level corresponding to each function module, where the log level reflects the fineness of the log record includes:
    根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The log level corresponding to each function module is calculated according to the type of error information corresponding to each function module and the corresponding number of error information. The log level reflects the fineness of the log record. The higher the level, the finer the log record.
  5. 根据权利要求1所述的方法,其特征在于,所述根据每个功能模块对应的日志等级进行相应的日志记录包括:The method according to claim 1, wherein the corresponding log record according to a log level corresponding to each function module comprises:
    根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则;Determining, according to a preset correspondence between a log level and a log record rule, a log record rule corresponding to each function module;
    根据每个功能模块对应的日志记录规则进行相应的日志记录。Corresponding logging is performed according to the logging rules corresponding to each function module.
  6. 一种日志记录装置,包括:A logging device comprising:
    标识获取模块,用于获取服务器中运行的功能模块所对应的功能标识;An identifier obtaining module, configured to acquire a function identifier corresponding to a function module running in the server;
    提取模块,用于根据所述功能标识提取每个功能模块对应的历史日志记录;An extraction module, configured to extract, according to the function identifier, a historical log record corresponding to each function module;
    统计模块,用于根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;a statistics module, configured to collect historical error information corresponding to each function module according to historical log records corresponding to each function module;
    确定模块,用于根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及a determining module, configured to determine, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record;
    记录模块,用于根据每个功能模块对应的日志等级进行相应的日志记录。The recording module is configured to perform corresponding log records according to the log level corresponding to each function module.
  7. 根据权利要求6所述的装置,其特征在于,所述装置还包括:The device according to claim 6, wherein the device further comprises:
    时长获取模块,用于获取每个功能模块对应的运行时长;The time acquisition module is configured to obtain a running time corresponding to each function module;
    所述确定模块还用于根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The determining module is further configured to determine a log level corresponding to each function module according to historical error information and a running time length corresponding to each function module, where the log level reflects the fineness of the log record, and the higher the level, the finer the log record .
  8. 根据权利要求6所述的装置,其特征在于,所述装置还包括:The device according to claim 6, wherein the device further comprises:
    检测模块,用于检测服务器当前所处的运行环境类型;a detection module, configured to detect a type of running environment in which the server is currently located;
    规则确定模块,用于根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。 The rule determining module is configured to determine a log level dividing rule corresponding to the running environment type according to the running environment type.
  9. 根据权利要求6所述的装置,其特征在于,所述统计模块还用于根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;The device according to claim 6, wherein the statistics module is further configured to count, according to the historical log records corresponding to each function module, each error type and a corresponding amount of error information;
    所述确定模块还用于根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The determining module is further configured to calculate a log level corresponding to each function module according to the type of the error information corresponding to each function module and the corresponding number of error information, and the log level reflects the fineness of the log record, and the higher the level, the more the log record fine.
  10. 根据权利要求6所述的装置,其特征在于,所述记录模块还用于根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则,根据每个功能模块对应的日志记录规则进行相应的日志记录。The device according to claim 6, wherein the recording module is further configured to determine, according to a preset correspondence between a log level and a log record rule, a log record rule corresponding to each function module, corresponding to each function module. The logging rules are logged accordingly.
  11. 一种计算机设备,包括存储器和处理器,所述存储器中存储有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述处理器执行以下步骤:A computer apparatus comprising a memory and a processor, the memory storing computer readable instructions, the computer readable instructions being executed by the processor such that the processor performs the following steps:
    获取服务器中运行的功能模块所对应的功能标识;Obtaining the function identifier corresponding to the function module running in the server;
    根据所述功能标识提取每个功能模块对应的历史日志记录;Extracting a history log record corresponding to each function module according to the function identifier;
    根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;And collecting historical error information corresponding to each function module according to historical log records corresponding to each function module;
    根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及Determining a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record;
    根据每个功能模块对应的日志等级进行相应的日志记录。Corresponding log records are performed according to the log level corresponding to each function module.
  12. 根据权利要求11所述的计算机设备,其特征在于,所述处理器还用于执行以下步骤:The computer device according to claim 11, wherein the processor is further configured to perform the following steps:
    获取每个功能模块对应的运行时长;Obtain the running time corresponding to each function module;
    所述根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度包括:Determining, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record, including:
    根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记 录越精细。Determining a log level corresponding to each function module according to the historical error information and the running time corresponding to each function module, and the log level reflects the fineness of the log record, and the higher the level, the log record The more detailed the record.
  13. 根据权利要求11所述的计算机设备,其特征在于,所述处理器在执行所述获取服务器中包含的功能模块所对应的功能标识之前,还用于执行以下步骤:The computer device according to claim 11, wherein the processor is further configured to perform the following steps before performing the function identifier corresponding to the function module included in the acquiring server:
    检测服务器当前所处的运行环境类型;Detect the type of operating environment the server is currently in;
    根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。Determining a log level division rule corresponding to the running environment type according to the running environment type.
  14. 根据权利要求11所述的计算机设备,其特征在于,所述根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息包括:The computer device according to claim 11, wherein the historical error information corresponding to each function module according to the history log record corresponding to each function module comprises:
    根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;Counting each type of error and the corresponding amount of error information according to historical log records corresponding to each function module;
    所述根据所述每个功能模块对应的错误信息确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度包括:Determining, according to the error information corresponding to each function module, a log level corresponding to each function module, where the log level reflects the fineness of the log record includes:
    根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The log level corresponding to each function module is calculated according to the type of error information corresponding to each function module and the corresponding number of error information. The log level reflects the fineness of the log record. The higher the level, the finer the log record.
  15. 根据权利要求11所述的计算机设备,其特征在于,所述根据每个功能模块对应的日志等级进行相应的日志记录包括:The computer device according to claim 11, wherein the corresponding log record according to a log level corresponding to each function module comprises:
    根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则;Determining, according to a preset correspondence between a log level and a log record rule, a log record rule corresponding to each function module;
    根据每个功能模块对应的日志记录规则进行相应的日志记录。Corresponding logging is performed according to the logging rules corresponding to each function module.
  16. 一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:One or more non-transitory readable storage mediums storing computer readable instructions, when executed by one or more processors, cause the one or more processors to perform the following steps:
    获取服务器中运行的功能模块所对应的功能标识; Obtaining the function identifier corresponding to the function module running in the server;
    根据所述功能标识提取每个功能模块对应的历史日志记录;Extracting a history log record corresponding to each function module according to the function identifier;
    根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息;And collecting historical error information corresponding to each function module according to historical log records corresponding to each function module;
    根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度;及Determining a log level corresponding to each function module according to the historical error information, and the log level reflects the fineness of the log record;
    根据每个功能模块对应的日志等级进行相应的日志记录。Corresponding log records are performed according to the log level corresponding to each function module.
  17. 根据权利要求16所述的存储介质,其特征在于,所述处理器还用于执行以下步骤:The storage medium according to claim 16, wherein the processor is further configured to perform the following steps:
    获取每个功能模块对应的运行时长;Obtain the running time corresponding to each function module;
    所述根据所述历史错误信息确定与每个功能模块对应的日志等级,日志等级反映了日志记录的精细度包括:Determining, according to the historical error information, a log level corresponding to each function module, where the log level reflects the fineness of the log record, including:
    根据所述每个功能模块对应的历史错误信息和运行时长确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高,日志记录越精细。The log level corresponding to each function module is determined according to the historical error information and the running time corresponding to each function module, and the log level reflects the fineness of the log record. The higher the level, the finer the log record.
  18. 根据权利要求16所述的存储介质,其特征在于,所述处理器在执行所述获取服务器中包含的功能模块所对应的功能标识之前还包括:The storage medium according to claim 16, wherein the processor further comprises: before executing the function identifier corresponding to the function module included in the acquiring server:
    检测服务器当前所处的运行环境类型;Detect the type of operating environment the server is currently in;
    根据所述运行环境类型确定与所述运行环境类型对应的日志等级划分规则。Determining a log level division rule corresponding to the running environment type according to the running environment type.
  19. 根据权利要求16所述的存储介质,其特征在于,所述根据所述每个功能模块对应的历史日志记录统计每个功能模块对应的历史错误信息包括:The storage medium according to claim 16, wherein the historical error information corresponding to each function module according to the history log record corresponding to each function module comprises:
    根据所述每个功能模块对应的历史日志记录统计每一种错误类型和相应的错误信息数量;Counting each type of error and the corresponding amount of error information according to historical log records corresponding to each function module;
    所述根据所述每个功能模块对应的错误信息确定每个功能模块对应的日志等级,日志等级反映了日志记录的精细度包括:Determining, according to the error information corresponding to each function module, a log level corresponding to each function module, where the log level reflects the fineness of the log record includes:
    根据每个功能模块对应的错误信息类型和相应的错误信息数量计算每个功能模块对应的日志等级,日志等级反映了日志记录的精细度,等级越高, 日志记录越精细。Calculate the log level corresponding to each function module according to the type of error information corresponding to each function module and the corresponding number of error information. The log level reflects the fineness of the log record, and the higher the level, The finer the logging.
  20. 根据权利要求16所述的存储介质,其特征在于,所述根据每个功能模块对应的日志等级进行相应的日志记录包括:The storage medium according to claim 16, wherein the performing the corresponding log record according to the log level corresponding to each function module comprises:
    根据预设的日志等级与日志记录规则的对应关系确定每个功能模块对应的日志记录规则;Determining, according to a preset correspondence between a log level and a log record rule, a log record rule corresponding to each function module;
    根据每个功能模块对应的日志记录规则进行相应的日志记录。 Corresponding logging is performed according to the logging rules corresponding to each function module.
PCT/CN2017/108061 2017-06-23 2017-10-27 Method, device, computer device, and storage medium for recording a log WO2018233170A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710488996.9 2017-06-23
CN201710488996.9A CN107678908B (en) 2017-06-23 2017-06-23 Log recording method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2018233170A1 true WO2018233170A1 (en) 2018-12-27

Family

ID=61133915

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/108061 WO2018233170A1 (en) 2017-06-23 2017-10-27 Method, device, computer device, and storage medium for recording a log

Country Status (2)

Country Link
CN (1) CN107678908B (en)
WO (1) WO2018233170A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144836B (en) * 2018-08-06 2021-09-28 创新先进技术有限公司 Method and device for processing operation log and electronic equipment
CN109324970A (en) * 2018-09-28 2019-02-12 平安普惠企业管理有限公司 SDK running environment detection method, device, computer equipment and storage medium
CN110351126A (en) * 2019-06-26 2019-10-18 中信百信银行股份有限公司 Log rank method of adjustment, device and electronic equipment
CN111010290B (en) * 2019-11-22 2022-11-29 泰康保险集团股份有限公司 Service log processing method and device, electronic equipment and storage medium
CN110932904B (en) * 2019-11-29 2022-08-09 新华三半导体技术有限公司 Key log recording method and device and network equipment
CN111786828B (en) * 2020-06-29 2023-07-11 百度在线网络技术(北京)有限公司 Log processing method executed in network equipment and network equipment
CN112491584B (en) * 2020-11-04 2022-05-20 贝壳技术有限公司 Service operation safety condition judgment method and device, electronic medium and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657255A (en) * 2013-11-25 2015-05-27 国际商业机器公司 Computer-implemented method and system for monitoring information technology systems
CN104935444A (en) * 2014-03-17 2015-09-23 杭州华三通信技术有限公司 Heterogeneous log system management configuration device and method
CN105528280A (en) * 2015-11-30 2016-04-27 中电科华云信息技术有限公司 Method and system capable of determining log alarm grades according to relationship between system logs and health monitoring
CN106156355A (en) * 2016-07-27 2016-11-23 腾讯科技(深圳)有限公司 Log processing method and device
CN106775929A (en) * 2016-11-25 2017-05-31 中国科学院信息工程研究所 A kind of virtual platform safety monitoring method and system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593148B (en) * 2009-04-15 2012-02-29 卡斯柯信号有限公司 Dynamic multi-output log processing system
CN103645982B (en) * 2013-11-29 2017-11-14 北京奇虎科技有限公司 Log processing method and client

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657255A (en) * 2013-11-25 2015-05-27 国际商业机器公司 Computer-implemented method and system for monitoring information technology systems
CN104935444A (en) * 2014-03-17 2015-09-23 杭州华三通信技术有限公司 Heterogeneous log system management configuration device and method
CN105528280A (en) * 2015-11-30 2016-04-27 中电科华云信息技术有限公司 Method and system capable of determining log alarm grades according to relationship between system logs and health monitoring
CN106156355A (en) * 2016-07-27 2016-11-23 腾讯科技(深圳)有限公司 Log processing method and device
CN106775929A (en) * 2016-11-25 2017-05-31 中国科学院信息工程研究所 A kind of virtual platform safety monitoring method and system

Also Published As

Publication number Publication date
CN107678908B (en) 2020-07-31
CN107678908A (en) 2018-02-09

Similar Documents

Publication Publication Date Title
WO2018233170A1 (en) Method, device, computer device, and storage medium for recording a log
WO2021169270A1 (en) Server fault pre-warning method, device, computer apparatus, and storage medium
US11687391B2 (en) Serializing machine check exceptions for predictive failure analysis
WO2022089202A1 (en) Fault identification model training method, fault identification method, apparatus and electronic device
US20170017537A1 (en) Apparatus and method of leveraging semi-supervised machine learning principals to perform root cause analysis and derivation for remediation of issues in a computer environment
US11550628B2 (en) Performing runbook operations for an application based on a runbook definition
US8631280B2 (en) Method of measuring and diagnosing misbehaviors of software components and resources
CN110716842A (en) Cluster fault detection method and device
US20030084376A1 (en) Software crash event analysis method and system
US11310140B2 (en) Mitigating failure in request handling
CN112631887A (en) Abnormality detection method, abnormality detection device, electronic apparatus, and computer-readable storage medium
CN106021054A (en) Method and apparatus for testing upgrading and downgrading stability of BMC
CN112699007A (en) Method, system, network device and storage medium for monitoring machine performance
CN113590432A (en) Database inspection method and device
US8984333B2 (en) Automatic computer storage medium diagnostics
CN115509797A (en) Method, device, equipment and medium for determining fault category
CN113806178B (en) Cluster node fault detection method and device
CN117827506A (en) MySQL abnormal user thread detection method based on system resource consumption
CN113590405A (en) Hard disk error detection method and device, storage medium and electronic device
US10776240B2 (en) Non-intrusive performance monitor and service engine
CN113608959B (en) Method, system, terminal and storage medium for positioning fault hard disk
CN115437961A (en) Data processing method and device, electronic equipment and storage medium
CN113742113B (en) Health management method, equipment and storage medium for embedded system
CN115237641A (en) Fault detection method and device, electronic equipment and readable medium
CN117407207B (en) Memory fault processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17915129

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 15/05/2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17915129

Country of ref document: EP

Kind code of ref document: A1