Log retrieval method and device

By recording the input and output data of thread identification and calling methods during log storage, the problem of incomplete log retrieval in the distributed log system is solved, and a comprehensive search of log data in each link of the same business is realized, improving the integrity and accuracy of log retrieval.

CN120448347AActive Publication Date: 2025-08-08BEIJING ALL UNION TECH CORP
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510344863.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-08-08
Estimated Expiration
2045-03-21

AI Technical Summary

Technical Problem

In distributed storage log systems, common parameters may be lacking between logs generated by different links of the same business, resulting in incomplete log retrieval and inability to retrieve all relevant log data.

Method used

When log data is stored, the thread identification when log data is generated and the input and output data of the calling method are recorded, and it is encapsulated into a log package storage with the log data, and is retrieved in association through thread identification and input and output data to ensure integrity.

Benefits of technology

It realizes a comprehensive search of log data in each link of the same business, improves the integrity and accuracy of log retrieval and reduces retrieval errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448347A_ABST
    Figure CN120448347A_ABST
Patent Text Reader

Abstract

The invention provides a log retrieval method and device. The method comprises the steps of obtaining retrieval information; according to the retrieval information, retrieving a target log package from log packages of a plurality of servers corresponding to the application program, each log packet of each server comprises log data generated by a corresponding link of a corresponding service of the application program, an identifier of a thread used by the application program when the log data is generated, and input data and output data of a called method; retrieving an extended log packet from the log packets of the plurality of servers according to the identifier in the target log packet, the input data and the output data; and determining the target log packet and the extended log packet as log packets corresponding to the retrieval information. Therefore, when the log data is retrieved based on the retrieval information, the associated log data can be searched according to the thread identifier carried by the retrieved log data and the input data and the output data of the calling method, comprehensive search of the log data required by the retrieval information is realized, and the integrity of log retrieval is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a log retrieval method, a log retrieval device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] Logs are an integral part of applications. Recording the logs generated by applications provides data support when troubleshooting application anomalies. Searching recorded logs allows you to accurately locate the logs you need, improving problem-solving efficiency.

[0003] Logs are typically stored in a distributed manner. This means that different logs generated by an application are stored on different servers. To retrieve application logs, logs from different servers are first stored in the same location. Then, using keywords or key phrases, the logs in that location are searched to retrieve the desired logs.

[0004] However, logs generated by different stages of the same business within an application may not share common parameters. For example, the payment process in a shopping app involves transactions, settlement, and clearing. Logs generated during the transaction phase contain order numbers, while logs generated during the settlement and clearing phases do not. Searching the logs by order number only retrieves logs generated during the transaction phase of the payment business. Logs generated during the settlement and clearing phases of the payment business cannot be retrieved by order number. This compromises the integrity of log retrieval. Summary of the Invention

[0005] The purpose of the embodiments of the present application is to provide a log retrieval method, a log retrieval device, an electronic device, a computer-readable storage medium, and a computer program product to improve the integrity of log retrieval.

[0006] To solve the above technical problems, the embodiments of the present application provide the following technical solutions:

[0007] The first aspect of the present application provides a log retrieval method, which includes: obtaining retrieval information; retrieving a target log package from the log packages of multiple servers corresponding to an application based on the retrieval information, wherein each log package of each server includes log data generated by a corresponding link of a corresponding business of the application, an identifier of a thread used by the application when the log data is generated, and input data and output data of a called method; retrieving an extended log package from the log packages of multiple servers based on the identifier, input data, and output data in the target log package; and determining the target log package and the extended log package as log packages corresponding to the retrieval information.

[0008] Compared to the prior art, the log retrieval method provided in the first aspect of this application stores the thread identifier that generated the log data, as well as the input and output data of the calling method, along with the log data. This allows for the complete search of the log data required for the retrieval information by finding the thread identifier and the input and output data of the calling method when retrieving the log data based on the retrieval information.

[0009] In some changed implementations of the first aspect of the present application, before obtaining the retrieval information, the method also includes: obtaining the target log data generated by the target link of the target business of the application; obtaining the identifier of the thread used by the application when the target log data is generated and the input data and output data of the called method, wherein different links of the same business in the application use the same thread when running, and the output data of the method called in the previous link is the same as the input data of the method called in the next link; encapsulating the target log data, identifier, input data and output data into a log package; and storing the log package on the server corresponding to the target log data.

[0010] When log data is generated in a certain link of a certain business of an application, the generated log data, the called thread identifier, and the input and output data of the calling method are immediately encapsulated into a log package for storage. This ensures that the log data, thread identifier, and calling method-related data are stored completely together, avoiding errors or loss of data, thereby improving the accuracy of log retrieval.

[0011] In some changed implementations of the first aspect of the present application, before encapsulating the target log data, identifier, input data and output data into a log package, the method also includes: storing the input data and output data in a thread set corresponding to the identifier, so that the input data and output data can be encapsulated together when the log data generated by the next link of the target link is encapsulated; encapsulating the target log data, identifier, input data and output data into a log package includes: encapsulating the target log data, identifier, input data and output data in the thread set into a log package.

[0012] While storing the input and output data of the current calling method, it also stores the input and output data of the calling method in the previous link of the same business, so that the log package can fully characterize the business involved to the greatest extent possible, thereby improving the accuracy of log retrieval.

[0013] In some modified implementations of the first aspect of the present application, before encapsulating the target log data, identifier, input data and output data into a log package, the method also includes: obtaining the characterization information of the server corresponding to the storage of the target log data; encapsulating the target log data, identifier, input data and output data into a log package, including: encapsulating the target log data, identifier, input data and output data and the characterization information into a log package.

