Log recording method and device, storage medium and electronic device

By obtaining the independent file information and interface information of the target program in the server system and switching its log interface to the independent log interface, the problem of low log analysis efficiency under centralized logging mode is solved, and independent recording and efficient analysis of the target program log is achieved.

CN119377058BActive Publication Date: 2025-04-25INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411967237.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-25
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

In existing server systems, centralized logging methods lead to inefficient log analysis, and technicians need to filter logs of specific programs from public files, which is time-consuming and labor-intensive and error-prone.

Method used

By obtaining the independent file information and independent interface information of the target program, switch its log interface from the system log interface to the independent log interface. The independent log interface records the log to the target independent file according to the specified recording policy.

Benefits of technology

The log independent recording of each target program is realized, and the independent files of the target program are directly accessed to obtain their logs, which simplifies the log management process and improves the efficiency of log analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377058B_ABST
    Figure CN119377058B_ABST
Patent Text Reader

Abstract

The present application discloses a log recording method and device, a storage medium and an electronic device, which are applied to a server system, and include: obtaining independent file information and independent interface information corresponding to a target program running on the server system, the current target program's running log is recorded by a system log interface of the server system to a common file that allows recording of running logs of multiple programs, the independent file information is used to identify the target independent file, the target independent file is a file that only allows recording of the running log of the target program, and the independent interface information is used to indicate that the log interface allows a recording strategy to be executed on the running log of the target program; according to the independent file information and the independent interface information, the log interface corresponding to the target program is switched from the system log interface to the independent log interface; and the independent log interface is controlled to record the running log of the target program, so as to solve the problems of low log analysis efficiency in the related art, and thus achieve the technical effect of improving the log analysis efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the computer field, and more specifically, to a log recording method and device, a storage medium, and an electronic device. Background Art

[0002] In server systems, effective logging and analysis help server systems run normally and diagnose faults quickly.

[0003] In the related art, most server systems use a centralized logging method, that is, all program operation logs are uniformly recorded in one or several public files. Although this method simplifies the log data collection process, it brings a series of problems. Since the log data of all programs are mixed together, when it is necessary to analyze the logs of a specific program, technicians need to filter out relevant information from all the log data recorded in the public folder. This process is not only time-consuming and labor-intensive, but also prone to errors, affecting the efficiency of log analysis.

[0004] In view of the problems of low efficiency of log analysis in related technologies, no effective solutions have been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide a log recording method and device, a storage medium, and an electronic device to at least solve the problem of low log analysis efficiency in the related art.

[0006] According to an embodiment of the present application, a log recording method is provided, which is applied to a server system, and the method includes:

[0007] Obtaining independent file information and independent interface information corresponding to a target program running on a server system, wherein the running log of the current target program is recorded to a public file by a system log interface of the server system, the public file allows the running logs of multiple programs to be recorded, the independent file information is used to identify a target independent file, the target independent file is a file that only allows the running log of the target program to be recorded, and the independent interface information is used to indicate the recording policy that the log interface allows to be executed on the running log of the target program;

[0008] Switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, wherein the independent log interface is used to record the operation log of the target program to the target independent file according to the recording strategy indicated by the independent interface information;

[0009] Control the independent log interface to record the running log of the target program.

[0010] Optionally, switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information includes:

[0011] Switching the file information currently used by the target program from the system file information to the independent file information, wherein the system file information is used to indicate a common file that allows recording the operation logs of multiple programs;

[0012] Switching the interface information currently used by the target program from the system interface information to the independent interface information, wherein the system interface information is used to indicate the recording policy that the system log interface allows to be executed on the running log of the target program;

[0013] The server system is configured to record the running log of the target program to the file indicated by the currently used file information according to the recording strategy indicated by the currently used interface information.

[0014] Optionally, before switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, the method further includes:

[0015] Detect the current system startup time of the server system;

[0016] Check whether the system startup time is greater than the target time threshold;

[0017] When it is detected that the system startup time is less than or equal to the target time threshold, the control system log interface records the running log of the target program to a public file;

[0018] When it is detected that the system startup duration is greater than the target duration threshold, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and the independent interface information.

[0019] Optionally, the control system log interface records the target program's running log to a public file, including:

[0020] Obtaining system file information and system interface information, wherein the system file information is used to indicate a common file that allows recording of operation logs of multiple programs, and the system interface information is used to indicate a recording policy that a system log interface allows to be executed on the operation log of a target program;

[0021] The file information currently used by the target program is set as the system file information, and the interface information currently used by the target program is set as the system interface information, wherein the server system is configured to record the operation log of the target program to the file indicated by the currently used file information according to the recording strategy indicated by the currently used interface information.

[0022] Optionally, obtain system file information and system interface information, including:

[0023] Get the public file handle corresponding to the public file, and the system log open function, system log write function, system log close function and system log reset function corresponding to the system log interface, wherein the public file handle is used to identify the public file in the server system, the system log open function is used to indicate the system log interface to allow the open policy to be executed on the running log, the system log write function is used to indicate the system log interface to allow the write policy to be executed on the running log, the system log close function is used to indicate the system log interface to allow the close policy to be executed on the running log, and the system log reset function is used to indicate the system log interface to allow the reset policy to be executed on the running log;

[0024] Determine the public file handle as system file information;

[0025] The system log opening function, the system log writing function, the above-mentioned system log closing function and the system log resetting function are determined as the system interface information.

[0026] Optionally, the server system allocates a switching thread for the target program within a time when the system startup time is less than or equal to the target time threshold, and switches the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, including:

[0027] Get the preset switching cycle;

[0028] The switching thread is called to execute the interface switching operation according to the preset switching cycle until the interface switching operation is successfully executed, wherein the switching thread is used to detect whether the independent file information and the independent interface information are currently obtained each time the interface switching operation is executed; if it is detected that the independent file information and the independent interface information are not successfully obtained, it is determined that the interface switching operation has failed to be executed; if it is detected that the independent file information and the independent interface information are successfully obtained, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and the independent interface information, and it is determined that the interface switching operation is successfully executed.

[0029] Optionally, independent file information and independent interface information corresponding to the target program running on the server system are obtained, including:

[0030] Obtaining an independent file handle, an independent log open function, an independent log write function, an independent log close function and an independent log reset function corresponding to the target program from a target configuration file, wherein the target configuration file records the programs, file handles, log open function, log write function, log close function and log reset function having corresponding relationships in the server system, the independent file handle is used to identify a file in the server system that is only allowed to record the operation log of the target program, the independent log open function is used to indicate that the log interface allows an open policy to be executed on the operation log of the target program, the independent log write function is used to indicate that the log interface allows a write policy to be executed on the operation log of the target program, the independent log close function is used to indicate that the log interface allows a close policy to be executed on the operation log of the target program, and the independent log reset function is used to indicate that the log interface allows a reset policy to be executed on the operation log of the target program;

[0031] Determine the independent file handle as independent file information;

[0032] An independent log opening function, an independent log writing function, an independent log closing function and an independent log resetting function are determined as independent interface information.

[0033] Optionally, the server system allocates a monitoring thread to the target program. After obtaining an independent file handle, an independent log opening function, an independent log writing function, an independent log closing function and an independent log resetting function corresponding to the target program from the target configuration file, the method further includes:

[0034] Call the monitoring thread to detect whether the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program recorded in the target configuration file are changed;

[0035] When it is detected that the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function corresponding to the target program have changed, the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function after the most recent change are used to update the independent file information and independent interface information currently used by the independent log interface.

[0036] Optionally, control the independent log interface to record the running log of the target program, including:

