Log printing method and device, equipment, storage medium and program product

By monitoring the log level of the business module in the open source network operating system and adaptively adjusting it, the problem of not being able to obtain sufficient log information during a failure is solved, and the efficiency of fault location is improved.

CN119621488APending Publication Date: 2025-03-14INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510155134.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-12
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The existing open source network operating system cannot obtain sufficient log information when a failure occurs, resulting in a large amount of time, manpower and material resources spent, and low efficiency.

Method used

By monitoring whether the business module generates a target log level log, the log level of the business module in the log configuration information is adaptively adjusted to ensure that the lower level log is printed in the event of a failure to obtain more information for fault location.

Benefits of technology

It realizes obtaining more log information when a fault occurs, improves the efficiency of fault location, and reduces manpower and material consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119621488A_ABST
    Figure CN119621488A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a log printing method and device, equipment, a storage medium and a program product. The method comprises the following steps: in response to a situation that a service module does not generate a log of a target log level, according to a first log level currently corresponding to the service module in log configuration information, printing the log, which is not lower than the first log level, of the service module; in response to the log of the target log level generated by the service module, modifying the log level corresponding to the service module into a second log level in the log configuration information, and printing the log, which is not lower than the second log level, of the service module, the first log level is not higher than the target log level, and the log level corresponding to the service module in the log configuration information is used for representing the lowest log level needing to be printed by the service module. More log information for fault positioning can be obtained, so that the fault positioning efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a log printing method, device, equipment, storage medium and program product. Background Art

[0002] With the rapid development of the Internet, big data, and artificial intelligence, many basic hardware devices (such as switches, network cards) and supporting professional software bundled sales solutions are inefficient and cannot meet actual needs. At the same time, due to the different implementation solutions and design standards of different manufacturers, the interface standard protocols are uneven, which greatly affects the delivery of network equipment and the development of a new generation of networking solutions. Therefore, the open source unification of network standards and the decoupling of network equipment software and hardware have become an inevitable trend for future development. Against this background, some technologies have launched open source network operating systems. All software function modules of open source network operating systems are open source, which can greatly promote the trend of network open source and software and hardware decoupling.

[0003] At present, although the open source network operating system has been rapidly developed, due to its new architecture, there are still many functions to be improved. For example, when a fault occurs, the current open source network operating system cannot obtain enough log information for fault location, resulting in a lot of time, manpower and material resources being consumed in the fault location process, and low efficiency. Summary of the invention

[0004] In view of this, the present disclosure provides a log printing method, a log printing device, an electronic device, a non-volatile computer-readable storage medium, and a computer program product, which can obtain more log information for fault location, thereby improving the efficiency of fault location.

[0005] In a first aspect, the present disclosure provides a log printing method, the method comprising: In response to the business module not generating a log of a target log level, printing a log of the business module that is not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information; In response to the business module generating a log of the target log level, the log level corresponding to the business module is modified to a second log level in the log configuration information, and a log of the business module that is not lower than the second log level is printed, wherein the second log level is lower than the first log level, and the first log level is not higher than the target log level, and the log level corresponding to the business module in the log configuration information is used to represent the minimum log level that the business module needs to print.

[0006] In a second aspect, the present disclosure provides a log printing device, the device comprising: A first log printing module, configured to, in response to the business module not generating a log of a target log level, print a log of the business module not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information; A second log printing module is used to respond to the business module generating a log of the target log level, modify the log level corresponding to the business module in the log configuration information to a second log level, and print the log of the business module that is not lower than the second log level, wherein the second log level is lower than the first log level, and the first log level is not higher than the target log level, and the log level corresponding to the business module in the log configuration information is used to control the minimum log level to be printed by the business module.

[0007] In a third aspect, the present disclosure provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the above method by executing the computer instructions.

[0008] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the above method.

[0009] In a fifth aspect, the present disclosure provides a computer program product, including computer instructions, and the computer instructions are used to enable a computer to execute the above method.

[0010] In the technical scheme of some embodiments of the present disclosure, by monitoring whether the business module generates a log of the target log level, it is determined whether to modify the log level corresponding to the business module in the log configuration information. In this way, adaptive adjustment of the log level can be achieved, so that when there is no fault problem in the business module, a higher level log can be printed, the amount of log printing can be reduced, and the problem of low-level log screen swiping can be avoided. When a fault problem occurs in the business module, a lower level log of the business module is printed, so that more log information for fault location can be obtained, and the efficiency of fault location can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1This is a flow chart of log printing in some open source network operating systems; Figure 2 It is a schematic diagram of some technologies modifying the minimum log level corresponding to the business module; Figure 3 is a flowchart of a log printing method provided by some embodiments of the present disclosure; Figure 4 is an interactive schematic diagram of a log printing method provided by some embodiments of the present disclosure; Figure 5 A log printing device provided by some embodiments of the present disclosure; Figure 6 It is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. DETAILED DESCRIPTION

[0013] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0014] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0015] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "some embodiments" or "the embodiment" should be understood as "at least some embodiments". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.

[0016] Herein, unless explicitly stated, executing a step “in response to A” does not mean executing the step immediately after “A” but may include one or more intermediate steps.

[0017] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition, use, storage or deletion of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.

[0018] It is understandable that before using the technical solutions disclosed in the various embodiments of the present disclosure, the types, scopes of use, usage scenarios, etc. of the information involved in the present disclosure should be informed to relevant users and their authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. The relevant users may include any type of right holders, such as individuals, enterprises, and groups.

[0019] For example, in response to receiving an active request from a user, a prompt message is sent to the relevant user to clearly prompt the relevant user that the operation requested to be performed will require obtaining and using the information of the relevant user, so that the relevant user can independently choose whether to provide information to software or hardware such as an electronic device, application, server or storage medium that executes the operation of the technical solution of the present disclosure based on the prompt message.

[0020] As an optional but non-limiting implementation, in response to receiving an active request from a relevant user, a prompt message is sent to the relevant user, for example, in the form of a pop-up window, in which the prompt message may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to select "agree" or "disagree" to provide information to the electronic device.

[0021] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.

[0022] The essence of an open source network operating system is to add various network-related applications to the Linux kernel and package it into a system image. The open source network operating system has its own functional characteristics, such as the key databases it uses, the modules containers, and the corresponding sub-module functions in each module container, which together constitute the entire system.