[0014] While storing thread identification and call method-related data, it also stores server representation information. This allows you to identify the server where the log data is stored while finding the log data. When tracing back based on the log data, you can quickly lock the server, improving the efficiency of problem solving based on log data.

[0015] In some changed implementations of the first aspect of the present application, obtaining target log data generated by the target link of the target business of the application includes: in response to calling the log append method, obtaining log data corresponding to the log append method, and determining the obtained log data as the target log data generated by the target link of the target business of the application.

[0016] When the log append method is detected to be called, the log data of the log writing calling method is obtained, the log data can be quickly obtained, and then the log data and its thread identifier are quickly encapsulated into a log package, thereby improving the storage efficiency of the log package.

[0017] In some modified implementations of the first aspect of the present application, a target log package is retrieved from the log packages of multiple servers corresponding to the application based on the retrieval information, including: if the retrieval information is consistent with the words in a preset custom dictionary, the target log package containing the retrieval information is retrieved from the log packages of multiple servers corresponding to the application, wherein the words in the custom dictionary are composed of the method names called by the application; if the retrieval information is inconsistent with the words in the preset custom dictionary, the retrieval information is segmented to obtain multiple segmented words, and the target log package containing each segmented word is retrieved from the log packages of multiple servers corresponding to the application.

[0018] Before searching based on the query information, the query information is first matched against the terms in the custom dictionary. If a match is found, the query information is used directly for the search, avoiding the need to split the query information into multiple word segments. Using each word segment for a search not only requires multiple searches, resulting in low search efficiency, but also may retrieve content unrelated to the query information, reducing search accuracy. Therefore, if the query information matches a term in the custom dictionary, using the query information directly for the search can improve the efficiency and accuracy of log retrieval.

[0019] In some modified implementations of the first aspect of the present application, before retrieving an extended log package from the log packages of multiple servers based on the identifier, input data and output data in the target log package, the method also includes: if the number of target log packages exceeds a preset threshold, the target log packages with the same identifier are classified into one category to obtain and output multiple target log package sets; based on the selection result of the target log package set, a specified target log package set is selected from the multiple target log package sets; and an extended log package is retrieved from the log packages of multiple servers based on the identifier, input data and output data in the target log package, including: retrieving the extended log package from the log packages of multiple servers based on the identifier, input data and output data in each target log package in the specified target log package set.

[0020] When a large number of log packages are initially retrieved, the log packages of the same business are classified based on the thread identifier in the log package and displayed to the user. In this way, the log package of a certain business is finally output according to the user's choice, which can improve the accuracy of log package retrieval.

[0021] The second aspect of the present application provides a log retrieval device, which includes: an acquisition module for acquiring retrieval information; a retrieval module for retrieving a target log package from the log packages of multiple servers corresponding to the application based on the retrieval information, wherein each log package of each server includes the log data generated by the corresponding link of the corresponding business of the application, the identifier of the thread used by the application when the log data is generated, and the input data and output data of the called method; an extension module for retrieving an extended log package from the log packages of multiple servers based on the identifier, input data and output data in the target log package; and a determination module for determining the target log package and the extended log package as the log packages corresponding to the retrieval information.

[0022] A third aspect of the present application provides an electronic device, which includes a processor, a memory and a bus. The processor and the memory communicate with each other through the bus, and the processor is used to call program instructions in the memory to execute the method in the first aspect.

[0023] A fourth aspect of the present application provides a computer-readable storage medium, which includes a stored program. When the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method in the first aspect.

[0024] In a fifth aspect, the present application provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by a device, the method in the first aspect is implemented.

[0025] The log retrieval device provided in the second aspect, the electronic device provided in the third aspect, the computer-readable storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect of this application have the same or similar beneficial effects as the log retrieval method provided in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The above and other objects, features and advantages of the exemplary embodiments of the present application will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0027] Figure 1 Schematic diagram of the scenario architecture of the log retrieval method in the embodiment of this application Figure 1 ;

[0028] Figure 2 Schematic diagram of the scenario architecture of the log retrieval method in the embodiment of this application Figure 2 ;

[0029] Figure 3 The process diagram of the log retrieval method in the embodiment of this application is as follows Figure 1 ;

[0030] Figure 4 The process diagram of the log retrieval method in the embodiment of this application is as follows Figure 2 ;

[0031] Figure 5 This is a schematic diagram of the structure of the log retrieval device in the embodiment of the present application. Figure 1 ;

[0032] Figure 6 This is a schematic diagram of the structure of the log retrieval device in the embodiment of the present application. Figure 2 ;

[0033] Figure 7 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0034] The following describes exemplary embodiments of the present application in more detail with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. Instead, these embodiments are provided to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0035] It should be noted that, unless otherwise specified, the technical or scientific terms used in this application should have the common meanings understood by those skilled in the art to which this application belongs.

[0036] The log data generated by different links of the same business in an application may not have common parameters. When log data is stored in a distributed manner, it may not be possible to retrieve all log data generated by all links of the same business based on retrieval information, thereby reducing the integrity of log retrieval.

[0037] In view of this, embodiments of the present application provide a log retrieval method, a log retrieval device, an electronic device, a computer-readable storage medium, and a computer program product. These methods store, along with the log data, the identifier of the thread that was called when the log data was generated, as well as the input and output data of the calling method. This allows, when searching for log data based on retrieval information, data from other parts of the same business process to be retrieved based on the thread identifier and input and output data carried in the log data, thereby improving the integrity of the log retrieval.

[0038] First, the application scenario of the log retrieval method provided in the embodiment of the present application is described.