[0037] Get the file directory to which the target independent file belongs, and get the target file directory;

[0038] Create a target test file in the target file directory;

[0039] Writing test data into a target test file to obtain a test result, wherein the test result is used to indicate whether the test data is successfully written into the target test file;

[0040] Control the independent log interface to record the running log of the target program according to the test results.

[0041] Optionally, control the independent log interface to record the running log of the target program according to the test results, including:

[0042] In the case where the test result indicates that the test data fails to be written into the target test file, the independent log interface is prohibited from recording the running log of the target program, and the target test file is deleted;

[0043] When the test result indicates that the test data is successfully written into the target test file, the independent log interface is controlled to start recording the running log of the target program.

[0044] Optionally, the server system pre-builds a log buffer queue, which is used to temporarily store the running logs of multiple programs in the server system and control the independent log interface to record the running logs of the target program, including:

[0045] Control the independent log interface to extract the target running log of the target program from the multiple running logs currently stored in the log buffer queue;

[0046] The independent log interface is controlled to record the target operation log to the target independent file according to the recording strategy indicated by the independent interface information.

[0047] According to another embodiment of the embodiment of the present application, a log recording device is also provided, which is applied to a server system, and the device includes:

[0048] An acquisition module is used to acquire independent file information and independent interface information corresponding to a target program running on a server system, wherein the operation log of the current target program is recorded to a public file by a system log interface of the server system, and the public file allows the operation logs of multiple programs to be recorded. The independent file information is used to identify a target independent file, and the target independent file is a file that only allows the operation log of the target program to be recorded. The independent interface information is used to indicate the recording policy that the log interface allows to be executed on the operation log of the target program;

[0049] A first switching module is used to switch the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, wherein the independent log interface is used to record the operation log of the target program to the target independent file according to the recording strategy indicated by the independent interface information;

[0050] The first control module is used to control the independent log interface to record the running log of the target program.

[0051] According to another embodiment of the present application, a computer program product is provided, including a computer program, and the computer program is executed by a processor to perform the steps in any of the above method embodiments.

[0052] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0053] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0054] In an embodiment of the present application, a log recording method is proposed, in which the server system first obtains independent file information and independent interface information corresponding to a target program running on the server system, wherein the running log of the current target program is recorded to a common file by the system log interface of the server system, the common file allows the running logs of multiple programs to be recorded, the independent file information can identify the target independent file, the target independent file is a file that only allows the running log of the target program to be recorded, and the independent interface information can indicate the recording policy that the log interface allows to be executed on the running log of the target program; then, according to the independent file information and the independent interface information, the log interface corresponding to the target program is switched from the system log interface to the independent log interface, wherein the independent log interface can record the running log of the target program to the target independent file according to the recording policy indicated by the independent interface information; finally, the independent log interface is controlled to record the running log of the target program, that is, during the running of the target program, the server system switches the log of the target program from the current default system log interface to the independent log interface corresponding to the target program by obtaining the independent file information and the independent interface information of the target program, and then, the independent log interface records the log of the target program to the target independent file identified by the corresponding independent file information according to the recording policy defined by the independent interface information of the target program. Compared with the related art, the operation logs of all target programs are recorded in a common file. When the operation logs of a specific target program need to be analyzed, a series of operations such as screening are required to obtain the logs of the specific target program. After adopting the above log recording method, the logs of each target program are recorded separately in its corresponding independent file. The independent file of the target program can be directly accessed to obtain its log, without the need to screen and search in the common file containing multiple target programs, which simplifies the log management process and improves the efficiency of log analysis. The above technical solution solves the problems of low log analysis efficiency in the related art and achieves the technical effect of improving log analysis efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a hardware structure block diagram of a computer device of a log recording method according to an embodiment of the present application;

[0056] Figure 2 is a flow chart of a log recording method according to an embodiment of the present application;

[0057] Figure 3 It is a flowchart of a multipath service log interface initialization method according to an embodiment of the present application;

[0058] Figure 4 It is a flow chart of a multi-path service log interface verification method according to an embodiment of the present application;

[0059] Figure 5 is a flow chart of a multi-path service log monitoring method according to an embodiment of the present application;

[0060] Figure 6 is a structural block diagram of a log recording device according to an embodiment of the present application;

[0061] Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0062] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0063] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0064] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a computer device for a log recording method according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0065] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the log recording method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server 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.

[0066] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0067] The present application proposes a log recording method. Before describing the optional embodiments of the present application, in order to better understand the inventive concept of the present application and the creativity of the solution, the related technology is first described:

[0068] Multipath service is a network storage technology that aims to enhance the reliability and performance of data storage by defining multiple physical paths from the server to the storage array. Even if a path fails, the server can still access the data through other paths and can access it concurrently through multiple paths. The implementation of multipath service requires a special software program, namely the multipath service program, which runs on the server's operating system. The multipath service program performs key tasks, including path monitoring, failover, load balancing, and the creation and management of multipath devices to ensure the stability and efficiency of data transmission.

[0069] During the operation of the multipath service program, a large number of operation logs will be generated. These logs record the operation status of the service, path switching events, fault detection information, etc. For system maintenance personnel, these logs are important bases for diagnosing problems, monitoring service health and optimizing performance. However, as a daemon in the Linux system, the multipath service program usually relies on the system log daemon Syslogd for logging. Syslogd is a standard logging service on the Linux platform, responsible for collecting log information from various parts of the system and daemons, and then recording this information to the corresponding log file according to the configuration rules. Usually, the log information of multiple daemon services in the Linux server will be recorded in the public file specified by the configuration file. Because the log information is mixed with other daemon services, when the log of the multipath service program needs to be analyzed in detail, it is necessary to filter out the relevant information from a large number of comprehensive logs, which limits the efficiency of log analysis.

[0070] In this embodiment, a log recording method is provided. Figure 2 is a flow chart of a log recording method according to an embodiment of the present application, which is applied to a server system, such as Figure 2 As shown, the process includes the following steps:

[0071] Step S12, obtaining independent file information and independent interface information corresponding to the target program running on the server system, wherein the operation log of the current target program is recorded to a public file by the system log interface of the server system, the public file allows the operation logs of multiple programs to be recorded, the independent file information is used to identify the target independent file, the target independent file is a file that only allows the operation log of the target program to be recorded, and the independent interface information is used to indicate the recording policy that the log interface allows to be executed on the operation log of the target program;

[0072] Step S14, switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, wherein the independent log interface is used to record the operation log of the target program to the target independent file according to the recording strategy indicated by the independent interface information;

[0073] Step S16, controlling the independent log interface to record the running log of the target program.

[0074] Optionally, in this embodiment, the target program may be, but is not limited to, any application or service in the server system that requires independent log recording, including a multipath service program, any module in the multipath service program, and a business application program, etc. In the following embodiment, any module in the multipath service program (hereinafter referred to as the multipath module) is taken as an example of the target program to describe the log recording method, without limiting the type of the target program.

[0075] Optionally, in this embodiment, the server system first identifies and obtains independent file information and independent interface information of the running multipath module, wherein the independent file information may be a specific file path, file handle or identifier, and the file under this file path is the target independent file, which is specifically used to record the log of the multipath module to distinguish it from the logs of other multipath modules or programs. Different multipath modules correspond to different target independent files, and one multipath module may correspond to one target independent file; the independent interface information may be a log recording strategy matching the target independent file, including an independent log opening function, an independent log writing function, an independent log closing function and an independent log reset function, etc. These functions may guide the log interface on how to collect, process and record the operation log of the multipath module. Different multipath modules correspond to different independent interface information, and one multipath module may correspond to one independent interface information.