[0023] In an open source network operating system, the log levels of each business module can be divided into multiple levels such as debug, info, notice, warning, error, critical, alert, and emerg. Logs of different levels can be used to record different system operation information. For example, debug-level logs can be used to record program operation information, such as variable values, function calls, execution paths, etc.; info-level logs can be used to record general information such as program startup, configuration information, and key operation completion, such as program startup time, loaded configuration, etc.; error-level logs can be used to record program errors that will not cause system crashes, such as failure to connect to the database, file read and write errors, etc.; critical-level logs can be used to record error information that will cause system downtime, such as key component crashes, database loss of key data, etc.

[0024] The log levels can be sorted in the order of emerge>alert>critical>error>warning>notice>info>debug. The higher the log level of a log, the higher the severity and importance of the log. For example, a critical-level log is more serious and important than an error-level log. Generally, high-level logs are used to record information that may have a greater impact on the system, and the corresponding number of logs can be small; low-level logs are used to record detailed information about system operation, and the corresponding number of logs can be large. In order to avoid not paying attention to high-level logs due to a large number of low-level logs flooding the screen, you can configure the minimum log level to be printed for each business module. In this way, when printing the logs of each business module, you can only print the logs of the business module that are not lower than the minimum log level. For example, assuming that the minimum log level that business module A needs to print is the warning level, and the minimum log level that business module B needs to print is the notice level, then when printing the log of business module A in the system's log file, you can only print logs at the warning, error, critical, alert, and emerg levels; and when printing the log of business module B, you can only print logs at the notice, warning, error, critical, alert, and emerg levels.

[0025] Combined with reference Figure 1 , which is a flowchart of log printing in some open source network operating systems. Figure 1In the case where there are multiple log levels, the multiple log levels can correspond one to one with multiple log printing functions. For any log level, the business module can call the log printing function corresponding to the log level to print the log of the log level into the first log file. For example, when business module A needs to print a log at the warning level, it can call the log printing function warning corresponding to the warning level to print the log at the warning level into the first log file; when business module B needs to print a log at the notice level, it can call the log printing function notice corresponding to the notice level to print the log at the notice level into the first log file. The log printing process can monitor the first log file. When the log is written into the first log file, the log printing process can filter the logs of each business module in the first log file based on the minimum log level that each business module needs to print configured in the log level configuration file, thereby printing the logs of each business module that are not lower than the minimum log level in the second log file. For example, suppose that in the log level configuration file, the minimum log level corresponding to business module A is configured as notice level, and the minimum log level corresponding to business module B is configured as warning level, and in the first log file, business module A writes logs of debug, info, notice, warning, and error levels by calling the log printing function, and business module B writes logs of notice, warning, error, and critical levels by calling the log printing function. Then, the log printing process can extract the logs of notice, warning, and error levels of business module A, and extract the logs of warning, error, and critical levels of business module B from the first log file, and print the extracted logs into the second log file.

[0026] The second log file may be a log file provided to the user for viewing. In the second log file, the user may view logs of each business module that are not lower than the minimum log level. Since the logs printed by each business module are filtered based on the log level configuration file, the situation where low-level logs appear in the second log file can be avoided.

[0027] In some technologies, the log printing function may include functions such as syslog_error(), syslog_warning(), syslog_error(), and syslog_info(). The log printing process may be an rsyslogd process. The first log file may be a / dev / log file, and the second log file may be a file similar to / var / log / syslog. The log level configuration file may be an rsyslog.conf file.

[0028] In theory, users can modify the minimum log level corresponding to each business module in the log level configuration file according to actual needs. However, in some technologies, users cannot directly modify the log level configuration file, but need to use the swssloglevel tool interface provided by the open source network operating system to modify the minimum log level corresponding to the business module. Since the swssloglevel tool interface only supports some business modules, the minimum log level of some business modules can only be the default value and cannot be modified. In view of this, other technologies have improved this problem.

[0029] Combined with reference Figure 2 , which is a schematic diagram of other technologies modifying the minimum log level corresponding to the business module. Figure 2 In the CLI interactive window of the open source network operating system, a log level modification tool is provided. Through the log level modification tool, users can issue instructions to modify or set the minimum log level corresponding to each business module. The open source network operating system includes two databases: the configuration database (config_DB) and the temporary database (loglevel_DB).

[0030] In the configuration database, the SYSLOG_SEVERITY_TABLE table can be introduced to store the minimum log level corresponding to each business module set by the user through the log level modification tool. The data in the SYSLOG_SEVERITY_TABLE table can be synchronized to the temporary database. The minimum log level corresponding to each business module in the temporary database will be destroyed with the restart of the open source network operating system, and the minimum log level corresponding to each business module in the configuration database will be permanently saved and will not be destroyed with the restart of the open source network operating system. The configuration will only take effect after the minimum log level corresponding to the business module is written to the temporary database. In simple terms, after the user sets the minimum log level corresponding to a business module in the SYSLOG_SEVERITY_TABLE table of the configuration database through the log level modification tool, if the setting is not synchronized to the temporary data, the configuration is ineffective. Only after the configuration is synchronized to the temporary database, the configuration will take effect. During each system restart, the data in the temporary database will be destroyed and the data will be resynchronized from the configuration database.

[0031] Based on the above description, in these technologies, the business modules are divided into business modules supported by the native tool interface swssloglevelveL of the open source network operating system and business modules not supported by the native tool interface swssloglevelveL. For different business modules, the minimum log level can be modified based on different modification logics. The following are explained separately.

[0032] 1) For business modules that are not supported by the native tool interface swsslogleveL.

[0033] These business modules are divided into one or more business containers, each of which includes one or more business modules. Each business container includes a log level configuration file. For any business container, the log level configuration file in the business container is used to set the minimum log level corresponding to each business module in the container.

[0034] The first services config_checker.py and loglevelmgrd are introduced into the open source network operating system, and the first service docker_config_rsyslog_conf.py is introduced into each business container.