[0039] Figure 1 Schematic diagram of the scenario architecture of the log retrieval method in the embodiment of this application Figure 1 , see Figure 1 As shown, the architecture may include: an application 11 , a log appender 12 , multiple servers 13 and a preset location 14 .

[0040] The application 11 can be any known program that can provide related services. After the application 11 generates log data, the log appender 12 obtains the log data, obtains related data according to the log appending rules, and stores the related data together with the log data to the server 13.

[0041] The log data here may be data representing user behavior in the application 11 .

[0042] The log appender 12 here can be any known tool for expanding the log data output by the application 11 without modifying the original program code. In practical applications, the log appender 12 can be an Appender. The specific type of the log appender 12 is not limited here.

[0043] The log appending rules herein may be specific rules for expanding the log data output by the application 11. For example, the identifiers of the threads called before and after the log data is generated may be output. The specific content of the log appending rules may be determined based on the actual log content to be appended and is not specifically limited here.

[0044] The relevant data here is the data obtained based on the log append rules.

[0045] After obtaining the relevant data, the log appender 12 stores the log data and the relevant data together in the corresponding server 13 according to the server 13 where the log data originally needs to be stored.

[0046] Log data generated by different business processes within application 11 may be stored on different servers 13 based on different storage requirements. For example, log data generated by process a1 within application 11 is stored on server A, log data generated by process a2 within application 11 is stored on server B, log data generated by process b1 within application 11 is stored on server B, and so on. Therefore, when searching for log data based on search information, the log data stored on each server 13 must first be stored in a preset location 14, and then the log data can be retrieved from that preset location 14 based on the search information.

[0047] In practical applications, the preset location 14 can be any one of the multiple servers 13 or a designated server, or can be other storage media other than the multiple servers 13, such as other servers, the cloud, etc.

[0048] The log retrieval method provided in the embodiment of the present application mainly includes two parts. One part is to store the log data after the application generates it, and the other part is to search the stored log data based on the retrieval information.

[0049] Log data storage can be implemented by dynamically injecting a packetization module into the log appender (Spring) at runtime. This eliminates the need for developers to modify existing code and is compatible with major logging frameworks. In practice, the packetization module can be any module that can retrieve relevant data and package it with the log data for storage, such as the PacketAppenderProxy module.

[0050] Figure 2 Schematic diagram of the scenario architecture of the log retrieval method in the embodiment of this application Figure 2 , see Figure 2As shown, a standardized log packet proxy (PacketAppenderProxy) is dynamically injected into the Appender. For Appender, there are FileAppender, ConsoleAppender and CustomAppender. Before FileAppender, ConsoleAppender or CustomAppender appends the log data generated by the application, the asynchronous Appender basic interface definition (UnsynchronizedAppenderBase) is used to make PacketAppenderProxy call the proxy method, that is, the packet() method, to standardize the log data before FileAppender, ConsoleAppender or CustomAppender executes the append() method. That is, the log data, thread identifier, calling method input / output data, etc. are first packaged, and then the packaged data is appended to the log and finally stored on the server.

[0051] It should be noted here that the relevant data and its related processing methods, as well as the related software and related hardware equipment involved in the embodiments of this application have all been authorized in advance and are legal and compliant.

[0052] Next, the log retrieval method provided in the embodiment of the present application is described in detail.

[0053] Figure 3 The process diagram of the log retrieval method in the embodiment of this application is as follows Figure 1 , see Figure 3 As shown, the method may include:

[0054] S31: Acquire search information.

[0055] The retrieval information here refers to the information that personnel enter when searching for specific log data within an application. In practice, the retrieval information can be determined based on the log data actually required. For example, if an operator needs to search for all log data related to a particular order using shopping software, the retrieval information could be the order number. The specific content and format of the retrieval information are not limited here.

[0056] S32: Retrieve a target log package from the log packages of multiple servers corresponding to the application program according to the retrieval information.

[0057] Each log package of each server includes log data generated by a corresponding link of a corresponding business of the application, an identifier of a thread used by the application when the log data is generated, and input data and output data of a called method.

[0058] When a particular step in a business node of an application generates log data, the packaging module obtains the thread identifier of the thread invoked during the execution of that step, as well as the input and output data of the invoked method. It then packages the log data, thread identifier, and input and output data into a log package. The log package is then appended to the log package by a log appender and stored on the server where the log data was originally stored. In this way, the multiple servers corresponding to the application store log packages corresponding to different steps in different business operations of the application.

[0059] The thread identifier may refer to a thread number or other identifier that can uniquely identify different threads, such as data features processed by the thread. The specific type of the thread identifier is not limited here.

[0060] The input and output data of a method call can refer to the input and output data of the current step. For example, in the payment discount step of a shopping app, the input data is the order amount, and the output data is the amount to be paid.

[0061] Log packages from each server are pre-stored in a preset location for future retrieval. This preset location can be a database. The specific contents of the preset location are not limited here.

[0062] After obtaining the search information, it can be matched against all stored log packages in sequence. The log package that successfully matches is the target log package. A match here can mean that the search information and the log package are consistent in content or have the same fields. Specifically, the search information can be matched against the log data in the log package, or against the thread identifier, input data, and output data of the calling method in the log package.

[0063] The log package that is successfully matched is the target log package. If multiple log packages are matched, all of them are target log packages.

[0064] However, in some cases, the retrieval information cannot match all the required log packages. For example, when you need to retrieve the log data of a payment for an order, the retrieval information is the order number of the order. The payment business includes three links: transaction, settlement, and clearing. It is possible that only the log data of the transaction link carries the order number. If you search by the order number, you can only retrieve the log data of the transaction link and the log data of non-payment services (such as order inquiry services), resulting in incomplete log data retrieval and retrieval errors. At this time, you need to further search in all log packages based on the content in the retrieved target log package.

