Log management method and computer readable storage medium

Through real-time monitoring and dynamic adjustment of log weights, the flexibility and stability of the gateway device log management system is solved, efficient log management and diversified storage are realized, and the system's operating stability and the utilization value of log data are improved.

CN119011200APending Publication Date: 2024-11-22FUJIAN STAR NET WISDOM TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410964015.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

The log management system of existing gateway devices lacks flexibility and cannot dynamically adjust log policies, resulting in waste of resources, insufficient storage, difficulty in log analysis and poor adaptability under high load conditions, affecting system stability and efficiency.

Method used

By monitoring the logs generated by each process in real time, calculating log weights, and dynamically adjusting the default log level according to the weights, providing a variety of storage and output options to ensure that the log system always runs in the optimal state.

Benefits of technology

It improves log management efficiency and system stability, reduces unnecessary logging, optimizes resource usage, supports diversified log storage methods, and enhances the application value of log data and the system's response capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119011200A_ABST
    Figure CN119011200A_ABST
Patent Text Reader

Abstract

The invention discloses a log management method and a computer readable storage medium, and the method comprises the steps: monitoring logs generated by each process in real time, and carrying out the statistics of log statistical data of each process in a preset unit time, the log statistical data comprising the number of logs corresponding to each log level; calculating the log weight of each process according to the log statistical data of each process and the preset score of each process, and calculating the average weight according to the log weight of each process; if the log weight of one process exceeds a weight threshold range, the default log level of the process is adjusted, and the weight threshold range is determined according to the average weight. The log strategy can be dynamically adjusted, and the log management efficiency and the system operation stability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a log management method and a computer-readable storage medium. Background Art

[0002] In enterprise networks, gateway devices play an important role in managing and monitoring network traffic. The log module is a key part of the gateway device, used to record the device's operating status, fault information, and security events. However, the existing log system of gateway devices generally has the following shortcomings:

[0003] 1. Static log configuration: Most existing log management systems use static configuration, which means that the log level and output method are difficult to change after the system is deployed, which limits the flexibility and adaptability of log management;

[0004] 2. Resource consumption problem: Due to static configuration, the system may not be able to effectively distinguish the importance of logs, resulting in a large number of unimportant logs being recorded and stored, which not only takes up valuable storage space but also may affect system performance;

[0005] 3. Lack of real-time monitoring and adjustment capabilities: Existing systems usually lack the ability to monitor log generation in real time, so they cannot dynamically adjust log policies based on current system status and needs;

[0006] 4. Single log storage method: Many systems only provide a single log storage method, such as saving only to the local file system, which may not be sufficient to meet the requirements for log security and accessibility in some cases;

[0007] 5. Difficulty in log analysis and retrieval: Due to the suboptimal organization and storage of logs, it is difficult to analyze and retrieve logs when needed, which limits the value of log data.

[0008] 6. Poor adaptability to high load conditions: When the system load is high, the existing log system may not be able to effectively process a large amount of log data, resulting in log loss or system response delays.

[0009] In other words, traditional log management systems are usually unable to flexibly respond to the output requirements of logs at different levels and lack the ability to dynamically adjust log policies, resulting in inefficient log management, waste of storage resources, and difficulty in responding to system changes and troubleshooting needs in a timely manner. Summary of the invention

[0010] The technical problem to be solved by the present invention is to provide a log management method and a computer-readable storage medium, which can dynamically adjust the log strategy to improve the log management efficiency and system operation stability.

[0011] In order to solve the above technical problems, the technical solution adopted by the present invention is: a log management method, comprising:

[0012] Monitor the logs generated by each process in real time, and count the log statistics of each process within a preset unit time, wherein the log statistics include the number of logs corresponding to each log level;

[0013] Calculate the log weight of each process according to the log statistics of each process and the preset score of each process, and calculate the average weight according to the log weight of each process;