[0035] The config_checker.py service can be started when the open source network operating system is started, and perform the following operations after startup: In the SYSLOG_SEVERITY_TABLE table of the configuration database, check whether each business module under each business container has a corresponding minimum log level. For any business module, if the minimum log level corresponding to the business module exists in the SYSLOG_SEVERITY_TABLE table, the minimum log level corresponding to the business module remains unchanged; if the minimum log level corresponding to the business module does not exist in the SYSLOG_SEVERITY_TABLE table, a new minimum log level corresponding to the business module is created in the SYSLOG_SEVERITY_TABLE table. The newly created minimum log level can be a preset default level, such as a notice level or a warning level.

[0036] The Loglevelmgrd service can be started when the open source network operating system is started. Compared with the config_checker.py service, the startup order of the Loglevelmgrd service can be relatively later. Since the minimum log level corresponding to each business module in the temporary database will be destroyed when the open source network operating system is restarted, after the Loglevelmgrd service is started, the following operations can be performed: from the SYSLOG_SEVERITY_TABLE table of the configuration database, the minimum log level corresponding to the business module that is not supported by the native tool interface swsslogleveL is synchronized to the temporary database. In this way, the minimum log level corresponding to each business module is in effect. At the same time, the Loglevelmgrd service can also monitor the SYSLOG_SEVERITY_TABLE table. For business modules that are not supported by the native tool interface swsslogleveL, if the minimum log level corresponding to these business modules is monitored to change (that is, the user modifies the minimum log level through the log level modification tool), the hset instruction is used to synchronize the data to the temporary database.

[0037] docker_config_rsyslog_conf.py can be started when the business container in which it is located is started. After the docker_config_rsyslog_conf.py service is started, the following operations can be performed: according to the minimum log level corresponding to each business module in the temporary database, add the minimum log level corresponding to each business module in this business container to the log level configuration file of this business container, and then restart the log printing process to make the configuration in the log level configuration file take effect. At the same time, you can also monitor the minimum log level corresponding to each business module belonging to this business container in the temporary database. If the minimum log level corresponding to the business module belonging to this business container is monitored to change, synchronize the change to the log level configuration file of this business container, and restart the log printing process to make the synchronization content in the log level configuration file take effect.

[0038] The log printing process can filter logs based on the log level configuration files in each business container. So far, based on the above steps, the minimum log level adjustment for business modules that are not supported by the native tool interface swssloglevel has been achieved.

[0039] 2) Business modules supported by the native tool interface swsslogleveL.

[0040] Considering that the business modules supported by the native tool interface swssloglevelL all rely on the swss container in the open source network operating system, a second service swss_loglevelmgrd can be added to the swss container. The swss_loglevelmgrd service is started when the swss container is started. After the swss_loglevelmgrd service is started, the command line of the native tool interface swssloglevelL can be directly called to synchronize the minimum log level corresponding to the business module supported by the native tool interface swssloglevelL to the temporary database from the SYSLOG_SEVERITY_TABLE table in the configuration database (because the data in the temporary database will be destroyed when the system is restarted), so as to ensure that the minimum log level corresponding to each business module is in effect. At the same time, the SYSLOG_SEVERITY_TABLE table in the configuration database is monitored, and when the minimum log level of the business module supported by the native tool interface swssloglevelL is monitored, the command line of the native tool interface swssloglevelL is directly called to reset the minimum log level of the corresponding business module.

[0041] At this point, based on the above steps, the minimum log level of the business modules supported by the native tool interface swssloglevel is adjusted.

[0042] In the above technology, although the minimum log level of all business modules can be adjusted, the user still needs to issue instructions through the log level modification tool to trigger, which cannot meet the needs of some current actual business scenarios. Specifically, in some current actual business scenarios, when the business module does not fail, it is hoped that the minimum log level of the business module is relatively high, so that the amount of log printing can be reduced and low-level logs can be avoided from being displayed on the screen. When a business module fails, it is hoped that the minimum log level of the business module can be relatively low, so that detailed logs during the operation of the business module can be printed, so as to facilitate fault location of the business module based on these detailed logs. For example, when the business module does not fail, the business module's notice, warning, error, critical, alert, and emerg level logs can be printed, so that the debug and info level logs can be avoided from being displayed on the screen; when the business module fails, the business module's debug, info, notice, warning, error, critical, alert, and emerg level logs can be printed, so that fault location can be performed based on the debug and info level logs (because the debug and info level logs contain more detailed operation information of the business module). Currently, in open source network operating systems, Figure 2 The technology shown cannot achieve adaptive adjustment of the minimum log level of the business module, resulting in failure to collect sufficient log information for fault location when a business module fails. The fault location process consumes a lot of time, manpower and material resources and is inefficient.

[0043] In view of this, based on Figure 2 The scheme shown in the present disclosure provides a log printing method, which can perform adaptive adjustment of the minimum log level, obtain more log information for fault location, and improve the efficiency of fault location. The log printing method can be applied to electronic devices. Electronic devices include but are not limited to tablet computers, desktop computers, tablet computers, laptop computers, etc. In the electronic device, the above-mentioned open source network operating system, log printing process, log printing function, configuration database, temporary database, etc. can be run.

[0044] Combined with reference Figure 3 , which is a flow chart of a log printing method provided in some embodiments of the present disclosure. Figure 3 In the log printing method, the log printing method includes the following steps: Step S301 , in response to the business module not generating a log of a target log level, printing a log of the business module not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information.

[0045] Step S302, in response to the business module generating a log of the target log level, modify the log level corresponding to the business module to the second log level in the log configuration information, and print the log of the business module that is not lower than the second log level, wherein the second log level is lower than the first log level, and the first log level is not higher than the target log level, and the log level corresponding to the business module in the log configuration information is used to represent the minimum log level that the business module needs to print.

[0046] Specifically, the target log level may be a higher log level, such as one or more log levels of error, critical, alert, and emerge. In the second log file, it can be checked whether the business module generates logs of the target log level.

[0047] Log configuration information refers to the configuration information related to log stored in the temporary database and the configuration database. The log configuration information includes the minimum log level corresponding to each business module, and the minimum log level is the first log level. The level of the first log level can be no higher than the target log level, but can be a relatively high log level. For example, the first log level can be a notice level, and the target log level can be a critical level. In addition, the first log levels corresponding to different business modules can be different. For example, the first log level corresponding to business module A can be a notice level, and the first log level corresponding to business module B can be a warning level. The present disclosure does not limit this.