[0065] S33: Retrieve an extended log package from the log packages of the multiple servers according to the identifier, input data, and output data in the target log package.

[0066] When different parts of the same business in an application are running, they all invoke the same thread. After retrieving the target log package based on the search information, other log packages with the same thread ID as the target log package may be other parts of the same business as the part corresponding to the target log package. Therefore, the log package with a successful thread ID matching the thread ID in the target log package among all log packages can be used as an extended log package.

[0067] Furthermore, between upstream and downstream links of the same business within an application, the output data and input data are identical. That is, the output data of the previous link serves as the input data for the next link. Therefore, the input data in the target log packet is matched against the output data of all other log packets. The log packet that successfully matches this is the log packet from the previous link, or extended log packet. The output data in the target log packet is matched against the input data of all other log packets. The log packet that successfully matches this is the log packet from the next link, or extended log packet.

[0068] After an extended log package is matched based on the input data and output data in the target log package, log package matching can continue based on the input data or output data in the extended log package. The matched log package is also an extended log package until no log package is matched.

[0069] The log packages matched based on the thread identifier, input data, and output data in the target log package may contain some unnecessary log packages that are not actually needed. The actually needed log packages will match the thread identifier and input or output data in the target log package. Therefore, the extended log package matched based on the thread identifier and the same log package in the extended log packages matched based on the input and output data can be used as the final extended log package to achieve precise expansion based on the target log package.

[0070] In order to improve the retrieval efficiency of extended log packages, and thus the efficiency of log retrieval, it is also possible to first determine the pending log package based on the input data and output data in the target log package, and then determine the extended log package in the pending log package based on the thread identifier in the target log package. In this way, the number of log package matches during log package retrieval can be reduced, and the matching efficiency of log packages can be improved. Of course, it is also possible to first determine the pending log package based on the thread identifier in the target log package, and then determine the extended log package in the pending log package based on the input data and output data in the target log package. The order of thread identifier matching and input data and output data matching is not limited here. Ultimately, it is sufficient to quickly match the extended log package.

[0071] S34: Determine the target log package and the extended log package as log packages corresponding to the search information.

[0072] The target log package is the log package directly retrieved from all log packages based on the search information. Generally speaking, it is the log package actually required for the search information. The extended log package is the log package retrieved from all log packages based on the target log package. It is the log package indirectly retrieved from all log packages based on the search information and serves as a supplement to the target log package. Therefore, identifying the target log package and the extended log package as the log packages corresponding to the search information enables complete retrieval of the required logs.

[0073] As can be seen from the above, the log retrieval method provided by the embodiments of the present application stores the thread identifier that generated the log data, as well as the input and output data of the calling method, at the same time as the log data. This allows, when retrieving log data based on the retrieval information, to find the associated log data based on the thread identifier carried in the retrieved log data and the input and output data of the calling method, thus achieving a comprehensive search of the log data required for the retrieval information and improving the integrity of the log retrieval.

[0074] Furthermore, as a Figure 3 As a refinement and extension of the method shown, an embodiment of the present application also provides a log retrieval method.

[0075] Figure 4 The process diagram of the log retrieval method in the embodiment of this application is as follows Figure 2 , see Figure 4 As shown, the method may include two parts, namely, log storage and log retrieval.

[0076] 1. Log Storage

[0077] S41: Obtain target log data generated by a target link of a target business of an application.

[0078] When each business link in an application runs, it outputs corresponding log data based on the configuration configured by the developer. The log data generated by user operations in a specific business link of the application is the target log data generated by the target link of the target business of the application.

[0079] On the application server side, a log appender is configured to append logs without modifying the original code. However, to enable complete log retrieval, the thread identifier and the input and output data of the calling method must be stored alongside the log data. This requires further improvements to the log appender, namely, the dynamic injection of a packaging module into the log appender. The packaging module is used to perform standardized packaging on the log data generated by the application before the log appender appends the log data. Specifically, the log data, thread identifier, and the input and output data of the calling method are packaged before appending the log data and subsequently storing the log data.

[0080] Specifically, the above step S41 may include: in response to calling the log append method, obtaining log data corresponding to the log append method, and determining the obtained log data as target log data generated by the target link of the target business of the application.

[0081] After the log appender obtains the log data generated by the application, it will start calling the log append method to append the log data. After the packaging module is injected into the log appender, it will monitor the call of the log append method in the log appender. Once the log appender is monitored to call the log append method, it means that the log appender has obtained the log data generated by the application. At this time, the packaging module intercepts the log data. The intercepted log data is the target log data to be standardized and packaged. The packaging module adds the thread identifier and the input and output data of the calling method to the log data, obtains the log package after packaging, and feeds the log package back to the log appender, so that the log appender calls the log append method to append the log package, and then stores the log package after log appending to the corresponding server.

[0082] As for the monitoring of the log append method call and the interception of log data by the packaging module, known monitoring methods and interception methods are adopted, which will not be described in detail here.

[0083] S42: Obtain the identifier of the thread used by the application program when the target log data is generated, as well as the input data and output data of the called method.

[0084] S43: Encapsulate the target log data, identifier, input data, and output data into a log package.

[0085] In an application, different parts of the same business run on the same thread. The output data of the method called in the previous part is the same as the input data of the method called in the next part.

[0086] Generally speaking, when a service in an application runs, it invokes a thread. This thread is used throughout all phases of the service. For example, when a user makes a payment in a shopping app, the transaction, settlement, and clearing stages all use the same thread. Therefore, the thread invoked when the application generates log data is the thread for the phase and service to which the log data pertains. By storing this thread identifier within the log data package, logs belonging to the same service can be found using the thread identifier during log retrieval.