[0076] Optionally, in this embodiment, before obtaining the independent file information and independent interface information corresponding to the multipath module, the operation log of the multipath module is recorded into a common file by default through the system log interface of the server system. This common file may contain the operation logs of multiple multipath modules or programs. The system log interface can be but is not limited to an interface provided by the operating system or server system that allows the system and program to send the generated logs to a local or remote log server, including Syslog, Windows Event Log (event log system of the Windows operating system) and Log4j (Java logging tool), etc.

[0077] Optionally, in this embodiment, after obtaining the independent file information and independent interface information corresponding to the multipath module, the log interface corresponding to the multipath module is switched from the system log interface to the independent log interface, wherein the independent log interface may be, but is not limited to, a component or service in a server system or application, and the operation log of the multipath module may be recorded into its target independent file according to the recording strategy defined by the independent interface information. Subsequently, the operation log of the multipath module is recorded into its target independent file by controlling the independent log interface, and when the log of a specific multipath module needs to be analyzed, the directory independent file of the multipath module may be directly accessed to obtain its log, thereby achieving the technical effect of improving the efficiency of log analysis, and further solving the technical problem of low efficiency of log analysis.

[0078] As an optional solution, switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information includes:

[0079] S21, switching the file information currently used by the target program from the system file information to the independent file information, wherein the system file information is used to indicate a common file that allows recording operation logs of multiple programs;

[0080] S22, switching the interface information currently used by the target program from the system interface information to the independent interface information, wherein the system interface information is used to indicate the recording policy that the system log interface allows to be executed on the running log of the target program;

[0081] S23, wherein the server system is configured to record the running log of the target program to the file indicated by the currently used file information according to the recording strategy indicated by the currently used interface information.

[0082] Optionally, in this embodiment, the method of switching the log interface corresponding to the multipath module from the system log interface to the independent log interface may include but is not limited to: first, switching the file information currently used by the multipath module from the system file information to the independent file information; then, switching the interface information currently used by the multipath module from the system interface information to the independent interface information.

[0083] Optionally, in this embodiment, the file information used by the multipath module by default is the system file information. After the file information of the multipath module is switched to independent file information, the storage location of the multipath module's operation log is also switched from the public file to the target independent file indicated by the independent file information.

[0084] Optionally, in this embodiment, the interface information used by the multipath module by default is the system interface information. After the interface information of the multipath module is switched to independent interface information, the server system will record the operation log of the multipath module according to the policy and parameters defined by the independent interface information.

[0085] As an optional solution, before switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, the method further includes:

[0086] S31, detecting the current system startup time of the server system;

[0087] S32, detecting whether the system startup time is greater than the target time threshold;

[0088] S33, when it is detected that the system startup time is less than or equal to the target time threshold, controlling the system log interface to record the running log of the target program to a public file;

[0089] S34, when it is detected that the system startup duration is greater than the target duration threshold, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and the independent interface information.

[0090] Optionally, in this embodiment, before the log interface of the multipath module is switched from the system log interface to the independent log interface, when the target independent file of the multipath module has not been mounted successfully (not ready to execute logging), the operation log of the multipath module is recorded in the public file indicated by the system log interface.

[0091] Optionally, in this embodiment, the method for determining whether the log interface of the multipath module can be switched to the independent log interface may include but is not limited to: first, pre-set the target duration threshold, wherein the target duration threshold is a specific time point, and if the server system startup duration exceeds this time point, it can be said that the target independent files of all multipath modules are in a state of successful mounting (logs can be recorded normally), assuming that it is 30s. Then, the system startup duration is recorded when the server system is started, and the current system startup duration is compared with the target duration threshold in real time. When the system startup duration does not exceed the target duration threshold, that is, the system may still be in the startup process (the target independent file may not be mounted successfully), the operation log of the multipath module will continue to be recorded in the public file by the system log interface. When the system startup duration exceeds the target duration threshold, that is, the system has been completely successfully started (the target independent file is mounted successfully), the server system will switch the log interface of the multipath module to the independent log interface according to the independent file information and independent interface information previously obtained. Ensure that the operation log of the multipath module can be correctly recorded at different stages of the server system startup.

[0092] Optionally, in this embodiment, Figure 3 is a flowchart of a multipath service log interface initialization method according to an embodiment of the present application, such as Figure 3 As shown, the method of determining whether the log interface of the multipath module can be switched to an independent log interface may include but is not limited to:

[0093] Step S201, when the server system starts, first obtain the system startup time, and at the same time, check the system configuration file to determine the total number of multipath modules that need to record independent logs, and then initialize the variable i to 0 to track the multipath module number currently being processed;

[0094] Step S202, determining whether all modules are initialized by checking whether the variable i is less than or equal to the total number of multipath modules that need to record logs, and continuing to execute step S203 when there are multipath modules that have not completed the initialization setting, and jumping to execute step S210 when all multipath modules have completed the initialization setting;

[0095] Step 203, determine whether the system startup time reaches the target time threshold. If the current system startup time exceeds the target time threshold, jump to step S204 to perform the preparation before the log interface switches to the independent log interface. If the current system startup time is less than or equal to the target time threshold, jump to step S207 to perform the operation of connecting the log interface to the system log interface.

[0096] Step S204, opening the independent log file of the multipath module i;

[0097] Step S205, the log recording thread M is initialized, the log recording handle (file information) of the log output dynamic array element i (the operation log of the multipath module i) is set to the target independent file handle (independent file information) of the multipath module i, and the interface function (interface information) is set to the target interface information (independent log opening function, independent log writing function, independent log closing function, independent log reset function) of the multipath module i;

[0098] Step S206, completing the processing of the multipath module i, and the variable i is incremented by 1;

[0099] Step S207, under the premise that the current system startup duration is less than or equal to the target duration threshold, determine whether the system file information (system log file handle) already exists. If it exists, it means that the public file indicated by the system file information has been opened before, and the previous system file information can be used directly. No other processing is required for the log interface of the multipath module i, and jump to step S206. If the system log file handle does not exist, jump to step S208 to perform preparations before the log interface is connected to the system log interface.

[0100] As an optional solution, the control system log interface records the target program's running log to a public file, including:

[0101] S41, acquiring system file information and system interface information, wherein the system file information is used to indicate a common file that allows recording of operation logs of multiple programs, and the system interface information is used to indicate a recording policy that a system log interface allows to be executed on the operation log of a target program;

[0102] S42, setting the file information currently used by the target program as system file information, and setting the interface information currently used by the target program as system interface information, wherein the server system is configured to record the operation log of the target program to the file indicated by the currently used file information according to the recording policy indicated by the currently used interface information.

[0103] Optionally, in this embodiment, the system file information may be information of a common file that records the operation logs of multiple multipath modules, and the system interface information is used to guide the corresponding system log interface on how to record the strategies and parameters of the multipath module operation logs, including a system log opening function, a system log writing function, a system log closing function, a system log reset function, etc. These functions may guide the log interface on how to collect, process and record the operation logs of the multipath modules.

[0104] Optionally, in this embodiment, the file information and interface information of the multipath module are set as system file information and system interface information respectively, and the server system can record the operation log of the multipath module into the public file indicated by the system file information according to the recording strategy defined by the system interface information.

[0105] As an optional solution, obtain system file information and system interface information, including:

[0106] S51, obtaining a public file handle corresponding to the public file, and a system log open function, a system log write function, a system log close function and a system log reset function corresponding to the system log interface, wherein the public file handle is used to identify the public file in the server system, the system log open function is used to indicate the system log interface to allow the opening policy to be executed on the operation log, the system log write function is used to indicate the system log interface to allow the writing policy to be executed on the operation log, the system log close function is used to indicate the system log interface to allow the closing policy to be executed on the operation log, and the system log reset function is used to indicate the system log interface to allow the reset policy to be executed on the operation log;

[0107] S52, determining the public file handle as system file information;

[0108] S53, determining the system log opening function, the system log writing function, the above-mentioned system log closing function and the system log resetting function as the system interface information.

[0109] Optionally, in this embodiment, if Figure 3 As shown, the method of obtaining system file information and system interface information may include but is not limited to:

[0110] Step S208, calling the system log interface, obtaining system file information (i.e., public file handle) and system interface information (i.e., system log open function, system log write function, system log close function, and system log reset function), and opening the public file indicated by the system file information;

[0111] Step S209, the log recording thread M is initialized, and the log recording handle (file information) of its log output dynamic array element i (the operation log of multi-path module i) is set to the system log file handle (system file information) of multi-path module i, and the interface function (interface information) is set to the system interface information of multi-path module i (system log open function, system log write function, system log close function, system log reset function).

[0112] As an optional solution, the server system allocates a switching thread for the target program when the system startup time is less than or equal to the target time threshold, and switches the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, including:

[0113] S61, obtaining a preset switching period;

[0114] S62, calling the switching thread to perform the interface switching operation according to the preset switching cycle until the interface switching operation is successfully executed, wherein the switching thread is used to detect whether independent file information and independent interface information are currently obtained each time the interface switching operation is executed; when it is detected that the independent file information and independent interface information are not successfully obtained, it is determined that the interface switching operation has failed to be executed; when it is detected that the independent file information and independent interface information are successfully obtained, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and independent interface information, and it is determined that the interface switching operation is successfully executed.

[0115] Optionally, in this embodiment, the switching thread may be, but is not limited to, a thread running in the background, which is specifically responsible for executing the multipath module log interface switching task without interfering with the execution of the main program.

[0116] Optionally, in this embodiment, Figure 4 is a flow chart of a multi-path service log interface verification method according to an embodiment of the present application, such as Figure 4 As shown, after all multipath modules are initialized, the log interfaces of some multipath modules are system log interfaces, and the log interfaces of some multipath modules are independent log interfaces. By setting a temporary task thread N (i.e., a switching thread), the log interfaces of some multipath modules whose log interfaces are system log interfaces are switched to independent log interfaces. The method of using the temporary task thread N to handle the switching of the multipath module log interfaces may include but is not limited to:

[0117] Step S216, the server system presets a retry interval (preset switching period), which determines the maximum retry threshold of the switching thread attempting to perform the interface switching operation (i.e., switching the log interface corresponding to the multipath module from the system log interface to the independent log interface). Usually, the maximum retry threshold can be the ratio of the target duration threshold of the system startup and the retry interval, and the number of retries x is initialized to 0;

[0118] Step S217, determining whether the system startup time of the multipath module reaches the target time threshold. If the current system startup time exceeds the target time threshold (indicating that the system has been started, the log interface of the multipath module has been switched to the independent log interface, and thread N can be terminated), jump to step S230 to end the verification, otherwise jump to step S218 to continue to perform subsequent operations;

[0119] Step S218, determine whether the number of retries x is less than the maximum retry threshold. If the current number of retries is less than the maximum retry threshold, jump to step S219. If the current number of retries is equal to the maximum retry threshold, end thread N and jump to step S230 to end the test;

[0120] Step S219, setting a variable y to track the number of the multipath module currently being processed, and setting the initial value of y to 0;

[0121] Step S220, determining whether y is less than or equal to the total number of multipath modules, if y is greater than the total number of multipath modules, that is, if all modules have been processed, then terminate thread N, jump to step S228 and wait for a certain time interval (retry interval) before retrying, if y is less than or equal to the total number of multipath modules, that is, if there are modules that have not been processed, then jump to step S221;

[0122] Step S221, determine whether the multipath module y has switched to an independent log interface, by detecting whether the multipath module y obtains independent file information and independent interface information. If the independent file information and independent interface information are not detected, it means that the log interface of the module has not completed the interface switching operation, jump to step S222 to continue trying the switching operation. If independent file information and independent interface information are detected, it means that the log interface of the module has switched to an independent log interface, jump to step S227 to continue preparing to process the next module.

[0123] As an optional solution, independent file information and independent interface information corresponding to the target program running on the server system are obtained, including:

[0124] S71, obtaining an independent file handle, an independent log open function, an independent log write function, an independent log close function and an independent log reset function corresponding to the target program from the target configuration file, wherein the target configuration file records the programs, file handles, log open function, log write function, log close function and log reset function having corresponding relationships in the server system, the independent file handle is used to identify a file in the server system that is only allowed to record the operation log of the target program, the independent log open function is used to indicate that the log interface allows the opening policy to be executed on the operation log of the target program, the independent log write function is used to indicate that the log interface allows the writing policy to be executed on the operation log of the target program, the independent log close function is used to indicate that the log interface allows the closing policy to be executed on the operation log of the target program, and the independent log reset function is used to indicate that the log interface allows the reset policy to be executed on the operation log of the target program;

[0125] S72, determining the independent file handle as independent file information;

[0126] S73, determining the independent log opening function, the independent log writing function, the independent log closing function and the independent log resetting function as independent interface information.

[0127] Optionally, in the present embodiment, the target configuration file includes the independent file information and independent interface information corresponding to the multipath module, which allows the user to set different log levels for the operation logs of different multipath modules according to the frequency or importance of the multipath module failures, such as, a higher log level can be set for the log of the module related to the system error, and a lower log level can be set for the log of the module of general information. It is also possible to send a notification or an alarm when a specific log event is triggered, such as, when an error log occurs, send an email notification. By monitoring the high-level log of key modules and notifying in real time, it is possible to ensure that quick identification and response can be achieved when the server system is abnormal, thereby improving the analysis efficiency of log records.

[0128] Optionally, in this embodiment, if Figure 3 As shown, the method of obtaining independent file information and independent interface information may include but is not limited to:

[0129] Step S204, obtaining independent file information (i.e., independent file handle) and independent interface information (i.e., independent log opening function, independent log writing function, independent log closing function, and independent log resetting function) from the target configuration file, and opening the target independent file indicated by the independent file information;

[0130] Step S205, the logging thread M is initialized, and the logging handle (file information) of its log output dynamic array element i (the operation log of the multi-path module i) is set to the independent log file handle (independent file information) of the multi-path module i, and the interface function (interface information) is set to the independent interface information of the multi-path module i (independent log opening function, independent log writing function, independent log closing function and independent log reset function).

[0131] As an optional solution, the server system allocates a monitoring thread to the target program. After obtaining the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program from the target configuration file, the method further includes:

[0132] S81, calling the monitoring thread to detect whether the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program recorded in the target configuration file are changed;

[0133] S82, when it is detected that the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function corresponding to the target program have changed, use the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function after the most recent change to update the independent file information and independent interface information currently used by the independent log interface.

[0134] Optionally, in this embodiment, the monitoring thread may be, but is not limited to, a thread running in the background, specifically responsible for executing the multipath module log interface monitoring task without interfering with the execution of the main program.

[0135] Optionally, in this embodiment, after obtaining the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function corresponding to the target program from the target configuration file, the monitoring thread is called to detect changes in the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function, and when changes are detected, the latest content is updated in the independent file information and independent interface information.