[0014] If the log weight of a process exceeds a weight threshold range, the default log level of the process is adjusted, wherein the weight threshold range is determined according to the average weight.

[0015] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described above is implemented.

[0016] The beneficial effects of the present invention are: by real-time monitoring of the log generation of each process, and analyzing and calculating the log weight of each process, when the log weight of a process deviates from the average weight of all processes, it is considered that there is a problem with the process, and the default log level of the process is adjusted. The present invention monitors and analyzes the log generation of each process in real time, dynamically adjusts the default log level of the process, improves log management efficiency, and can ensure that the log system always runs in an optimal state, enhancing the operational stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A flow chart of a log management method of the present invention;

[0018] Figure 2 This is a flow chart of a method according to Embodiment 1 of the present invention. DETAILED DESCRIPTION

[0019] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is a detailed description in conjunction with the implementation methods and the accompanying drawings.

[0020] See also Figure 1 , a log management method, comprising:

[0021] Monitor the logs generated by each process in real time, and count the log statistics of each process within a preset unit time, wherein the log statistics include the number of logs corresponding to each log level;

[0022] Calculate the log weight of each process according to the log statistics of each process and the preset score of each process, and calculate the average weight according to the log weight of each process;

[0023] If the log weight of a process exceeds a weight threshold range, the default log level of the process is adjusted, wherein the weight threshold range is determined according to the average weight.

[0024] From the above description, it can be seen that the beneficial effect of the present invention is that the efficiency and flexibility of log management are improved by dynamically adjusting the default log level of the process.

[0025] Furthermore, after real-time monitoring of the logs generated by each process, the method further includes:

[0026] According to the log level of the log, the corresponding output format and storage path are determined, and the log is output to the corresponding storage path according to its corresponding output format.

[0027] Furthermore, the storage path includes at least one of a serial port device, a mobile storage device, a remote log server and a local file, and the local file includes a general log file and / or a local dedicated log file.

[0028] From the above description, it can be seen that by providing a variety of log storage and output options, a variety of log storage methods are achieved.

[0029] Furthermore, before calculating the log weight of each process according to the log statistics of each process within the preset unit time and the preset score of each process, the method further includes:

[0030] The score of each process is preset according to the importance of each process.

[0031] Furthermore, the log weight of each process is calculated according to the log statistics of each process in the preset unit time and the preset score of each process, specifically:

[0032] According to the log weight calculation formula, the log weight of each process is calculated respectively. The log weight calculation formula is:

[0033]

[0034] Among them, W i represents the log weight of the ith process, S i represents the score of the i-th process, L j Indicates the quantized value corresponding to the jth log level, m ij Indicates the number of logs of the jth log level corresponding to the i-th process, and n is the total number of log levels.

[0035] Furthermore, if the log weight of a process exceeds a weight threshold range, adjusting the default log level of the process includes:

[0036] If the log weight of a process is greater than a first weight threshold, the default log level of the process is reduced according to a preset level step;

[0037] If the log weight of a process is less than the second weight threshold, the default log level of the process is increased according to a preset level step;

[0038] The first weight threshold and the second weight threshold are calculated according to the average weight and a preset ratio.

[0039] Further, the adjusting the default log level of the process is specifically:

[0040] Modify the default log level of the process in the configuration file, and send an update message to the process so that the process reads the modified default log level.

[0041] From the above description, it can be seen that the default log level of the process can be dynamically modified while the system is running, without restarting the process or the system, thereby improving the efficiency of log management.

[0042] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described above is implemented.

[0043] Embodiment 1

[0044] Please refer to Figure 2 , Embodiment 1 of the present invention is: a log management method, which can be applied to the log system of a gateway device.

[0045] The storage of the gateway device itself is extremely limited, but the functional modules involved are numerous. Assuming that there is a problem with the voice module, if the log level is set too high, the voice module will only output a few fatal logs, which is not conducive to troubleshooting; if the log level is too low, a large number of useless logs will occupy the small storage space. The purpose of this embodiment is to record more useful logs in as little storage as possible.