[0087] After the packaging module obtains the target log data, it searches for the corresponding thread in the application through the target log data. The ID of the thread found is the ID of the thread used by the application when the target log data to be obtained this time was generated.

[0088] When obtaining the thread ID, it is also necessary to obtain the input data and output data of the method called by the application when the target log data is generated.

[0089] Specifically, after the packaging module obtains the target log data, it searches for the corresponding call method in the application program. The input and output data corresponding to the found call method are the input and output data of the method called by the application program when the target log data to be obtained is generated.

[0090] Taking shopping software as an example, when a user makes a payment, the payment service involves a discount link. The discount link generates log data. After the packaging module obtains the log data, it finds the thread of the discount link based on the obtained log data, and then determines through the thread that the discount link calls the discount method (which can be understood as the use of a coupon). The input data of the discount method is the order amount, and the output data of the discount method is the actual amount to be paid. In this way, the input data and output data of the method called when the application generates log data are obtained. The input data and output data of the called method are packaged and stored with the log data, so that when searching the logs, the input data and output data can be used to find the logs of the upper and lower links of the same business.

[0091] The input and output data at this point serve as the output data of the previous link and the input data of the next link before the current link. During log retrieval, they can only be associated with adjacent links. If a business involves many links, a single association may not be enough to retrieve logs for all links involved. Therefore, the input and output data of method calls from different links within the same business can be stored together. This allows the input and output data of all previous links to be packaged together when the log data for each link is packaged. This allows logs for all links to be retrieved with a single association during retrieval.

[0092] Specifically, the above step S42 may further include: storing the input data and the output data in the thread set corresponding to the identifier, so that the input data and the output data can be encapsulated together when the log data generated by the next link of the target link is encapsulated.

[0093] Accordingly, the above step S43 may include: encapsulating the target log data, the identifier, the input data and the output data in the thread set into a log package.

[0094] For example, suppose an application's business includes steps a, b, c, and d. Step a generates log data a. The input data of the method called by step a is data 1, and the output data is data 2. Step b generates log data b. The input data of the method called by step b is data 2, and the output data is data 3. Step c generates log data c. The input data of the method called by step c is data 3, and the output data is data 4. Step d generates log data d. The input data of the method called by step d is data 4, and the output data is data 5.

[0095] First, the packaging module receives log data a. Based on log data a, the packaging module identifies thread x, as well as input data 1 and output data 2. The packaging module packages and stores log data a, thread x, and data 1 and data 2. It also creates a collection for thread x and stores data 1 and data 2 in the collection.

[0096] The packaging module then obtains log data b. Based on log data b, the packaging module determines thread x, as well as data 2 and data 3. The packaging module packages and stores data 1, data 2, and data 3 based on log data b, thread x, and data 1, data 2, and data 3, and also stores data 2 and data 3 in the collection of thread x.

[0097] Next, the packaging module receives log data c. Based on log data c, the packaging module identifies thread x, as well as data 3 and data 4. The packaging module packages and stores data 1, data 2, data 3, and data 4 based on log data c, thread x, and data 1, data 2, data 3, and data 4, while also storing data 3 and data 4 in the collection of thread x.

[0098] Finally, the packaging module receives log data d. Based on log data d, the packaging module identifies thread x, as well as data 4 and data 5. The packaging module packages and stores data 1, data 2, data 3, data 4, and data 5 based on log data d, thread x, and data 1, data 2, data 3, data 4, and data 5, and also stores data 4 and data 5 in the collection of thread x.

[0099] At this time, the server stores log package a (log data a, thread x, data 1 and data 2), log package b (log data b, thread x, data 1, data 2 and data 3), log package c (log data c, thread x, data 1, data 2, data 3 and data 4), and log package d (log data d, thread x, data 1, data 2, data 3, data 4 and data 5).

[0100] When data 4 is included in the retrieval information, although direct retrieval can only retrieve log package c and log package d, log package a, log package b and log package d can also be indirectly retrieved through thread x, data 1, data 2, data 3 or data 5 in log package c and log package d, thereby realizing complete log retrieval of all links of the same business.

[0101] While packaging the input and output data of the called method with the log data, the key server parameters of the current code execution point of the application can also be packaged together. This allows you to directly lock the corresponding server when tracing through the log, thereby improving problem solving efficiency.

[0102] Specifically, the above step S42 may further include: obtaining characterization information of a server corresponding to the storage of the target log data.

[0103] Accordingly, the above step S43 may include: encapsulating the target log data, the identifier, the input data, the output data, and the representation information into a log package.

[0104] The characterization information here can be the server's Internet Protocol (IP) address, actual name, distributed node name, database name, table name, transaction name, etc., as long as it can uniquely characterize the server, and the specific content is not limited here.

[0105] Because different code executions in an application correspond to different servers, the correspondence between code and server can be preconfigured and stored in a specific location. After acquiring the target log data, the packaging module determines the current code execution point in the application based on the target log data. Furthermore, using the stored correspondence, it determines the server corresponding to the current code execution point, thereby obtaining the server's representation information from the server's configuration information. The packaging module then sequentially packages the target log data, along with its corresponding thread identifier, the input and output data of the calling method, and the server's representation information.

[0106] When obtaining the thread identifier, thread set and server characterization information corresponding to the target log data, the packaging module packages the target log data and its corresponding thread identifier, all data in the thread set and the server characterization information to obtain a log package.

[0107] In practical applications, log packages can be encapsulated into standard JSON format. The specific format of the log package can be determined based on actual needs and is not specified here.