[0048] When the business module does not generate logs of the target log level, it means that no serious problems have occurred at present. The log printing process can print the logs of the business module that are not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information. In this way, while preventing the problem of low-level logs from flooding the screen, higher-level logs can be printed, so as to timely discover possible business module problems.

[0049] When the business module generates logs at the target log level, it means that a serious problem has occurred. At this time, the minimum log level corresponding to the business module in the log configuration information can be modified to a relatively low log level. Figure 2 When the relevant services in the temporary database detect that the minimum log level corresponding to the business object has changed, the change can be synchronized to the log level configuration file, thereby dynamically adjusting the minimum log level that the business module needs to print. In this way, more low-level logs can be printed, so that problems can be located based on these low-level logs.

[0050] In summary, in the technical scheme of some embodiments of the present disclosure, by monitoring whether the business module generates a log of the target log level, it is determined whether to modify the log level corresponding to the business module in the log configuration information. In this way, the adaptive adjustment of the log level can be achieved, so that when there is no fault problem in the business module, a higher level log can be printed, the amount of log printing can be reduced, and the problem of low-level log screen swiping can be avoided, and when a fault problem occurs in the business module, the log of the lower level of the business module is printed, so that more log information for fault location can be obtained, and the efficiency of fault location can be improved.

[0051] In some embodiments, when the log level corresponding to the business module is changed to the second log level, the method of the present disclosure may further include: Starting from the target time point when the log level corresponding to the business module is modified to the second log level, if the preset conditions are met, the log level corresponding to the business module is modified back to the first log level in the log configuration information.

[0052] In this way, the problem of low-level logs flooding the screen can be avoided.

[0053] In some embodiments, when the preset conditions are met, modifying the log level corresponding to the business module in the log configuration information back to the first log level may include: Starting from the target time point, obtaining the logs of the business module within the most recent first preset time period at intervals of a first preset time period; If no log of the target log level appears in the logs within the most recent first preset period of time, the log level corresponding to the business module is modified back to the first log level.

[0054] For example, you can obtain the logs of the business module in the last 5 seconds from the second log file every 5 seconds. If there are no logs of the target log level in the logs in the last 5 seconds, it means that the fault problem of the business module has been solved. In this case, in order to avoid the problem of low-level logs flooding the screen, the log level corresponding to the business module can be modified back to the first log level.

[0055] In some embodiments, when the preset conditions are met, modifying the log level corresponding to the business module in the log configuration information back to the first log level may include: Starting from the target time point, if the duration of the log level corresponding to the business module being the second log level reaches a second preset duration, the log level corresponding to the business module is modified back to the first log level.

[0056] For example, when the log level corresponding to the business module is at the second log level for a duration of 5 minutes, the log level corresponding to the business module can be modified back to the first log level, so as to avoid printing low-level logs for a long time.

[0057] In some embodiments, when there are logs of the target log level in the logs of the business module within the most recent first preset time period, if the duration of the log level corresponding to the business module being the second log level reaches the second preset time period, the log level corresponding to the business module can be forcibly modified back to the first log level. In this way, on the one hand, the problem of low-level logs swiping the screen can be avoided, and on the other hand, too many repeated low-level logs can be prevented from being collected, which increases the processing time of log data and reduces the efficiency of problem location.

[0058] In some embodiments, when a preset condition is met, modifying the log level corresponding to the business module in the log configuration information back to the first log level may include: Get the logs of the business module after the target time point; When the log includes a first log at a target log level and a second log at a level lower than the first log level, analyzing the correlation between the first log and the second log; If the relevance is lower than the relevance threshold, the log level corresponding to the business module is modified back to the first log level.

[0059] Specifically, the correlation between the first log and the second log can be analyzed using a trained language model. If the correlation between the first log and the second log is lower than the correlation threshold, it means that the currently printed low-level log may not be closely related to the fault problem of the business module. In this case, the log level corresponding to the business module can be modified back to the first log level. In this way, on the one hand, the problem of low-level logs flooding the screen can be avoided, and on the other hand, the collection of too many low-level logs that are not related to the fault problem can be prevented.

[0060] In some embodiments, when a preset condition is met, modifying the log level corresponding to the business module in the log configuration information back to the first log level may include: Obtain logs of the business module after the target time point, and determine the number of logs in the log that are lower than the first log level; If the number of logs reaches the preset target number, the log level corresponding to the business module is modified back to the first log level.

[0061] Specifically, the target number can be set according to actual needs. For example, the target data can be 1,000. When the number of low-level logs reaches the target number, it means that based on these low-level logs, the fault location analysis can be well performed. In this case, the log level corresponding to the business module can be modified back to the first log level, thereby avoiding the problem of low-level logs flooding the screen and preventing too many low-level logs from being collected, resulting in a large amount of data analysis.

[0062] In some embodiments, when a preset condition is met, modifying the log level corresponding to the business module in the log configuration information back to the first log level may include: Starting from the target time point, if a log level modification instruction for a business module is received, the log level corresponding to the business module is modified back to the first log level.

[0063] Specifically, the log level modification instruction can be input by the user. In this way, the user can control the time point when the log level corresponding to the business module is modified back to the first log level, which is more adaptable. For example, when there are still logs of the target log level in the log of the above-mentioned business module, the duration of the log level corresponding to the business module being the second log level has not reached the second preset duration, the correlation between the first log and the second log is higher than the correlation threshold, and the number of logs in the log that does not reach the first log level, if the user has found a way to solve the fault problem, the log level corresponding to the business module can be manually modified back to the first log level by means of the log level modification instruction, so as to avoid the screen swiping of low-level logs.

[0064] It should be noted that the above is only an exemplary listing of triggering scenarios for modifying the log level corresponding to the business module back to the first log level. In specific applications, the triggering scenario for modifying the log level corresponding to the business module back to the first log level can be selected according to actual needs, and the present disclosure does not limit this.

[0065] Further, such as Figure 2 As shown, since the log configuration information is stored in at least the configuration database and the temporary database, and the log configuration information in the temporary database is the log configuration information synchronized from the configuration database, and can only take effect after the log configuration information is written into the temporary database, therefore, when the log level corresponding to the business module is modified to the second log level in the log configuration information, the log level corresponding to the business module can be modified to the second log level only in the log configuration information of the temporary database, and the log configuration information in the configuration database remains unchanged.