[0046] like Figure 2 As shown, the method of this embodiment includes the following steps:

[0047] S1: monitor the logs generated by each process in real time, and count the log statistics of each process within a preset unit time, wherein the log statistics include the number of logs corresponding to each log level, and may also include the total number of logs, etc.

[0048] In this embodiment, the log levels from low to high include Debug, Information, Notice, Warning, Error, Critical, Alert, and Emergency.

[0049] Each process has a default log level, which is equivalent to the minimum log level. That is, the log level of the logs generated by the process is not lower than its default log level.

[0050] S2: Determine the corresponding output format and storage path according to the log level of the log, and output the log to the corresponding storage path according to the corresponding output format.

[0051] The storage path includes at least one of a serial port device, a mobile storage device (such as a USB flash drive), a remote log server, and a local file, and the local file includes a general log file and a local dedicated log file.

[0052] By providing a variety of log storage and output options, a variety of log storage methods are achieved.

[0053] This step and the following steps can be performed simultaneously or in any order.

[0054] S3: preset the score of each process according to the importance of each process.

[0055] For example, for a gateway device, the most important function is WAN connection, so the score of the corresponding process is set to 100 points; the score of the process corresponding to the voice function can be set to 80 points; the VPN function is less used, so the score of the corresponding process can be set to 30 points.

[0056] S4: Calculate the log weight of each process according to the log statistics of each process and the preset score of each process, and calculate the average weight according to the log weight of each process.

[0057] In this embodiment, the log weight of each process is calculated according to the log weight calculation formula, and the log weight calculation formula is:

[0058]

[0059] Among them, W i represents the log weight of the ith process, S i represents the score of the i-th process, L j Indicates the quantized value corresponding to the jth log level, m ij Indicates the number of logs of the jth log level corresponding to the i-th process, and n is the total number of log levels.

[0060] In this embodiment, the quantization values ​​of the eight log levels from low to high are set to 1-8 respectively.

[0061] For example, assuming that the current default log level of process A is Error, the score of process A is 100, and within a preset unit time (such as 1 hour), a total of 60 logs are generated, of which 20 logs have a log level of Error, 20 logs have a log level of Critical, and 20 logs have a log level of Alert. Then the log weight of process A = 100×(5×20+6×20+7×20)=3600.

[0062] After calculating the log weights of all processes, the average value is calculated to get the average weight of all processes.

[0063] S5: Determine a weight threshold range based on the average weight.

[0064] In this embodiment, the weight threshold range is determined based on the average weight and a preset ratio. For example, the weight threshold range may be the average weight ±10%, that is, the two endpoints of the weight threshold range are the first weight threshold and the second weight threshold, respectively. The first weight threshold = average weight × (1 + 10%), and the second weight threshold = average weight × (1-10%).

[0065] S6: Adjust the default log level for processes whose log weight exceeds the weight threshold.

[0066] Specifically, if the log weight of a process is greater than the first weight threshold, the default log level of the process is reduced according to the preset level step; if the log weight of a process is less than the second weight threshold, the default log level of the process is increased according to the preset level step. In this embodiment, the preset level step is 1 level. For example, if the current default log level is Error, it will be reduced by one level to Warning and increased by one level to Critical.

[0067] When the default log level of a process is to be modified, the default log level of the process in the configuration file can be modified, and an update message can be sent to the process so that the process reads the modified default log level.

[0068] In actual application scenarios, a real-time adjustment interface can be provided to allow administrators to dynamically modify the default log level of the process and the log output method while the system is running. The modification operation takes effect immediately without restarting the process or system.