[0108] S44: The log package is stored in the server corresponding to the target log data.

[0109] After the packaging module plans to encapsulate the log package, the log package is appended by the log appender. The log package after log appending will be stored by the log appender on the server where the target log data is originally configured to be stored.

[0110] In this way, the standardized packaging, log appending, and storage of the target log data are completed, so that the complete log of a certain business can be retrieved based on the search information.

[0111] 2. Log Retrieval

[0112] S45: Acquire search information.

[0113] When the relevant personnel need to perform log retrieval, the relevant personnel inputs retrieval information, so that the log data required by the relevant personnel can be retrieved through the retrieval information.

[0114] The specific search information needs to be set by relevant personnel based on actual needs. The specific content of the search information is not limited here.

[0115] Log packages from multiple servers are pre-stored in a preset location. Once the search information is obtained, all log packages can be searched within that preset location based on the search information. During the search, the search information can be matched against the log data in the log package. If a match is successful, the log package corresponding to the matched log data is the target log package.

[0116] When searching log packets based on search information, in some cases, it's necessary to first segment the search information. However, if the segmentation is too detailed, the search volume will be large and a large amount of content will be retrieved, some of which may not be what you need. Therefore, before segmenting the search information, you can first verify its completeness.

[0117] S46: Determine whether the search information is consistent with the words in the preset custom dictionary. If yes, execute S47; if not, execute S48.

[0118] The terms in the custom dictionary are composed of the names of methods called by the application. As each business process within the application runs, the corresponding methods are called. These method names are extracted and stored in the custom dictionary. This ensures that the terms stored in the custom dictionary are semantically complete within the application. Using these terms to search log data ensures that the search keywords are neither too short, which would increase the number of searches and the amount of content retrieved, nor too long, which would result in missing content.

[0119] When specifically judging whether they are consistent, if the search information is the same as a word in the custom dictionary, it is determined that the search information is consistent with the words in the preset custom dictionary. For example: the search information is "NetEase Cloud Music e-voucher", and the custom dictionary includes the word "NetEase Cloud Music e-voucher". If part of the content in the search information is the same as a word in the custom dictionary, it is determined that the search information is inconsistent with the words in the preset custom dictionary. For example: the search information is "NetEase Cloud Music e-voucher", and the custom dictionary includes the word "NetEase Cloud Music". At this time, the search information can be split into "NetEase Cloud Music" and "e-voucher". If part of the content of the search information is the same as a word in the custom dictionary, it is determined that the search information is inconsistent with the words in the preset custom dictionary. For example: the search information is "NetEase Cloud Music", and the custom dictionary includes the word "NetEase Cloud Music e-voucher". At this time, the search information is split according to conventional semantics to obtain "NetEase", "Cloud", and "Music".

[0120] It can be seen that the match between the search information here and the words in the preset custom dictionary is an exact match.

[0121] S47: Retrieve a target log package containing the retrieval information from the log packages of the multiple servers corresponding to the application program.

[0122] If the search information matches a word in the custom dictionary, it indicates that the search information is accurate and the word is neither too long or too specific, nor too short or too general. You can directly use the search information to match the log data of all stored log packages. The log package that successfully matches is the target log package.

[0123] S48: performing word segmentation processing on the search information to obtain multiple word segments, and retrieving a target log package containing each word segment from the log packages of multiple servers corresponding to the application program.

[0124] The search information is different from all the words in the custom dictionary, indicating that there are certain differences between the search information and the log data. In this case, you need to first segment the search information according to semantics to obtain multiple segments. Then, match each segment with the log data in all log packets. The log packet corresponding to the successfully matched log data is the target log packet.

[0125] After retrieving the target log package, since it may not be possible to directly and completely retrieve all the log packages actually required through the retrieval information, you can continue to search again in all the stored log packages through the thread identifier in the target log package and the input data and output data of the calling method to obtain the extended log package.

[0126] In some cases, the search information might reveal log packages for not just one service, but multiple services. However, only the log package for one service is actually needed. For example, if the search information is an order number, the log package for the payment service might be retrieved based on the order number, as well as log packages for the inquiry service and the refund service. In reality, the user only needs to retrieve log packages for the payment service based on the order number. In this case, relevant information can be displayed to facilitate filtering by relevant personnel.

[0127] S49: Determine whether the number of target log packets exceeds a preset threshold. If yes, execute S410-S412; if no, execute S413.

[0128] S410: Grouping target log packages with the same identifier into one category, obtaining and outputting multiple target log package sets.

[0129] S411: Selecting a designated target log package set from multiple target log package sets according to the selection result of the target log package set.

[0130] S412: Retrieve an extended log package from the log packages of the multiple servers according to the identifier, input data, and output data in each target log package in the specified target log package set.

[0131] S413: Retrieve an extended log package from the log packages of multiple servers according to the identifier, input data, and output data in the target log package.

[0132] The preset threshold value may be determined based on the average number or maximum number of links included in different businesses, and is not specifically limited here.

[0133] After obtaining the target log package, if the number of target log packages exceeds the preset threshold, and the number of links corresponding to a business is limited, and thus the corresponding log packages are limited, it means that the target log package involves multiple businesses, and log packages beyond the actual requirements may have been obtained.

[0134] At this time, according to the thread identifier in the target log package, based on the different threads used by different services, the target log packages of the same service corresponding to the same thread identifier are classified into one category to obtain multiple target log package sets.

[0135] Then, multiple target log package sets can be output directly to relevant personnel so that they can select the target log package corresponding to the business they actually need. They can also obtain corresponding businesses through multiple target log package sets, and then output each business name to relevant personnel so that they can make a selection based on the displayed business names, and then output the final target log package set based on the selection of the relevant personnel.