[0066] Among them, keeping the log configuration information in the configuration database unchanged can, on the one hand, reduce the amount of data modification; on the other hand, prevent the user's configuration data from being modified or lost. In short, the operation of modifying the log level corresponding to the business module to the second log level in this application can be understood as a temporary operation, that is, although the log level corresponding to the business module is modified to the second log level, under the condition of meeting the preset conditions (such as after the problem of the business module is solved), the log level corresponding to the business module is finally adjusted back to the original first log level configured by the user based on the user's configuration data. In this context, if the log level corresponding to the business module is modified to the second log level in both the configuration database and the temporary database, the original configuration data of the user may not be found when the log level recovery is required, thereby causing the problem of configuration data loss. In summary, the log level corresponding to the business module can be modified to the second log level only in the log configuration information of the temporary database.

[0067] Furthermore, since only the log configuration information in the temporary database is modified, the log level corresponding to the business module is modified back to the first log level in the log configuration information, the log level corresponding to the business module can be obtained in the log configuration information of the configuration database, and the log level obtained from the configuration database is synchronized to the temporary database, so that the log level corresponding to the business module is modified back to the first log level in the log configuration information of the temporary database. In this way, the accuracy of data recovery can be guaranteed.

[0068] Of course, in a specific application, the first log level corresponding to the business module may be backed up before modifying the log configuration information in the temporary database, so that the log level corresponding to the business module may be modified back to the first log level based on the backup data.

[0069] Further, such as Figure 1 In the case where there are multiple log levels, the multiple log levels can correspond to multiple log printing functions one by one. For any log level, the business module can call the log printing function corresponding to the log level, and print the log of the log level into the first log file. The log printing process can filter the logs in the first log file based on the log configuration information, and print the logs of the business module that are not lower than the first log level or the second log level into the second log file.

[0070] Based on the above principles, in some embodiments of the present application, it is possible to determine whether a business module generates a log of a target log level based on the following method: If the log printing function corresponding to the target log level is called by the business module, it is determined that the business module generates logs of the target log level; If the log printing function corresponding to the target log level is not called by the business module, it is determined that the business module does not generate a log at the target log level.

[0071] For example, assuming the target log level is error, the log printing function corresponding to error is log printing function error. If log printing function error is called by business module A, it can be determined that business module A generates logs at error level; if log printing function error is called by business module B, it can be determined that business module B generates logs at error level.

[0072] By judging whether the log printing function corresponding to the target log level is called by the business module, it is judged whether the business module generates logs of the target log level. In this way, it is possible to judge in real time whether there is a problem or failure in the business module, and when a problem or failure occurs in the business module, the log level corresponding to the business module in the log configuration information can be modified to the second log level in time, so that in the process of the problem or failure of the business module, the low-level log of the business module can be collected in real time, without the need to reproduce the scene of the problem or failure, thereby improving the efficiency of problem location.

[0073] For example, in some technologies, generally, after finding that the log of the target log level appears in the business module in the second log file by manually checking or automatically detecting, manually modifying the first log level corresponding to the business module to the second log level in the log configuration information, re-performing the problem fault reproduction of the business module, so as to collect the low-level logs of the business module when the problem fault occurs, and locating the problem fault according to the collected low-level logs. In these technologies, it is necessary to have at least two problem faults in the business module before the low-level logs can be collected. That is, when the problem fault occurs in the business module for the first time, by manually checking or automatically detecting, it is found that the problem fault occurs in the business module through the second log file. At this time, since the first log level corresponding to the business module has not been modified to the second log level in the log configuration information, it is impossible to collect the low-level log of the business module. After the first log level corresponding to the business module is modified to the second log level, the low-level log of the business module can be collected by reproducing the problem fault (making the business module have the problem fault for the second time). Among these technologies, on the one hand, the efficiency of reproducing the problem is low, and on the other hand, the problem may not be reproduced or is difficult to reproduce, which makes it more difficult to locate the problem. For example, when some problems and failures in the business module only occur occasionally, the technicians may not know how to reproduce these problems and failures, resulting in the inability to collect low-level logs for problem location.

[0074] In the scheme disclosed in the present invention, by monitoring whether the log printing function corresponding to the target log level is called by the business module, when the business module starts to print the log of the target log level, it can be immediately triggered to change the first log level corresponding to the business module to the second log level, so that when a problem occurs in the business module for the first time, the low-level log of the business module can be collected without the need to reproduce the problem, thereby greatly improving the efficiency of fault locating and avoiding the problem that the problem cannot be reproduced.

[0075] In some embodiments, the original log printing function corresponding to the target log level can be obtained, and the original log printing function is repackaged to obtain the log printing function corresponding to the target log level. The original log printing function after the repackage is newly added with the function of modifying the log level corresponding to the business module to the second log level. Specifically, the original log printing function is Figure 1 The log printing function in is mainly used to print the log of the target log level of the business module. In the process of secondary packaging, some functions required by the present disclosure can be added on the basis of the original log printing function, so that after the packaging is completed, in response to the call of the business module, the log printing function corresponding to the target log level can also be used to complete the following operations: In the log configuration information, change the log level corresponding to the business module to the second log level; The target time point when the log level corresponding to the business module is modified to the second log level is written into the time data item of the state database.

[0076] In simple terms, after the secondary encapsulation, when the log printing function corresponding to the target log level is called, the log printing function can first modify the log level corresponding to the business module to the second log level in the log configuration information before printing the log, and write the target time point when the log level corresponding to the business module is modified to the second log level into the database. After completing the modification of the log configuration information and recording the target time point, print the log of the target log level of the business module. In this way, when printing the log of the target log level of the business module, you can start printing the low-level log of the business module at the same time, without having to reproduce the fault problem.

[0077] In the above embodiment, by secondary packaging of the original log printing function corresponding to the target log level, and completing related operations such as log configuration information modification based on the secondary packaged log printing function, the development cost can be greatly reduced, and at the same time, the timeliness of low-level log printing can be guaranteed.