[0136] Optionally, in this embodiment, Figure 5 is a flow chart of a multi-path service log monitoring method according to an embodiment of the present application, such as Figure 5 As shown, the monitoring thread may perform updates in a manner that includes, but is not limited to:

[0137] Step S301, determining whether a shutdown signal of the monitoring thread K is received, if a shutdown signal is received, indicating that it is no longer necessary to monitor and adjust the log settings of the multipath module, and directly terminating the thread K, if a shutdown signal is not received, jumping to step S302 to monitor changes in the target configuration file;

[0138] Step S302: monitor whether the target configuration file has any addition, deletion or modification actions (thread K starts monitoring the log configuration file, checks whether the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function have any change actions);

[0139] Step S303: Determine whether there is any addition, deletion or modification action on the target configuration file; if changes are detected in the configuration file, jump to step S304 to read and parse these changes; if no changes are detected in the configuration file, jump to step S302 to continue monitoring the target configuration file;

[0140] Step S304: reading and parsing the independent file handle in the target configuration file, and updating the independent log opening function, the independent log writing function, the independent log closing function and the independent log resetting function;

[0141] Step S305: setting a new log recording strategy according to the latest independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function;

[0142] Step S306: setting a variable z to track the number of the multipath module currently being processed, and initializing z to 0;

[0143] Step S307: Determine whether z is less than or equal to the total number of multipath modules. If z is less than or equal to the total number of multipath modules, it means that there are still multipath modules that need to be updated, and jump to step S308 to continue execution. If z is greater than the total number of multipath modules, it means that all multipath modules have been updated, and jump to step S303 to continue monitoring the changes of the target configuration file.

[0144] Step S308: Open the independent log file of the multipath module z (ie, the target independent file);

[0145] Step S309: the log output dynamic array element z log file handle (independent file information) of the log recording thread M is switched from the old log file handle to the new log file handle; the log output dynamic array element z log interface function (independent interface information) of the log recording thread M is switched from the old log interface to the new log interface;

[0146] Step S310: the variable z is incremented by 1, and the process jumps to step S307 to check whether there are more modules that need to be updated.

[0147] As an optional solution, control the independent log interface to record the running log of the target program, including:

[0148] S91, obtaining the file directory to which the target independent file belongs, and obtaining the target file directory;

[0149] S92, creating a target test file in the target file directory;

[0150] S93, writing the test data into the target test file to obtain a test result, wherein the test result is used to indicate whether the test data is successfully written into the target test file;

[0151] S94, controlling the independent log interface to record the running log of the target program according to the test result.

[0152] Optionally, in this embodiment, the process of controlling the independent log interface to record the running log of the target program can be implemented by, but not limited to, the log recording thread M, such as Figure 4 As shown, the method of controlling the independent log interface to record the running log of the target program may include but is not limited to:

[0153] Step S222: Obtain the file directory (target file directory) to which the independent log file (target independent file) of multipath module y belongs, create a temporary test file (target test file) in the same directory, and write test data in the temporary log file to test whether the path is available.

[0154] As an optional solution, the independent log interface is controlled to record the running log of the target program according to the test results, including:

[0155] S101, when the test result indicates that the test data fails to be written into the target test file, prohibiting the independent log interface from recording the running log of the target program, and deleting the target test file;

[0156] S102, when the test result indicates that the test data is successfully written into the target test file, controlling the independent log interface to start recording the operation log of the target program.

[0157] Optionally, in this embodiment, if Figure 4 As shown, the method of controlling the log interface of the multipath module to record logs according to the test results may include but is not limited to:

[0158] Step S223: Check whether the test data is written successfully. If the writing fails, jump to step S226 to delete the temporary test file and prepare to retry. If the writing is successful, jump to step S224 to perform the log interface switching operation, switch the log interface to an independent log interface, and then control the independent log interface to record the operation log of the multipath module.

[0159] As an optional solution, the server system pre-builds a log buffer queue, which is used to temporarily store the running logs of multiple programs in the server system and control the independent log interface to record the running logs of the target program, including:

[0160] S111, controlling the independent log interface to extract a target running log of a target program from a plurality of running logs currently stored in the log buffer queue;

[0161] S112, controlling the independent log interface to record the target operation log into the target independent file according to the recording strategy indicated by the independent interface information.

[0162] Optionally, in this embodiment, the server system pre-builds a log buffer queue that can temporarily store the operation logs of multiple multipath modules. The log buffer queue can be a circular queue. A circular queue can temporarily store the operation log of one multipath module, or temporarily store the operation logs of multiple multipath modules.

[0163] Optionally, in this embodiment, if Figure 3 As shown, the method of using the log buffer queue to control the independent log interface to record the running log of the target program may include but is not limited to:

[0164] Step S210, the log ring buffer queue is initialized and the log recording thread M is started;

[0165] Step S211, the multipath service process determines whether it has received a log recording thread M shutdown signal. If the multipath service process receives the log recording thread M shutdown signal, it indicates that the multipath service process will terminate the log processing task, and the process ends directly; if the multipath service process does not receive the log recording thread M shutdown signal, the log processing task will proceed normally, and the process goes to step S212;

[0166] Step S212, waiting for a wake-up signal. If the logging thread M receives the wake-up signal, jump to step S213;

[0167] Step S213, determining whether the log ring buffer queue is empty, that is, checking whether there are logs to be processed in the log ring buffer queue. If the log ring buffer queue is not empty, it means that there are new logs to be recorded, and the multipath service process will process these logs, and jump to step S214. If the log ring buffer queue is empty, it means that there are no new logs to be recorded at this time, and jump to step S215 to enter the waiting state;

[0168] Step S214: for each log entry in the log ring buffer queue, according to the module name to which the source belongs, the interface of the corresponding element in the log output dynamic array is called to record the log. After the log recording is completed, the multipath service process will enter the waiting state again to receive a new wake-up signal or shutdown signal.

[0169] Step S215, when there is no log to be processed, the multipath service process will remain in a waiting state. In the waiting state, the process will periodically check whether there is new log data to be processed (jump to step S213), or whether there is a shutdown signal to be responded to).

[0170] Optionally, in this embodiment, in order to better understand the process of the above-mentioned log recording method, the above-mentioned log recording process is described below in combination with an optional embodiment, but it is not used to limit the technical solution of the embodiment of the present application.

[0171] In this embodiment, a log recording method is provided, which mainly includes a log interface initialization method, a verification method and a monitoring method, and the following steps:

[0172] like Figure 3 As shown, the initialization method of the log interface includes:

[0173] Step S201, when the server system starts, first obtain the system startup time, and at the same time, check the system configuration file to determine the total number of multipath modules that need to record independent logs, and then initialize the variable i to 0 to track the multipath module number currently being processed;

[0174] Step S202, determining whether all modules are initialized by checking whether the variable i is less than or equal to the total number of multipath modules that need to record logs, and continuing to execute step S203 when there is a multipath module that has not completed the initialization setting, and executing the inspection method of the log interface when all multipath modules have completed the initialization setting;

[0175] Step 203, determine whether the system startup time reaches the target time threshold. If the current system startup time exceeds the target time threshold, jump to step S204 to perform the preparation before the log interface switches to the independent log interface. If the current system startup time is less than or equal to the target time threshold, jump to step S207 to perform the operation of connecting the log interface to the system log interface.

[0176] Step S204, opening the independent log file of the multipath module i;