[0136] If the number of target log packages does not exceed the preset threshold, it means that the target log packages do not involve many businesses and may be the log packages actually required.

[0137] At this time, the extended log package with the same thread identifier, input data, and output data can be directly retrieved from all log packages according to the thread identifier, input data, and output data in the target log package.

[0138] S414: Determine the target log package and the extended log package as log packages corresponding to the search information.

[0139] The target log package is a log package directly retrieved from the log data of all stored log packages based on the search information, meeting the search requirements. The extended log package is a log package retrieved from the thread identifier, input data, and output data of all stored log packages based on the thread identifier, input data, and output data of the calling method in the target log package. This supplementary search can compensate for the missing target log package based on the search requirements. The target log package and the extended log package provide more complete search feedback for the search information, and thus serve as the log package corresponding to the search information.

[0140] In actual applications, after retrieving the target log package based on the retrieval information, and retrieving the extended log package based on the target log package, the target log package and the extended log package can be displayed separately in a preset template so that relevant personnel can clearly obtain which log packages are directly retrieved based on the retrieval information and which log packages are obtained by extended retrieval.

[0141] In addition, in the template, the log data, thread parameters, input data and output data of the calling method, server parameters, etc. in the target log package, as well as the log data, thread parameters, input data and output data of the calling method, server parameters, etc. in the extended log package can be displayed separately to comprehensively and clearly display the search results.

[0142] At this point, the log retrieval method provided in the embodiments of the present application has been fully described.

[0143] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present application further provides a log retrieval device.

[0144] Figure 5 This is a schematic diagram of the structure of the log retrieval device in the embodiment of the present application. Figure 1 , see Figure 5 As shown, the device may include: an acquisition module 51, a retrieval module 52, an expansion module 53 and a determination module 54.

[0145] The acquisition module 51 is used to acquire search information.

[0146] The retrieval module 52 is used to retrieve a target log package from the log packages of multiple servers corresponding to the application according to the retrieval information, wherein each log package of each server includes the log data generated by the corresponding link of the corresponding business of the application, the identifier of the thread used by the application when the log data is generated, and the input data and output data of the called method.

[0147] The extension module 53 is configured to retrieve an extended log package from the log packages of multiple servers according to the identifier, input data and output data in the target log package.

[0148] The determination module 54 is configured to determine the target log package and the extended log package as log packages corresponding to the search information.

[0149] Furthermore, as a Figure 5 As a refinement and extension of the device shown, an embodiment of the present application further provides a log retrieval device.

[0150] Figure 6 This is a schematic diagram of the structure of the log retrieval device in the embodiment of the present application. Figure 2 , see Figure 6 As shown, the device may include: a log acquisition module 61, a data acquisition module 62, a packaging module 63, a storage module 64, an information acquisition module 65, a retrieval module 66, an interaction module 67, an expansion module 68 and a determination module 69.

[0151] The log acquisition module 61 is used to acquire target log data generated by a target link of a target business of an application.

[0152] The log acquisition module 61 is specifically configured to acquire log data corresponding to the log append method in response to calling the log append method, and determine the acquired log data as target log data generated by a target link of a target business of the application program.

[0153] The data acquisition module 62 is used to obtain the identifier of the thread used by the application when the target log data is generated, as well as the input data and output data of the called method. Among them, different links of the same business in the application use the same thread when running, and the output data of the method called in the previous link is the same as the input data of the method called in the next link.

[0154] The data acquisition module 62 is further configured to store the input data and the output data in the thread set corresponding to the identifier, so that the input data and the output data can be packaged together when the log data generated by the next link of the target link is packaged.

[0155] The data acquisition module 62 is further configured to acquire representation information of the server storing the target log data.

[0156] The packaging module 63 is used to package the target log data, identifier, input data and output data into a log package.

[0157] The packaging module 63 is further configured to package the target log data, the identifier, the input data and the output data in the thread set into a log package.

[0158] The packaging module 63 is further configured to package the target log data, identifier, input data, output data, and representation information into a log package.

[0159] The storage module 64 is used to store the log package in the server corresponding to the target log data.

[0160] The information acquisition module 65 is used to acquire search information.

[0161] The retrieval module 66 is used to retrieve a target log package from the log packages of multiple servers corresponding to the application according to the retrieval information, wherein each log package of each server includes the log data generated by the corresponding link of the corresponding business of the application, the identifier of the thread used by the application when the log data is generated, and the input data and output data of the called method.

[0162] The retrieval module 66 is specifically used to retrieve a target log package containing the retrieval information from the log packages of multiple servers corresponding to the application if the retrieval information is consistent with the words in the preset custom dictionary, wherein the words in the custom dictionary are composed of the method names called by the application; if the retrieval information is inconsistent with the words in the preset custom dictionary, the retrieval information is segmented to obtain multiple segmented words, and a target log package containing each segmented word is retrieved from the log packages of multiple servers corresponding to the application.

[0163] The interactive module 67 is used to classify target log packages with the same identifier into one category if the number of target log packages exceeds a preset threshold, obtain and output multiple target log package sets; and select a specified target log package set from the multiple target log package sets based on the selection result of the target log package set.

[0164] The expansion module 68 is configured to retrieve an extended log package from the log packages of multiple servers according to the identifier, input data, and output data in the target log package.

[0165] The extension module 68 is further configured to retrieve an extended log package from the log packages of the multiple servers according to the identifier, input data and output data in each target log package in the specified target log package set.

[0166] The determination module 69 is configured to determine the target log package and the extended log package as log packages corresponding to the search information.