[0078] In some embodiments, a recovery process module_syslog_error_set_handler may be introduced in an open source network operating system. The operation of modifying the log level corresponding to the business module in the log configuration information back to the first log level may be completed by the recovery process. That is, the log level modification and log level recovery of the present disclosure may be completed by two different functional modules, wherein: The log printing function corresponding to the target log level completes log level modification, target time point recording, and log printing of the target log level; The recovery process module_syslog_error_set_handler completes the operation of restoring the log level, that is, starting from the target time point when the log level is changed to the second log level, if the preset conditions are met, the log level corresponding to the business module in the log configuration information is changed back to the first log level.

[0079] Specifically, the recovery process can determine the target time point based on the following method: When a value setting operation for a time data item is detected in the state database, a time point at which the time data item is written is obtained as a target time point.

[0080] Specifically, in the state database, each business module may have its own corresponding time data item. For example, business module A corresponds to time data item a, and business module B corresponds to time data item b. For any time data item M, when the recovery process detects that a value setting operation has occurred for the time data item M, it can be determined that a problem has occurred in the business module N corresponding to the time data item M, and the time point at which the time data item M is written can be used as the target time point when the log level of the corresponding business module N is modified to the second log level.

[0081] After obtaining the target time point when the log level of the business module N is modified to the second log level, the recovery process can start timing and execute the above-mentioned related logic of modifying the log level corresponding to the business module back to the first log level to perform log level recovery.

[0082] In some embodiments, after the recovery process modifies the log level corresponding to the business module back to the first log level in the log configuration information, it is also used to delete the target time point in the time data item. Deleting the target time point in the time data item means setting the value in the time data item to a default value, such as 0, -1, etc. In this way, it is possible to avoid the residual data in the data item affecting the next task execution.

[0083] In some embodiments, when there are multiple business modules, the second log level corresponding to at least some business modules may be different. The second log level corresponding to each business module may be pre-set according to the actual situation of each business module. For example, for business module A, assuming that the log of the debug level of business module A needs to be collected, the problem fault of business module A can be located, so the second log level corresponding to business module A can be the debug level. When a problem fault occurs in business module A, the log level corresponding to business module A can be modified to the debug level, so as to print the log of the debug, info, notice, warning, error, critical, alert, and emerg levels of business module A. But for business module B, assuming that only the log of the info level of business module A needs to be collected, the problem fault of business module B can be located, so the second log level corresponding to business module B can be the info level. When a problem fault occurs in business module B, the log level corresponding to business module B can be modified to the info level, so as to print the log of the info, notice, warning, error, critical, alert, and emerg levels of business module B.

[0084] Based on the above description, in some embodiments, before modifying the log level corresponding to the business module to the second log level in the log configuration information, the method of the present disclosure may further include: Determine the target business module that generates logs of the target log level; According to the preset correspondence between the business module and the second log level, the second log level corresponding to the target business module is determined.

[0085] Specifically, the above operation can be completed by the log printing function corresponding to the target log level obtained after secondary encapsulation. When the business module calls the log printing function corresponding to the target log level to print the log, it can carry information such as the module identification. Based on the module identification and other information, the log printing function corresponding to the target log level can determine the target business module that generates the target log level log, and can determine the second log level corresponding to the target business module according to the correspondence between the preset business module and the second log level, and then modify the log level corresponding to the target business module in the log configuration information according to the determined second log level.

[0086] In the above embodiment, corresponding second log levels are set for different business modules respectively, which has better adaptability.

[0087] In some embodiments, before modifying the log level corresponding to the business module to the second log level in the log configuration information, the method of the present disclosure may further include: Display the human-computer interaction interface, and display the name of the target business module that generates the target log level log in the human-computer interaction interface; In response to a log level being input in the human-computer interaction interface, the log level in the human-computer interaction interface is used as a second log level.

[0088] In simple terms, after a business module generates a log of the target log level, the target business module with the problem can be displayed through the human-computer interaction interface, and the user can select the second log level corresponding to the target business module according to actual needs. In this way, the solution is more flexible.

[0089] In summary, in the technical scheme disclosed herein, by monitoring whether the business module generates a log of the target log level, it is determined whether to modify the log level corresponding to the business module in the log configuration information. In this way, the adaptive adjustment of the log level can be achieved, so that when there is no fault problem in the business module, a higher-level log can be printed, the log printing amount can be reduced, the problem of low-level log screen brushing can be avoided, and when there is a fault problem in the business module, the log of the lower level of the business module is printed, so that more log information for fault location can be obtained, and the efficiency of fault location can be improved.

[0090] For easier understanding, please refer to Figure 4 , which is an interactive schematic diagram of a log printing method provided in some embodiments of the present disclosure. Figure 4 In the figure, the steps in the left dashed box may be completed by the log printing function corresponding to the target log level, and the steps in the right dashed box may be completed by the recovery process.

[0091] The steps executed by the log printing function corresponding to the target log level include the following steps 31)~34): 31) In response to being called by the business module, the log printing function corresponding to the target log level determines that the business module generates a log of the target log level; 32) In the log configuration information of the temporary database, change the log level corresponding to the business module to the second log level; 33) Writing the target time point when the log level corresponding to the business module is changed to the second log level into the time data item of the state database; 34) Print the log of the target log level of the business module.

[0092] For the specific implementation principles of steps 31) to 34), please refer to the above related descriptions and will not be repeated here.

[0093] The steps performed by the recovery process include the following steps (41) to 48): 41) When a value setting operation for a time data item is detected in the state database, the time point at which the time data item is written is obtained as the target time point; 42) Start timing from the target time point; 43) Starting from the target time point, obtaining the logs of the business module within the most recent first preset time period every first preset time period; 44) Check whether there is a log of the target log level in the logs of the business module within the most recent first preset time period. If so, execute step 45); if not, execute step 47); 45) Determine whether the duration of the second log level corresponding to the business module reaches the second preset duration. If yes, execute step 47); if no, execute step 46); 46) Continue printing low-level logs; 47) The log level obtained from the configuration database is synchronized to the temporary database, so that the log level corresponding to the business module is modified back to the first log level in the log configuration information of the temporary database.

[0094] based on Figure 2 According to the method shown, the service in the open source network operating system monitors the changes of the log configuration information of the temporary database, and can synchronize these changes to the log level configuration file, so that the printed log level can be controlled in real time.