[0177] Step S205, the log recording thread M is initialized, the log recording handle (file information) of the log output dynamic array element i (the operation log of the multipath module i) is set to the target independent file handle (independent file information) of the multipath module i, and the interface function (interface information) is set to the target interface information (independent log opening function, independent log writing function, independent log closing function, independent log reset function) of the multipath module i;

[0178] Step S206, completing the processing of the multipath module i, and the variable i is incremented by 1;

[0179] Step S207, under the premise that the current system startup duration is less than or equal to the target duration threshold, determine whether the system file information (system log file handle) already exists. If it exists, it means that the public file indicated by the system file information has been opened before, and the previous system file information can be used directly. No other processing is required for the log interface of the multipath module i, and jump to step S206. If the system log file handle does not exist, jump to step S208 to perform preparations before the log interface is connected to the system log interface.

[0180] Step S208, calling the system log interface, obtaining system file information (i.e., public file handle) and system interface information (i.e., system log open function, system log write function, system log close function, and system log reset function), and opening the public file indicated by the system file information;

[0181] Step S209, the log recording thread M is initialized, and the log recording handle (file information) of its log output dynamic array element i (the operation log of the multipath module i) is set to the system log file handle (system file information) of the multipath module i, and the interface function (interface information) is set to the system interface information (system log opening function, system log writing function, system log closing function, system log reset function) of the multipath module i;

[0182] Step S210, the log ring buffer queue is initialized and the log recording thread M is started;

[0183] Step S211, the multipath service process determines whether it has received a log recording thread M shutdown signal. If the multipath service process receives the log recording thread M shutdown signal, it indicates that the multipath service process will terminate the log processing task, and the process ends directly; if the multipath service process does not receive the log recording thread M shutdown signal, the log processing task will proceed normally, and the process goes to step S212;

[0184] Step S212, waiting for a wake-up signal. If the logging thread M receives the wake-up signal, jump to step S213;

[0185] Step S213, determining whether the log ring buffer queue is empty, that is, checking whether there are logs to be processed in the log ring buffer queue. If the log ring buffer queue is not empty, it means that there are new logs to be recorded, and the multipath service process will process these logs, and jump to step S214. If the log ring buffer queue is empty, it means that there are no new logs to be recorded at this time, and jump to step S215 to enter the waiting state;

[0186] Step S214: for each log entry in the log ring buffer queue, according to the module name to which the source belongs, the interface of the corresponding element in the log output dynamic array is called to record the log. After the log recording is completed, the multipath service process will enter the waiting state again to receive a new wake-up signal or shutdown signal.

[0187] Step S215, when there is no log to be processed, the multipath service process will remain in a waiting state. In the waiting state, the process will periodically check whether there is new log data to be processed (jump to step S213), or whether there is a shutdown signal to be responded to).

[0188] like Figure 4 As shown, the verification method of the log interface includes:

[0189] Step S216, the server system presets a retry interval (preset switching period), which determines the maximum retry threshold of the switching thread attempting to perform the interface switching operation (i.e., switching the log interface corresponding to the multipath module from the system log interface to the independent log interface). Usually, the maximum retry threshold can be the ratio of the target duration threshold of the system startup and the retry interval, and the number of retries x is initialized to 0;

[0190] Step S217, determining whether the system startup time of the multipath module reaches the target time threshold. If the current system startup time exceeds the target time threshold (indicating that the system has been started, the log interface of the multipath module has been switched to the independent log interface, and the temporary task thread N can be terminated), jump to step S230 to end the verification, otherwise jump to step S218 to continue to perform subsequent operations;

[0191] Step S218, determine whether the number of retries x is less than the maximum retry threshold. If the current number of retries is less than the maximum retry threshold, jump to step S219. If the current number of retries is equal to the maximum retry threshold, end thread N and jump to step S230 to end the test;

[0192] Step S219, setting a variable y to track the number of the multipath module currently being processed, and setting the initial value of y to 0;

[0193] Step S220, determining whether y is less than or equal to the total number of multipath modules, if y is greater than the total number of multipath modules, that is, if all modules have been processed, then terminate thread N, jump to step S228 and wait for a certain time interval (retry interval) before retrying, if y is less than or equal to the total number of multipath modules, that is, if there are modules that have not been processed, then jump to step S221;

[0194] Step S221, determining whether the multipath module y has switched to the independent log interface, by detecting whether the multipath module y obtains the independent file information and the independent interface information, if the independent file information and the independent interface information are not detected, it means that the log interface of the module has not completed the interface switching operation, and jumping to step S222 to continue to try the switching operation, if the independent file information and the independent interface information are detected, it means that the log interface of the module has switched to the independent log interface, and jumping to step S227 to continue to prepare to process the next module;

[0195] Step S222: obtaining the file directory (target file directory) to which the independent log file (target independent file) of the multipath module y belongs, creating a temporary test file (target test file) in the same directory, and writing test data in the temporary log file to test whether the path is available;

[0196] Step S223: Verify whether the test data is written successfully. If the writing fails, jump to step S226 to delete the temporary test file and prepare to retry. If the writing succeeds, jump to step S224 to perform the log interface switching operation, switch the log interface to the independent log interface, and then control the independent log interface to record the operation log of the multipath module.

[0197] Step S224: After successful writing, the multipath module performs an open operation on the independent log file y to obtain its independent log file handle;

[0198] Step S225: the log output dynamic array element y log record file handle of thread M is switched from the system log handle to the independent log file handle of multipath module y; the log output dynamic array element y log record interface function of thread M is switched from the system log interface to the independent log interface of multipath module y (switching the log output interface of thread M from the system log to the independent log interface);

[0199] Step S226: Delete temporary test files (delete temporary files after the test is completed);

[0200] Step S227: the variable y is incremented by 1 (processing the next multipath module);

[0201] Step S228: sleep retry time interval seconds (wait for a certain time interval before retrying);

[0202] Step S229: the number of retries is incremented by 1, and the process goes to step S218 (the number of retries is incremented after each retry);

[0203] Step S230: After all modules have been processed or the maximum number of retries has been reached, thread N is terminated.

[0204] like Figure 5 As shown, the monitoring method of the log interface includes:

[0205] Step S301, determining whether a shutdown signal of the monitoring thread K is received, if a shutdown signal is received, indicating that it is no longer necessary to monitor and adjust the log settings of the multipath module, and directly terminating the thread K, if a shutdown signal is not received, jumping to step S302 to monitor changes in the target configuration file;

[0206] Step S302: monitor whether the target configuration file has any addition, deletion or modification actions (thread K starts monitoring the log configuration file, checks whether the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function have any change actions);

[0207] Step S303: Determine whether there is any addition, deletion or modification action on the target configuration file; if changes are detected in the configuration file, jump to step S304 to read and parse these changes; if no changes are detected in the configuration file, jump to step S302 to continue monitoring the target configuration file;

[0208] Step S304: reading and parsing the independent file handle in the target configuration file, and updating the independent log opening function, the independent log writing function, the independent log closing function and the independent log resetting function;

[0209] Step S305: setting a new log recording strategy according to the latest independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function;

[0210] Step S306: setting a variable z to track the number of the multipath module currently being processed, and initializing z to 0;

[0211] Step S307: Determine whether z is less than or equal to the total number of multipath modules. If z is less than or equal to the total number of multipath modules, it means that there are still multipath modules that need to be updated, and jump to step S308 to continue execution. If z is greater than the total number of multipath modules, it means that all multipath modules have been updated, and jump to step S303 to continue monitoring the changes of the target configuration file.

[0212] Step S308: Open the independent log file of the multipath module z (ie, the target independent file);