[0167] It should be noted that the description of the above device embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0168] Based on the same inventive concept, an embodiment of the present application also provides an electronic device.

[0169] Figure 7 This is a schematic diagram of the structure of the electronic device in the embodiment of the present application, see Figure 7 As shown, the electronic device may include: a processor 71, a memory 72, and a bus 73. The processor 71 and the memory 72 communicate with each other through the bus 73. The processor 71 is used to call program instructions in the memory 72 to execute the methods in one or more of the above embodiments.

[0170] It should be noted that the description of the electronic device embodiment above is similar to the description of the method embodiment above, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the electronic device embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0171] Based on the same inventive concept, an embodiment of the present application further provides a computer-readable storage medium, which may include: a stored program that controls the device where the storage medium is located to execute the method in one or more of the above embodiments when the program is running.

[0172] It should be noted that the description of the above computer-readable storage medium embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the computer-readable storage medium embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0173] Based on the same inventive concept, an embodiment of the present application further provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are executed by the device where they are located, the method in one or more of the above embodiments is implemented.

[0174] It should be noted that the description of the above computer program product embodiment is similar to the description of the above method embodiment and has similar beneficial effects as the method embodiment. For technical details not disclosed in the computer program product embodiment of this application, please refer to the description of the method embodiment of this application for understanding.

[0175] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A log retrieval method, characterized in that: The method comprises: Get search information; Retrieving a target log package from the log packages of multiple servers corresponding to the application according to the retrieval information, wherein each log package of each server includes log data generated by a corresponding link of a corresponding business of the application, an identifier of a thread used by the application when the log data is generated, and input data and output data of a called method; Retrieving an extended log package from the log packages of the multiple servers according to the identifier, input data, and output data in the target log package; The target log package and the extended log package are determined as log packages corresponding to the search information.

2. The method according to claim 1, characterized in that Before obtaining the search information, the method further includes: Obtain target log data generated by a target link of a target business of the application; Obtaining the identifier of the thread used by the application when the target log data is generated, as well as the input data and output data of the called method, wherein different links of the same business in the application use the same thread when running, and the output data of the method called in the previous link is the same as the input data of the method called in the next link; Encapsulating the target log data, the identifier, the input data, and the output data into a log package; The log package is stored in the server corresponding to the target log data.

3. The method according to claim 2, characterized in that Before encapsulating the target log data, the identifier, the input data, and the output data into a log package, the method further includes: Storing the input data and output data in the thread set corresponding to the identifier so that the input data and output data can be encapsulated together when encapsulating log data generated by the next link of the target link; The step of encapsulating the target log data, the identifier, the input data, and the output data into a log package includes: The target log data, the identifier, the input data and the output data in the thread set are encapsulated into a log package.

4. The method according to claim 2, characterized in that Before encapsulating the target log data, the identifier, the input data, and the output data into a log package, the method further includes: Obtaining representation information of a server corresponding to storage of the target log data; The step of encapsulating the target log data, the identifier, the input data, and the output data into a log package includes: The target log data, the identifier, the input data and output data, and the representation information are encapsulated into a log package.

5. The method according to claim 2, characterized in that The target log data generated by the target link of the target business of the application is obtained, including: In response to calling the log append method, log data corresponding to the log append method is obtained, and the obtained log data is determined as target log data generated by a target link of a target business of the application.

6. The method according to any one of claims 1 to 5, characterized in that The step of retrieving a target log package from log packages of multiple servers corresponding to the application program according to the retrieval information includes: If the search information is consistent with a word in a preset custom dictionary, a target log package containing the search information is retrieved from log packages of multiple servers corresponding to the application, wherein the words in the custom dictionary are composed of method names called by the application; If the search information is inconsistent with the words in the preset custom dictionary, the search information is segmented to obtain multiple segmented words, and a target log package containing each segmented word is retrieved from the log packages of multiple servers corresponding to the application.

7. The method according to any one of claims 1 to 5, characterized in that Before retrieving an extended log package from the log packages of the multiple servers according to the identifier, input data, and output data in the target log package, the method further includes: If the number of target log packets exceeds a preset threshold, the target log packets with the same identifier are grouped into one category, and multiple target log packet sets are obtained and output; Selecting a specified target log package set from multiple target log package sets according to the selection result of the target log package set; The step of retrieving an extended log package from the log packages of the multiple servers according to the identifier, input data, and output data in the target log package includes: An extended log package is retrieved from the log packages of the multiple servers according to the identifier, input data, and output data in each target log package in the specified target log package set.

8. A log retrieval device, characterized in that: The device comprises: Acquisition module, used to obtain retrieval information; a retrieval module, configured to retrieve a target log package from the log packages of multiple servers corresponding to the application according to the retrieval information, wherein each log package of each server includes log data generated by a corresponding link of a corresponding business of the application, an identifier of a thread used by the application when the log data is generated, and input data and output data of a called method; An extension module, configured to retrieve an extended log package from the log packages of the plurality of servers according to the identifier, input data, and output data in the target log package; A determination module is used to determine the target log package and the extended log package as the log packages corresponding to the search information.

9. An electronic device, characterized in that: The electronic device includes: a processor, a memory, and a bus; wherein the processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The storage medium includes: a stored program; wherein, when the program is running, the device where the storage medium is located is controlled to execute the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for outputting storage process log

    CN111858247A

  • Context-aware feature embedding and anomaly detection of sequential log data using deep recurrent neural networks

    CN113190843A

  • Recording and analyzing method for request logs in distributed environment

    CN114610689A

  • Log query method and device

    CN117807027A

  • Trace management

    US20180203795A1