[0095] Combined with reference Figure 5 , a log printing device is provided for some embodiments of the present disclosure. Figure 5 In the example, the log printing device includes: A first log printing module 501 is used for printing logs of the business module not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information in response to the business module not generating logs of the target log level; The second log printing module 502 is used to respond to the business module generating a log of a target log level, modify the log level corresponding to the business module to a second log level in the log configuration information, and print the log of the business module that is not lower than the second log level, wherein the second log level is lower than the first log level, and the first log level is not higher than the target log level, and the log level corresponding to the business module in the log configuration information is used to control the minimum log level to be printed by the business module.

[0096] In some embodiments, when the log level corresponding to the business module is modified to the second log level, the second log printing module 502 is further used to: Starting from the target time point when the log level corresponding to the business module is modified to the second log level, if the preset conditions are met, the log level corresponding to the business module is modified back to the first log level in the log configuration information.

[0097] In some embodiments, the second log printing module 502 is specifically used to: Starting from the target time point, obtaining the logs of the business module within the most recent first preset time period at intervals of a first preset time period; If no log of the target log level appears in the logs within the most recent first preset period of time, the log level corresponding to the business module is modified back to the first log level.

[0098] In some embodiments, the second log printing module 502 is specifically used for: Starting from the target time point, if the duration of the log level corresponding to the business module being the second log level reaches a second preset duration, the log level corresponding to the business module is modified back to the first log level.

[0099] In some embodiments, the second log printing module 502 is specifically used to: Get the logs of the business module after the target time point; When the log includes a first log at a target log level and a second log at a level lower than the first log level, analyzing the correlation between the first log and the second log; If the relevance is lower than the relevance threshold, the log level corresponding to the business module is modified back to the first log level.

[0100] In some embodiments, the second log printing module 502 is specifically used to: Obtain logs of the business module after the target time point, and determine the number of logs in the log that are lower than the first log level; If the number of logs reaches the preset target number, the log level corresponding to the business module is modified back to the first log level.

[0101] In some embodiments, the second log printing module 502 is specifically used to: Starting from the target time point, if a log level modification instruction for a business module is received, the log level corresponding to the business module is modified back to the first log level.

[0102] In some embodiments, the log configuration information is stored in at least a configuration database and a temporary database, and the log configuration information in the temporary database is the log configuration information synchronized from the configuration database; the second log printing module 502 is specifically used for: In the log configuration information of the temporary database, the log level corresponding to the business module is modified to the second log level, and the log configuration information in the configuration database is kept unchanged.

[0103] In some embodiments, the second log printing module 502 is specifically used to: Obtain the log level corresponding to the business module from the log configuration information of the configuration database; The log level obtained from the configuration database is synchronized to the temporary database, so that the log level corresponding to the business module is modified back to the first log level in the log configuration information of the temporary database.

[0104] In some embodiments, when there are multiple log levels, the multiple log levels correspond one-to-one to the multiple log printing functions; The first log printing module 501 and the second log printing module 502 are specifically used to determine whether the business module generates logs of the target log level based on the following method: If the log printing function corresponding to the target log level is called by the business module, it is determined that the business module generates logs of the target log level; If the log printing function corresponding to the target log level is not called by the business module, it is determined that the business module does not generate logs of the target log level; Among them, for any log level, the business module calls the log printing function corresponding to the log level, and prints the log of the log level into the first log file. The log printing process filters the logs in the first log file based on the log configuration information, and prints the logs of the business module that are not lower than the first log level or the second log level into the second log file.

[0105] In some embodiments, the second log printing module 502 is specifically used to complete the following operations through the log printing function corresponding to the target log level: In the log configuration information, change the log level corresponding to the business module to the second log level; The target time point when the log level corresponding to the business module is modified to the second log level is written into the time data item of the state database.

[0106] In some embodiments, the second log printing module 502 is specifically used to obtain a log printing function corresponding to the target log level based on the following method: Get the original log printing function corresponding to the target log level. The original log printing function is used to print the log of the target log level of the business module. The original log printing function is encapsulated twice to obtain a log printing function corresponding to the target log level. The original log printing function after the second encapsulation is newly added with a function of modifying the log level corresponding to the business module to the second log level.

[0107] In some embodiments, the second log printing module 502 modifies the log level corresponding to the business module in the log configuration information back to the first log level through the recovery process; The recovery process determines the target time point based on the following method: When a value setting operation for a time data item is detected in the state database, a time point at which the time data item is written is obtained as a target time point.

[0108] In some embodiments, after the recovery process modifies the log level corresponding to the business module in the log configuration information back to the first log level, the second log printing module 502 is further used to delete the target time point in the time data item through the recovery process.

[0109] In some embodiments, when there are multiple business modules, at least some of the business modules correspond to different second log levels; Before the log level corresponding to the business module is modified to the second log level in the log configuration information, the second log printing module 502 is further used to: Determine the target business module that generates logs of the target log level; According to the preset correspondence between the business module and the second log level, the second log level corresponding to the target business module is determined.

[0110] In some embodiments, before the log level corresponding to the business module is modified to the second log level in the log configuration information, the second log printing module 502 is further used to: Display the human-computer interaction interface, and display the name of the target business module that generates the target log level log in the human-computer interaction interface; In response to a log level being input in the human-computer interaction interface, the log level in the human-computer interaction interface is used as a second log level.

[0111] The performance monitoring device of the input and output card in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0112] The present disclosure also provides an electronic device having the above Figure 5 The log printing device shown.

[0113] Combined with reference Figure 6 , is a schematic diagram of the structure of an electronic device provided by some embodiments of the present disclosure. Figure 6As shown, the electronic device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.

[0114] The processor 10 may be a first PCIe device, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0115] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0116] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0117] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0118] The electronic device further comprises a communication interface 30 for the electronic device to communicate with other devices or a communication network.

[0119] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0120] A part of the present disclosure may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present disclosure through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0121] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A log printing method, characterized in that: The method comprises: In response to the business module not generating a log of a target log level, printing a log of the business module that is not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information; In response to the business module generating a log of the target log level, the log level corresponding to the business module is modified to a second log level in the log configuration information, and a log of the business module that is not lower than the second log level is printed, wherein the second log level is lower than the first log level, and the first log level is not higher than the target log level, and the log level corresponding to the business module in the log configuration information is used to represent the minimum log level that the business module needs to print.