[0213] Step S309: the log output dynamic array element z log file handle (independent file information) of the log recording thread M is switched from the old log file handle to the new log file handle; the log output dynamic array element z log interface function (independent interface information) of the log recording thread M is switched from the old log interface to the new log interface;

[0214] Step S310: the variable z is incremented by 1, and the process jumps to step S307 to check whether there are more modules that need to be updated.

[0215] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of each embodiment of the present application.

[0216] In this embodiment, a log recording device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0217] Figure 6 is a structural block diagram of a log recording device according to an embodiment of the present application; Figure 6 As shown, applied to a server system, the device includes:

[0218] The acquisition module 602 is used to acquire the independent file information and independent interface information corresponding to the target program running on the server system, wherein the operation log of the current target program is recorded to a public file by the system log interface of the server system, and the public file allows the operation logs of multiple programs to be recorded. The independent file information is used to identify the target independent file, and the target independent file is a file that only allows the operation log of the target program to be recorded. The independent interface information is used to indicate the recording policy that the log interface allows to be executed on the operation log of the target program;

[0219] A first switching module 604 is used to switch the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, wherein the independent log interface is used to record the operation log of the target program to the target independent file according to the recording strategy indicated by the independent interface information;

[0220] The first control module 606 is used to control the independent log interface to record the running log of the target program.

[0221] In an exemplary embodiment, the first switching module includes:

[0222] A first switching unit, used to switch the file information currently used by the target program from the system file information to the independent file information, wherein the system file information is used to indicate a common file that allows recording of operation logs of multiple programs;

[0223] A second switching unit, used to switch the interface information currently used by the target program from the system interface information to the independent interface information, wherein the system interface information is used to indicate the recording policy that the system log interface allows to be executed on the running log of the target program;

[0224] The server system is configured to record the running log of the target program to the file indicated by the currently used file information according to the recording strategy indicated by the currently used interface information.

[0225] In an exemplary embodiment, the apparatus further comprises:

[0226] A first detection module is used to detect the current system startup time of the server system before switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information;

[0227] The second detection module is used to detect whether the system startup time is greater than the target time threshold;

[0228] The second control module is used to control the system log interface to record the running log of the target program to a public file when it is detected that the system startup time is less than or equal to the target time threshold;

[0229] The second switching module is used to switch the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information when it is detected that the system startup duration is greater than the target duration threshold.

[0230] In an exemplary embodiment, the second control module includes:

[0231] A first acquisition unit is used to acquire system file information and system interface information, wherein the system file information is used to indicate a common file that allows recording of operation logs of multiple programs, and the system interface information is used to indicate a recording policy that a system log interface allows to be executed on the operation log of a target program;

[0232] A setting unit is used to set the file information currently used by the target program as system file information, and to set the interface information currently used by the target program as system interface information, wherein the server system is configured to record the operation log of the target program to the file indicated by the file information currently used according to the recording strategy indicated by the interface information currently used.

[0233] In an exemplary embodiment, the first acquisition unit is configured to:

[0234] Get the public file handle corresponding to the public file, and the system log open function, system log write function, system log close function and system log reset function corresponding to the system log interface, wherein the public file handle is used to identify the public file in the server system, the system log open function is used to indicate the system log interface to allow the open policy to be executed on the running log, the system log write function is used to indicate the system log interface to allow the write policy to be executed on the running log, the system log close function is used to indicate the system log interface to allow the close policy to be executed on the running log, and the system log reset function is used to indicate the system log interface to allow the reset policy to be executed on the running log;

[0235] Determine the public file handle as system file information;

[0236] The system log opening function, the system log writing function, the above-mentioned system log closing function and the system log resetting function are determined as the system interface information.

[0237] In an exemplary embodiment, the server system allocates a switching thread to the target program within a time when the system startup time is less than or equal to the target time threshold, and the second switching module includes:

[0238] A second acquisition unit, used to acquire a preset switching period;

[0239] A calling unit is used to call a switching thread to perform an interface switching operation according to a preset switching cycle until the interface switching operation is successfully executed, wherein the switching thread is used to detect whether independent file information and independent interface information are currently obtained each time the interface switching operation is executed; if it is detected that the independent file information and the independent interface information are not successfully obtained, it is determined that the interface switching operation has failed to be executed; if it is detected that the independent file information and the independent interface information are successfully obtained, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and the independent interface information, and it is determined that the interface switching operation is successfully executed.

[0240] In an exemplary embodiment, the acquisition module includes:

[0241] A third acquisition unit is used to obtain an independent file handle, an independent log open function, an independent log write function, an independent log close function and an independent log reset function corresponding to the target program from a target configuration file, wherein the target configuration file records the programs, file handles, log open function, log write function, log close function and log reset function having corresponding relationships in the server system, the independent file handle is used to identify a file in the server system that is only allowed to record the operation log of the target program, the independent log open function is used to indicate that the log interface allows an open policy to be executed on the operation log of the target program, the independent log write function is used to indicate that the log interface allows a write policy to be executed on the operation log of the target program, the independent log close function is used to indicate that the log interface allows a close policy to be executed on the operation log of the target program, and the independent log reset function is used to indicate that the log interface allows a reset policy to be executed on the operation log of the target program;

[0242] A first determining unit, configured to determine the independent file handle as independent file information;

[0243] The second determining unit is used to determine the independent log opening function, the independent log writing function, the independent log closing function and the independent log resetting function as independent interface information.

[0244] In an exemplary embodiment, the server system allocates a monitoring thread to the target program, and the device further includes:

[0245] A calling module is used to, after obtaining the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program from the target configuration file, call the monitoring thread to detect whether the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program recorded in the target configuration file are changed;

[0246] An update module is used to update the independent file information and independent interface information currently used by the independent log interface using the most recently changed independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function when it is detected that the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function corresponding to the target program have changed.

[0247] In an exemplary embodiment, the first control module includes:

[0248] A fourth acquisition unit is used to acquire the file directory to which the target independent file belongs, and obtain the target file directory;

[0249] Create a unit, which is used to create a target test file in the target file directory;

[0250] A writing unit, used to write test data into a target test file and obtain a test result, wherein the test result is used to indicate whether the test data is successfully written into the target test file;

[0251] The recording unit is used to control the independent log interface to record the running log of the target program according to the test results.

[0252] In an exemplary embodiment, the recording unit is configured to:

[0253] In the case where the test result indicates that the test data fails to be written into the target test file, the independent log interface is prohibited from recording the running log of the target program, and the target test file is deleted;

[0254] When the test result indicates that the test data is successfully written into the target test file, the independent log interface is controlled to start recording the running log of the target program.

[0255] In an exemplary embodiment, the server system pre-builds a log buffer queue, which is used to temporarily store the operation logs of multiple programs in the server system, and the recording unit is also used to:

[0256] Control the independent log interface to extract the target running log of the target program from the multiple running logs currently stored in the log buffer queue;

[0257] The independent log interface is controlled to record the target operation log to the target independent file according to the recording strategy indicated by the independent interface information.

[0258] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0259] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps of the method in each embodiment of the present application when the computer program is executed by a processor; the computer program product also includes a non-volatile computer-readable storage medium, which stores the computer program, and implements the steps of the method in each embodiment of the present application when the computer program is executed by the processor.