[0069] In actual scenarios, before a serious BUG occurs in a process, a large number of relatively high-level logs (or a small number of logs with the highest severity level) will be printed, so that within a certain period of time, the log weight of this process will rise. This embodiment reduces its default log level so that it outputs more logs later. When the process log output is frequent (for example, the total number of logs generated within a preset unit time is greater than the preset number threshold), it is easy to be noticed by the operator, which is convenient for the operator to maintain. If the process returns to normal afterwards, it will output a log with a lower log level, and the log weight will be reduced. When its log weight is lower than the second weight threshold, its default log level will be raised back.

[0070] This embodiment can enable the system to process log data more effectively and reduce unnecessary log records by dynamically adjusting the log strategy, thereby improving the overall log efficiency; by intelligently screening and storing important logs, the demand for storage resources is reduced, and the load of system log processing is reduced, thereby optimizing resource usage and helping to maintain smooth operation of the system; by real-time monitoring and dynamic adjustment of log strategies, while outputting logs to multiple devices and media, system administrators can respond to and resolve potential problems more quickly, thereby enhancing data security.

[0071] Embodiment 2

[0072] This embodiment is a computer-readable storage medium corresponding to the above embodiment, on which a computer program is stored. When the program is executed by the processor, the various steps of a log management method in the above embodiment are implemented, and the same technical effect can be achieved, which will not be repeated here.

[0073] In summary, the log management method and computer-readable storage medium provided by the present invention can improve the efficiency and flexibility of log management by monitoring and analyzing the log generation of each process in real time, dynamically adjusting the default log level of the process, and ensuring that the log system always runs in the optimal state, thereby enhancing the operating stability of the system. Even under high load conditions, the system can stably process and store log data to avoid log loss and system delays; support a variety of log storage methods; ensure that only important logs are recorded and stored by intelligently identifying and classifying logs, thereby reducing unnecessary resource consumption; and optimize the organization and storage structure of logs to make log data easier to analyze and retrieve, thereby improving the application value of log data.

[0074] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A log management method, characterized in that: include: Monitor the logs generated by each process in real time, and count the log statistics of each process within a preset unit time, wherein the log statistics include the number of logs corresponding to each log level; Calculate the log weight of each process according to the log statistics of each process and the preset score of each process, and calculate the average weight according to the log weight of each process; If the log weight of a process exceeds a weight threshold range, the default log level of the process is adjusted, wherein the weight threshold range is determined according to the average weight.

2. The log management method according to claim 1, characterized in that: After the real-time monitoring of the logs generated by each process, the method further includes: According to the log level of the log, the corresponding output format and storage path are determined, and the log is output to the corresponding storage path according to its corresponding output format.

3. The log management method according to claim 2, characterized in that: The storage path includes at least one of a serial port device, a mobile storage device, a remote log server and a local file, and the local file includes a general log file and / or a local dedicated log file.

4. The log management method according to claim 1, characterized in that: Before calculating the log weight of each process according to the log statistics of each process in the preset unit time and the preset score of each process, the method further includes: The score of each process is preset according to the importance of each process.

5. The log management method according to claim 1, characterized in that: The log weight of each process is calculated according to the log statistics of each process in a preset unit time and the preset score of each process, specifically: According to the log weight calculation formula, the log weight of each process is calculated respectively. The log weight calculation formula is: Among them, W i represents the log weight of the ith process, S i represents the score of the i-th process, L j Indicates the quantized value corresponding to the jth log level, m ij Indicates the number of logs of the jth log level corresponding to the i-th process, and n is the total number of log levels.

6. The log management method according to claim 1, characterized in that: If the log weight of a process exceeds a weight threshold range, adjusting the default log level of the process includes: If the log weight of a process is greater than a first weight threshold, the default log level of the process is reduced according to a preset level step; If the log weight of a process is less than the second weight threshold, the default log level of the process is increased according to a preset level step; The first weight threshold and the second weight threshold are calculated according to the average weight and a preset ratio.

7. The log management method according to claim 1, characterized in that: The step of adjusting the default log level of a process is as follows: Modify the default log level of the process in the configuration file, and send an update message to the process so that the process reads the modified default log level.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.