2. The method according to claim 1, characterized in that In the case where the log level corresponding to the business module is changed to the second log level, the method further includes: Starting from the target time point when the log level corresponding to the business module is modified to the second log level, if a preset condition is met, the log level corresponding to the business module is modified back to the first log level in the log configuration information.

3. The method according to claim 2, characterized in that The modifying the log level corresponding to the business module in the log configuration information back to the first log level when the preset condition is met includes: Starting from the target time point, obtaining the log of the business module within the most recent first preset time period at intervals of a first preset time period; If no log of the target log level appears in the logs within the first preset time period recently, the log level corresponding to the business module is modified back to the first log level.

4. The method according to claim 2, characterized in that: The modifying the log level corresponding to the business module in the log configuration information back to the first log level when the preset condition is met includes: Starting from the target time point, if the duration for which the log level corresponding to the business module is the second log level reaches a second preset duration, the log level corresponding to the business module is modified back to the first log level.

5. The method according to claim 2, characterized in that: The modifying the log level corresponding to the business module in the log configuration information back to the first log level when the preset condition is met includes: Obtaining logs of the business module after the target time point; When the log includes a first log at the target log level and a second log at a level lower than the first log level, analyzing the correlation between the first log and the second log; If the correlation degree is lower than the correlation degree threshold, the log level corresponding to the business module is modified back to the first log level.

6. The method according to claim 2, characterized in that The modifying the log level corresponding to the business module in the log configuration information back to the first log level when the preset condition is met includes: Obtain logs of the business module after the target time point, and determine the number of logs in the logs that are lower than the first log level; If the number of logs reaches a preset target number, the log level corresponding to the business module is modified back to the first log level.

7. The method according to claim 2, characterized in that The modifying the log level corresponding to the business module in the log configuration information back to the first log level when the preset condition is met includes: Starting from the target time point, if a log level modification instruction for the business module is received, the log level corresponding to the business module is modified back to the first log level.

8. The method according to any one of claims 2 to 7, characterized in that: The log configuration information is stored at least in a configuration database and a temporary database, and the log configuration information in the temporary database is the log configuration information synchronized from the configuration database; The step of modifying the log level corresponding to the business module to the second log level in the log configuration information includes: In the log configuration information of the temporary database, the log level corresponding to the business module is modified to the second log level, and the log configuration information in the configuration database is kept unchanged.

9. The method according to claim 8, characterized in that The modifying the log level corresponding to the business module in the log configuration information back to the first log level includes: Obtaining the log level corresponding to the business module from the log configuration information of the configuration database; The log level obtained from the configuration database is synchronized to the temporary database, so that the log level corresponding to the business module is modified back to the first log level in the log configuration information of the temporary database.

10. The method according to claim 2, characterized in that In the case where there are multiple log levels, the multiple log levels correspond one-to-one to the multiple log printing functions; Determine whether the business module generates logs of the target log level based on the following method: If the log printing function corresponding to the target log level is called by the business module, it is determined that the business module generates a log of the target log level; If the log printing function corresponding to the target log level is not called by the business module, it is determined that the business module does not generate a log of the target log level; Among them, for any of the log levels, the business module calls the log printing function corresponding to the log level, and prints the log of the log level into the first log file. The log printing process filters the logs in the first log file based on the log configuration information, and prints the logs of the business module that are not lower than the first log level or the second log level into the second log file.

11. The method according to claim 10, characterized in that In response to the call of the business module, the log printing function corresponding to the target log level is also used to complete the following operations: In the log configuration information, the log level corresponding to the business module is modified to the second log level; The target time point when the log level corresponding to the business module is modified to the second log level is written into the time data item of the state database.

12. The method according to claim 11, characterized in that The log printing function corresponding to the target log level is obtained based on the following method: Obtaining an original log printing function corresponding to the target log level, wherein the original log printing function is used to print the log of the target log level of the business module; The original log printing function is encapsulated twice to obtain a log printing function corresponding to the target log level, and the original log printing function after the second encapsulation is newly added with a function of modifying the log level corresponding to the business module to the second log level.

13. The method according to claim 11, characterized in that The operation of modifying the log level corresponding to the business module in the log configuration information back to the first log level is completed by the recovery process; The recovery process determines the target time point based on the following method: When it is monitored that a value setting operation for the time data item occurs in the status database, a time point at which the time data item is written is acquired as the target time point.

14. The method according to claim 13, characterized in that After the recovery process modifies the log level corresponding to the business module in the log configuration information back to the first log level, it is also used to delete the target time point in the time data item.

15. The method according to claim 1, characterized in that In the case where there are multiple business modules, at least some of the business modules correspond to different second log levels; Before modifying the log level corresponding to the business module to the second log level in the log configuration information, the method further includes: Determine the target business module that generates logs of the target log level; According to the preset correspondence between the business module and the second log level, the second log level corresponding to the target business module is determined.

16. The method according to claim 1, characterized in that Before modifying the log level corresponding to the business module to the second log level in the log configuration information, the method further includes: Displaying a human-computer interaction interface, and displaying the name of a target business module that generates a log of a target log level in the human-computer interaction interface; In response to a log level being input in the human-computer interaction interface, the log level in the human-computer interaction interface is used as the second log level.

17. A log printing device, characterized in that: The device comprises: A first log printing module, configured to, in response to the business module not generating a log of a target log level, print a log of the business module not lower than the first log level according to the first log level currently corresponding to the business module in the log configuration information; A second log printing module is used to respond to the business module generating a log of the target log level, modify the log level corresponding to the business module in the log configuration information to a second log level, and print the log of the business module that is not lower than the second log level, wherein the second log level is lower than the first log level, and the first log level is not higher than the target log level, and the log level corresponding to the business module in the log configuration information is used to control the minimum log level to be printed by the business module.

18. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the log printing method according to any one of claims 1 to 16 by executing the computer instructions.

19. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the log printing method according to any one of claims 1 to 16.

20. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the log printing method according to any one of claims 1 to 16.

Citation Information

Patent Citations

  • Method, system and device for log printing

    CN112486435A

  • Log level adjusting method and device

    CN115017022A

  • Log level adjustment method and device, equipment and storage medium

    CN117472680A