[0260] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0261] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0262] An embodiment of the present application further provides an electronic device, Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present application, such as Figure 7 As shown, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0263] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0264] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0265] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0266] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A log recording method, characterized in that: Applied to a server system, the method includes: Obtaining independent file information and independent interface information corresponding to a target program running on a server system, wherein the running log of the current target program is recorded to a public file by a system log interface of the server system, the public file allows the running logs of multiple programs to be recorded, the independent file information is used to identify a target independent file, the target independent file is a file that only allows the running log of the target program to be recorded, and the independent interface information is used to indicate the recording policy that the log interface allows to be executed on the running log of the target program; Switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, wherein the independent log interface is used to record the operation log of the target program to the target independent file according to the recording strategy indicated by the independent interface information; Control the independent log interface to record the running log of the target program; The step of switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information includes: Switching the file information currently used by the target program from the system file information to the independent file information, wherein the system file information is used to indicate a common file that allows recording the operation logs of multiple programs; Switching the interface information currently used by the target program from the system interface information to the independent interface information, wherein the system interface information is used to indicate the recording policy that the system log interface allows to be executed on the running log of the target program; The server system is configured to record the running log of the target program to the file indicated by the currently used file information according to the recording strategy indicated by the currently used interface information.

2. The method according to claim 1, characterized in that Before switching the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, the method further includes: Detecting the current system startup time of the server system; Detecting whether the system startup duration is greater than a target duration threshold; When it is detected that the system startup duration is less than or equal to the target duration threshold, controlling the system log interface to record the running log of the target program to the public file; When it is detected that the system startup duration is greater than the target duration threshold, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and the independent interface information.

3. The method according to claim 2, characterized in that The controlling the system log interface to record the operation log of the target program to the public file includes: Acquire system file information and system interface information, wherein the system file information is used to indicate the common file that allows recording of operation logs of multiple programs, and the system interface information is used to indicate the recording policy that the system log interface allows to be executed on the operation log of the target program; The file information currently used by the target program is set as the system file information, and the interface information currently used by the target program is set as the system interface information, wherein the server system is configured to record the operation log of the target program to the file indicated by the currently used file information in accordance with the recording strategy indicated by the currently used interface information.

4. The method according to claim 3, characterized in that The obtaining of system file information and system interface information includes: Obtain a public file handle corresponding to the public file, and a system log open function, a system log write function, a system log close function and a system log reset function corresponding to the system log interface, wherein the public file handle is used to identify the public file in the server system, the system log open function is used to indicate the opening policy that the system log interface allows to be executed on the operation log, the system log write function is used to indicate the writing policy that the system log interface allows to be executed on the operation log, the system log close function is used to indicate the closing policy that the system log interface allows to be executed on the operation log, and the system log reset function is used to indicate the reset policy that the system log interface allows to be executed on the operation log; Determining the public file handle as the system file information; The system log opening function, the system log writing function, the above-mentioned system log closing function and the system log resetting function are determined as the system interface information.

5. The method according to claim 2, characterized in that: The server system allocates a switching thread to the target program within a time when the system startup duration is less than or equal to the target duration threshold, and the switching of the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information includes: Get the preset switching cycle; The switching thread is called to perform an interface switching operation according to a preset switching cycle until the interface switching operation is successfully executed, wherein the switching thread is used to detect whether the independent file information and the independent interface information are currently obtained each time the interface switching operation is executed; if it is detected that the independent file information and the independent interface information are not successfully obtained, it is determined that the interface switching operation has failed to be executed; if it is detected that the independent file information and the independent interface information are successfully obtained, the log interface corresponding to the target program is switched from the system log interface to the independent log interface according to the independent file information and the independent interface information, and it is determined that the interface switching operation is successfully executed.

6. The method according to claim 1, characterized in that The obtaining of independent file information and independent interface information corresponding to the target program running on the server system includes: Obtaining an independent file handle, an independent log opening function, an independent log writing function, an independent log closing function and an independent log resetting function corresponding to the target program from a target configuration file, wherein the target configuration file records the programs, file handles, log opening function, log writing function, log closing function and log resetting function having corresponding relationships in the server system, the independent file handle is used to identify a file in the server system that is only allowed to record the operation log of the target program, the independent log opening function is used to indicate that the log interface allows an opening policy to be executed on the operation log of the target program, the independent log writing function is used to indicate that the log interface allows a writing policy to be executed on the operation log of the target program, the independent log closing function is used to indicate that the log interface allows a closing policy to be executed on the operation log of the target program, and the independent log resetting function is used to indicate that the log interface allows a resetting policy to be executed on the operation log of the target program; Determine the independent file handle as the independent file information; The independent log opening function, the independent log writing function, the independent log closing function and the independent log resetting function are determined as the independent interface information.

7. The method according to claim 6, characterized in that The server system allocates a monitoring thread to the target program. After obtaining the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program from the target configuration file, the method further includes: Calling the monitoring thread to detect whether there are changes in the independent file handle, independent log opening function, independent log writing function, independent log closing function and independent log resetting function corresponding to the target program recorded in the target configuration file; When it is detected that the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function corresponding to the target program have changed, the independent file handle, independent log open function, independent log write function, independent log close function and independent log reset function after the most recent change are used to update the independent file information and the independent interface information currently used by the independent log interface.

8. The method according to claim 1, characterized in that The controlling the independent log interface to record the operation log of the target program includes: Obtain the file directory to which the target independent file belongs, and obtain the target file directory; Create a target test file in the target file directory; Writing test data into the target test file to obtain a test result, wherein the test result is used to indicate whether the test data is successfully written into the target test file; The independent log interface is controlled to record the running log of the target program according to the test result.

9. The method according to claim 8, characterized in that The controlling the independent log interface to record the operation log of the target program according to the test result includes: In the case where the test result indicates that the test data fails to be written into the target test file, prohibiting the independent log interface from recording the running log of the target program, and deleting the target test file; When the test result indicates that the test data is successfully written into the target test file, the independent log interface is controlled to start recording the operation log of the target program.

10. The method according to claim 1, characterized in that The server system pre-builds a log buffer queue, and the log buffer queue is used to temporarily store the operation logs of multiple programs in the server system. The controlling the independent log interface to record the operation log of the target program includes: Controlling the independent log interface to extract a target running log of the target program from a plurality of running logs currently stored in the log buffer queue; The independent log interface is controlled to record the target operation log to the target independent file according to the recording strategy indicated by the independent interface information.

11. A log recording device, characterized in that: Applied to a server system, the device includes: An acquisition module is used to acquire independent file information and independent interface information corresponding to a target program running on a server system, wherein the operation log of the current target program is recorded to a public file by a system log interface of the server system, and the public file allows the operation logs of multiple programs to be recorded. The independent file information is used to identify a target independent file, and the target independent file is a file that only allows the operation log of the target program to be recorded. The independent interface information is used to indicate the recording policy that the log interface allows to be executed on the operation log of the target program; A first switching module switches the log interface corresponding to the target program from the system log interface to the independent log interface according to the independent file information and the independent interface information, wherein the independent log interface is used to record the operation log of the target program to the target independent file according to the recording strategy indicated by the independent interface information; A first control module controls the independent log interface to record the operation log of the target program; Wherein, the first switching module includes: A first switching unit, used to switch the file information currently used by the target program from the system file information to the independent file information, wherein the system file information is used to indicate a common file that allows recording of operation logs of multiple programs; A second switching unit, used to switch the interface information currently used by the target program from the system interface information to the independent interface information, wherein the system interface information is used to indicate the recording policy that the system log interface allows to be executed on the running log of the target program; The server system is configured to record the running log of the target program to the file indicated by the currently used file information according to the recording strategy indicated by the currently used interface information.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 10 when executed by a processor.

14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 10 are implemented.

Citation Information

Patent Citations

  • Log recording method and system

    CN106296400A

  • Log file generation method and device, computer equipment and storage medium

    CN111290919A