Log retrieval method, device, electronic device, and storage medium

By adding a unique identification code during the log printing process, the problems of low log pickup efficiency and missing data in the existing technology are solved, and fast and efficient target log pickup is achieved.

CN114385401BActive Publication Date: 2025-08-15CHINA PING AN LIFE INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210029840.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-12
Publication Date
2025-08-15
Estimated Expiration
2042-01-12

AI Technical Summary

Technical Problem

The prior art is inefficient when fetching target logs and is prone to missing important data, especially in the process of multiple interfaces calling, it is difficult to accurately locate strings that run through all interfaces.

Method used

Add a unique identification code during the log printing process, generate the unique identification code of the client through the service framework, and print the identification code in the log through the subclass of the log printing interface to achieve rapid positioning and picking up the target log.

Benefits of technology

It improves the efficiency and accuracy of log pickup, reduces the possibility of missing important evidence and data, and simplifies the multi-interface call process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385401B_ABST
    Figure CN114385401B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computing and processing technology, and provides a log retrieval method, device, electronic device and storage medium, the method comprising: respectively initializing the classes on the service framework of multiple clients to obtain the unique identification code corresponding to each client; respectively obtaining at least one log printing interface of each client according to the log printing signal, and obtaining the subclass of the log printing interface; printing the log of the log printing interface through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes; and retrieving the log from multiple logs with corresponding unique identification codes through the unique identification code corresponding to each client to obtain the target log. The technical solution of the embodiment of the present application can print out a log with a unique identification code, and can quickly and accurately retrieve the target log from the full-link log through the unique identification code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer processing technology, and more specifically, to a log retrieval method, device, electronic device, and storage medium. Background Art

[0002] Software testing can verify the quality, performance and reliability of software, discover more defects faster, locate and solve defects faster and better, thereby ensuring the quality of software.

[0003] Common testing methods include unit testing, integration testing, system testing, joint debugging testing, and performance testing. Regardless of the testing method, after discovering a defect during testing, locating the defect requires reviewing and analyzing logs. Currently, extracting target logs (e.g., extracting logs related to defect data from a large number of logs) often involves using grep (Globally Search a Regular Expression and Print, a text search tool) to view logs for the entire chain. For example, if interface A is called at a certain time, and interface A calls interface B and interface C in turn, interface B also calls interface D, and interface C also calls interface E, then to retrieve logs related to this call, the following steps need to be repeated for the above interfaces (ABCDE) in the order in which they are called: analyze the interface input parameters, find a string that can be found throughout the entire interface processing process, and then use grep to retrieve the target logs.

[0004] Because this log extraction method extracts logs from multiple interfaces, it needs to locate a string that runs through all interfaces. The string extraction process is cumbersome, time-consuming, and inefficient. In addition, not only is it difficult to locate the string that runs through all interfaces, but there may also be situations where a certain interface does not have an input parameter that can serve as the string. In this case, it is difficult to accurately extract logs through this interface, and important evidence and data may be missed. Summary of the Invention

[0005] To solve the above technical problems, the embodiments of the present application provide a log retrieval method and device, an electronic device, and a computer-readable storage medium, which add a unique identification code to the printed log to facilitate log retrieval and viewing.

[0006] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by practice of the present application.

[0007] According to one aspect of an embodiment of the present application, a log retrieval method is provided, comprising: initializing classes on a service framework of multiple clients respectively to obtain a unique identification code corresponding to each client; obtaining at least one log printing interface of each client according to a log printing signal, and obtaining a subclass of the log printing interface, wherein the subclass is a class that inherits the unique identification code corresponding to the client where the log printing interface is located and adds a new attribute; printing the log of the log printing interface through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes; and retrieving logs from the multiple logs with corresponding unique identification codes through the unique identification code corresponding to each client to obtain a target log.

[0008] In one embodiment, the steps of respectively initializing classes on the service framework of the plurality of clients to obtain a unique identification code corresponding to each client include:

[0009] Obtain a character string identifying each client, the character string being a combination of one or more of a timestamp, a random string, a service number, and a client information digest of each client;

[0010] The character strings are deduplicated, and a class on a service framework corresponding to the client is constructed based on the deduplicated character strings to obtain a unique identification code corresponding to each client.

[0011] In one embodiment, the log of the log printing interface is printed by a subclass of the log printing interface to obtain multiple logs with different corresponding unique identification codes, including:

[0012] Obtaining log printing requirements from the corresponding service framework through the log printing interface;

[0013] Print the log of the log printing interface according to the log printing requirement to obtain multiple initial logs;

[0014] The multiple logs with different corresponding unique identification codes are obtained by adding unique identification codes to the multiple initial logs through the subclass of the log printing interface.

[0015] In one embodiment, the log of the log printing interface is printed according to the log printing requirement to obtain multiple initial logs, including:

[0016] determining a log printing level from the log printing requirement;

[0017] The logs of the corresponding level in the log printing interface are printed according to the log printing level to obtain a plurality of initial logs of the corresponding level.

[0018] In one embodiment, the adding of unique identification codes to the multiple initial logs by the subclass of the log printing interface to obtain the multiple logs with corresponding unique identification codes includes:

[0019] Acquire target location information from the log printing request;

[0020] According to the target location information, the unique identification codes corresponding to the subclasses of the log printing interface are respectively added to the target locations in the multiple initial logs, where the target locations are the locations in the multiple initial logs pointed to by the target location information.

[0021] In one embodiment, after adding unique identification codes to the multiple initial logs through the subclass of the log printing interface to obtain the multiple logs with corresponding unique identification codes, the method further includes:

[0022] Obtaining a log printing destination address from the log printing request;

[0023] The plurality of logs with corresponding unique identification codes are stored in the log printing destination address.

[0024] In one embodiment, the process of retrieving a log from the plurality of logs with corresponding unique identification codes using the unique identification code corresponding to each client to obtain a target log includes:

[0025] The unique identification code corresponding to the client whose logs are to be retrieved is used as the target unique identification code;

[0026] Logs are retrieved from the multiple logs with corresponding unique identification codes using the target unique identification code to obtain a target log with the target unique identification code.

[0027] According to one aspect of an embodiment of the present application, a log retrieval device is provided, including: a unique identification code acquisition module, configured to initialize the classes on the service framework of multiple clients respectively to obtain the unique identification code corresponding to each client; a subclass acquisition module, configured to obtain at least one log printing interface of each client according to a log printing signal, and obtain a subclass of the log printing interface, the subclass being obtained by inheriting the class corresponding to the unique identification code of the client where the log printing interface is located and adding a new attribute; a log printing module, configured to print the log of the log printing interface through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes; a log retrieval module, configured to retrieve logs from the multiple logs with corresponding unique identification codes through the unique identification code corresponding to each client to obtain a target log.

[0028] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising one or more processors; and a storage device for storing one or more computer programs. When the one or more computer programs are executed by the one or more processors, the electronic device implements the log retrieval method described above.

[0029] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the log retrieval method described above.

[0030] According to one aspect of an embodiment of the present application, a computer program product or computer program is provided. The computer program product or computer program includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the log retrieval method provided in the various optional embodiments described above.

[0031] In the technical solution provided in the embodiments of the present application, a unique identification code is generated at the service framework layer, and a subclass that inherits the class corresponding to the unique identification code is set for each log printing interface, so that the logs printed through the log printing interface all have a unique identification code. Subsequently, the log corresponding to the unique identification code can be retrieved from the full-link log with only one unique identification code, and the retrieval process is short and efficient.

[0032] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] The accompanying drawings are incorporated into and constitute a part of the specification, illustrating embodiments consistent with the present application and, together with the specification, serving to explain the principles of the present application. It is obvious that the drawings described below are merely some embodiments of the present application, and a person of ordinary skill in the art can derive other drawings based on these drawings without inventive effort. In the drawings:

[0034] Figure 1 It is a schematic diagram of an implementation environment involved in this application;

[0035] Figure 2 is a flow chart of a log retrieval method shown in an exemplary embodiment of the present application;

[0036] Figure 3 yes Figure 2 A flow chart of step S210 in the illustrated embodiment in an exemplary embodiment;

[0037] Figure 4 yes Figure 2 A flow chart of step S250 in the illustrated embodiment in an exemplary embodiment;

[0038] Figure 5 yes Figure 4 A flowchart of step S430 in the illustrated embodiment in another exemplary embodiment;

[0039] Figure 6 yes Figure 4 A flow chart of step S450 in the illustrated embodiment in an exemplary embodiment;

[0040] Figure 7 is a flow chart of a log retrieval method shown in another exemplary embodiment of the present application;

[0041] Figure 8 yes Figure 2 A flow chart of step S270 in the illustrated embodiment in an exemplary embodiment;

[0042] Figure 9 1 is a schematic structural diagram of a log retrieval device according to an exemplary embodiment of the present application;

[0043] Figure 10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0044] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0045] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0046] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.

[0047] It should also be noted that the term "plurality" used in this application refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. The character " / " generally indicates an "or" relationship between the associated objects.

[0048] The log retrieval method and device, electronic device, and storage medium proposed in the embodiments of the present application involve computer processing technology, and these embodiments will be described in detail below.

[0049] First see Figure 1 , Figure 1 The present invention is a schematic diagram of an implementation environment involved in this application. The implementation environment includes a terminal 100 and a server 200, which communicate with each other via a wired or wireless network. The terminal 100 is used to collect a target unique identification code and input the collected target unique identification code into the server 200. The server 200 retrieves the target log from a large number of logs based on the target unique identification code and then sends the target log to the terminal 100. The target log can be visually displayed through the display module provided by the terminal 100.

[0050] Exemplarily, the server side 200 first initializes the classes on the service framework of multiple clients to obtain the unique identification code corresponding to each client, then obtains the log printing interface according to the log printing signal, and obtains the subclass of the log printing interface, which is a class that inherits the unique identification code corresponding to the client where the log printing interface is located and adds a new attribute; the log of the log printing interface is printed through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes; finally, the target unique identification code can be received through the terminal 100, and the terminal 100 sends the target unique identification code to the server side 200, and the server side 200 uses the target unique identification code to retrieve multiple logs with corresponding unique identification codes to obtain the target log.

[0051] The terminal 100 can be any electronic device capable of data visualization, such as a smartphone, tablet, laptop, or computer, and is not limited here. The server side 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, wherein multiple servers can form a blockchain, and the server is a node on the blockchain. The server side 200 can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms, and is not limited here.

[0052] Figure 2 FIG. 1 is a flow chart showing a log retrieval method according to an exemplary embodiment. Figure 2 As shown, in an exemplary embodiment, the method may include steps S210 to S270, which are described in detail as follows:

[0053] Step S210: Initialize the classes on the service framework of multiple clients respectively to obtain the unique identification code corresponding to each client.

[0054] The service framework in this embodiment is a Java service code project. Java is an object-oriented language, and an object is a class. There are many Java classes in the service code project, and a unique identification code is obtained by modifying the class in Java.

[0055] In this embodiment, multiple classes are provided on the service framework, and each class includes its corresponding configuration information. The class can be assigned with the configuration information. When the log is subsequently printed according to the class, the log printing requirements are read from the assignment information of the class to print the log to be printed according to the read log printing requirements.

[0056] Specifically, after obtaining the class on the service framework agreement, in order to obtain a unique identification code, the class attributes need to be initialized in this step. By designing the initialization of the class attributes, a unique identification code is formed. In this step, the class attributes can be designed to generate a unique identification code through deduplication methods such as timestamp + random string, MD5 information digest algorithm (timestamp + random string), MD5 (business id), MD5 (concatenated string of certain parameter fields), etc. When modifying an object of a class, the number obtained in any of the above methods can be used to determine which method to use to generate the unique identification code. Of course, in addition to the above-mentioned method of constructing a class to generate a unique identification code, in this embodiment, developers can also use encapsulation or inheritance methods to customize the unique identification code they need. No specific restrictions are made here.

[0057] In this embodiment, different clients may obtain corresponding unique identification codes that are different, and the unique identification code may uniquely point to a corresponding client.

[0058] Step S230: obtaining the log printing interface of each client according to the log printing signal, and obtaining the subclass of the log printing interface.

[0059] In this embodiment, the service framework provides a unified log printing interface (API), and the framework user (ie, the client user where the service framework is located) directly calls the log printing interface (application programming interface) to print logs.

[0060] In this embodiment, the log that can respond to the server trigger can start log printing according to the log printing signal. First, the log printing interface required for log printing can be obtained according to the log printing signal. The log printing interface can be set according to the user's needs. For example, the interface used by the user can be set to print the log through the log printing interface.

[0061] Of course, a single log print signal can trigger multiple clients to print logs simultaneously. For example, if a team is printing logs for a project, a single log print signal can trigger all clients in the team to print logs simultaneously. Log printing can also be targeted at a single client. A client can have multiple or just one log print interface.

[0062] This embodiment rewrites the log printing method of the subclass to allow access to the parent class. The class corresponding to the unique identification code is the parent class. When printing the log, the log printing interface inherits the parent class and rewrites a subclass by adding an attribute to the parent class. Different log printing interfaces inherit the classification and add different attributes to rewrite corresponding subclasses. Subsequently, log printing is performed through multiple log printing interfaces, each with different subclasses.

[0063] Step S250: Print the log of the log printing interface through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes.

[0064] In this embodiment, based on the log printing interface, log printing requirements can be obtained from the service framework. The log printing requirements may include the log printing level, log printing destination address, log printing format, etc. Each log printing interface prints relevant logs based on the log printing requirements. When printing logs from the log printing interface, since each log printing interface has its own subclass, and the subclass is a rewrite of the class corresponding to the unique identification code, the printed logs will be marked with the corresponding unique identification code.

[0065] For example, the unique identification code obtained for a client A is a. When log printing is performed based on the client service framework, all logs printed through its log printing interface will be marked with the unique identification code a.

[0066] In this embodiment, the log printing destination address can be set by configuring the log printing requirements, so that all printed log outputs are stored in one address, which is convenient for subsequent log retrieval and viewing.

[0067] Step S270: Retrieving logs from the multiple logs with corresponding unique identification codes using the unique identification codes corresponding to each client to obtain target logs.

[0068] In this embodiment, a large number of logs are obtained through the above steps, and the printed logs are all in a folder, and each log has its corresponding unique identification code enclosed in brackets. For example, by printing the logs of all clients of a company at a certain moment, the logs of all clients of the company at a certain moment are obtained, and the logs include logs with unique identification code a of client A, logs with unique identification code b of client B, logs with unique identification code c of client C... When it is necessary to retrieve the log of client B, the unique identification code b is used as the target unique identification code to search among all the obtained logs, and all target logs with unique identification code b are retrieved.

[0069] The log retrieval method proposed in this embodiment can complete the retrieval of full-link logs through a unique identification code, with high efficiency, low cost, and no omission of log information: this method supports the generation of unique identification codes through a service framework, which is completely transparent to the application and business logic layers. In other words, front-end and back-end developers only need to focus on their own professional fields and business needs, without having to think about other things. For example, when a development teacher tests his own business module interface, the existing log retrieval method requires a parameter field that is easy to identify and unique when formulating the interface protocol. This is not only very inconvenient but may also affect the business, and will also bring greater limitations and risks in terms of scalability and compatibility. For example, when development teachers in different business modules conduct joint debugging tests, different businesses may have different log printing styles and development specifications. It is very difficult to perform log retrieval work in the existing way.

[0070] At the same time, the log retrieval method proposed in this embodiment does not require multiple interface calls to retrieve logs, and the retrieval time is fast: since the unique identification code in this embodiment is constructed through the class on the service framework, that is, it is located in the protocol layer of the service framework, for business and application development, when retrieval of logs, there is no need to think about how to bring unique identification information in the log, especially between different business modules. As long as they use the same protocol type, the logs of multiple interfaces can be retrieved in the full-link log through the unique identification code, and there is no need to analyze each other's calls between multiple interfaces to obtain the target log. Using the same protocol type is natural - because business modules must use the same protocol type to communicate.

[0071] In addition, in this embodiment, a unified log printing interface is provided through the service framework, and the log printing interface has subclasses. When the log printing interface is called to print the log, a unique identification code can be automatically added to the log. The logs of all clients of the entire company can be printed through a log printing signal. On the basis of ensuring that the unique identification code is globally unique, the target log can be retrieved from the global log; of course, the method proposed in this embodiment can also be expanded, such as through encapsulation and inheritance, it can also support business developers to customize the complex application scenarios they need.

[0072] Figure 3 yes Figure 2 The flowchart of step S210 in the embodiment shown is in an exemplary embodiment. Figure 3 As shown, in an exemplary embodiment, the process of respectively initializing the classes on the service framework of multiple clients to obtain the unique identification code corresponding to each client may include steps S310 to S330, which are described in detail as follows:

[0073] Step S310: Obtain a character string identifying each client.

[0074] In this embodiment, the character string identifying each client is composed of one or more combinations of the timestamp, random string, business number and client information digest of each client. For example, for client A, the timestamp of the client at a certain moment can be obtained, and the timestamp can be combined with some random strings to obtain the character string identifying client A. Of course, one or more of the client's information digest, business number, etc. can also be combined to obtain the character string identifying the client. No specific restrictions are made here. Finally, unique and different character strings corresponding to different clients can be obtained.

[0075] Step S330: De-duplicate the character strings, construct a class on the service framework of the corresponding client based on the de-duplicated character strings, and obtain a unique identification code corresponding to each client.

[0076] In this embodiment, the strings corresponding to each client are deduplicated to prevent the existence of identical strings that would affect subsequent log retrieval. The deduplicated strings are then used to construct a class on the service framework to obtain a unique identification code corresponding to each client.

[0077] In this embodiment, by obtaining the character string of each client identification, deduplicating the character string and constructing a unique identification code, which is used for subsequent log printing, a log with a unique identification code can be obtained in the end, and the unique identifications corresponding to different clients are different, so that the target log can be retrieved through the unique identification code in the future.

[0078] Figure 4 yes Figure 2 The flowchart of step S250 in the embodiment shown is in an exemplary embodiment. Figure 4 As shown, in an exemplary embodiment, the process of printing the log of the log printing interface through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes may include steps S410 to S450, which are detailed as follows:

[0079] Step S410: Obtaining a log printing request from the corresponding service framework through a log printing interface.

[0080] In this embodiment, after receiving the log printing signal, the log printing interface can be obtained through the service framework, and then the log printing requirements can be obtained from the service framework through the log printing interface. The log printing requirements include the log printing level, log printing destination address and log printing format, etc. The log format can include: date, time, code location, log content, error code, etc.

[0081] Step S430: Print the log of the log printing interface according to the log printing requirement to obtain multiple initial logs.

[0082] In this embodiment, the logs to be printed are searched from each log printing interface according to the log printing requirement, and a plurality of initial logs can be obtained.

[0083] Step S450: adding unique identification codes to the multiple initial logs through the subclass of the log printing interface to obtain multiple logs with different corresponding unique identification codes.

[0084] In this embodiment, after obtaining multiple initial logs, when different initial logs are printed to the destination through each log printing interface, the subclass of each log printing interface will print the corresponding unique identification code in the log. For example, when printing a log through interface 1, the subclass of interface 1 inherits the class corresponding to the unique identification code a, then the logs passing through interface 1 will all be printed with the unique identification code a, and the unique identification code a is also expanded in brackets and printed at any position in each log.

[0085] In this embodiment, through the subclass of the log printing interface, each log printed from the log printing interface is printed with a unique identification code corresponding to the subclass, so that the required target log can be retrieved quickly and efficiently through the unique identification code.

[0086] Figure 5 yes Figure 4 The flowchart of step S430 in the embodiment shown is in an exemplary embodiment. Figure 5 As shown, in an exemplary embodiment, the process of printing the log of the log printing interface according to the log printing requirement to obtain multiple initial logs may include steps S510 to S530, which are described in detail as follows:

[0087] Step S510: Determine the log printing level from the log printing requirement.

[0088] In this embodiment, the log printing level is used to determine the type of print data for this log printing. For example, the log printing levels include ERROR (abnormal conditions that affect the normal operation of the program and the normal operation of the current request), WARN (abnormal conditions that should not occur but do not affect the normal operation of the program and the current request), INFO (system operation information), DEBUG (recording program variables and comments), TRACE (recording complete information during system operation), etc.

[0089] Step S530: Printing the logs of the corresponding level in the log printing interface according to the log printing level to obtain a plurality of initial logs of the corresponding level.

[0090] In this embodiment, the log to be printed is determined by the log printing level. For example, when ERROR information is required, the log printing level is "ERROR", and logs related to "ERROR" are printed, such as failure to open the configuration file, exceptions in third-party docking, etc.; when the log printing level is "WARN", logs related to "WARN" are printed, such as error conditions that occur when there is a fault tolerance mechanism, records of business exceptions, etc.

[0091] In this embodiment, logs of a required level can be accurately printed from the log printing interface through the log printing level.

[0092] Figure 6yes Figure 4 The flowchart of step S450 in the embodiment shown is in an exemplary embodiment. Figure 6 As shown, in an exemplary embodiment, the process of adding unique identification codes to multiple initial logs through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes may include steps S610 to S630, which are detailed as follows:

[0093] Step S610: Acquire target location information from the log printing request.

[0094] In this embodiment, the log printing request is provided with a location where the unique identification code is printed in the log, such as the target location information is included at the beginning of a log line, at the end of a log line, in a log line, etc.

[0095] Step S630: adding the unique identification codes corresponding to the subclasses of the log printing interface to the target locations in the plurality of initial logs respectively according to the target location information.

[0096] In this embodiment, after printing out multiple initial logs using the method proposed in the above embodiment, the unique identification code corresponding to the subclass of the log printing interface is printed at the target position in each initial log according to the target position information. For example, when the target position is at the beginning of the log line, the log printing interface will print the unique identification code enclosed in square brackets at the beginning of each line of log. Of course, the position of the unique identification code can also be printed at the end of the log or at a fixed position in the log. The position is not unique, as long as the corresponding log can be retrieved through the unique identification code, no specific restrictions are made here.

[0097] In this embodiment, the unique identification code is printed in the initial log by setting the target location information, and the corresponding log can be accurately retrieved later by the unique identification code.

[0098] Figure 7 FIG. 1 is a flow chart illustrating a log retrieval method according to another exemplary embodiment. Figure 7 As shown, in an exemplary embodiment, the method can be implemented in Figure 4 After step S450 in the method, the method may include steps S710 to S730, which are described in detail as follows:

[0099] Step S710: Obtain the log printing destination address from the log printing request.

[0100] In this embodiment, when log printing is performed through the log printing interface, the log printing destination address is obtained from the log printing request. The log printing destination addresses corresponding to different log printing interfaces may be the same or different.

[0101] Of course, in order to facilitate the subsequent log retrieval, the destination of a single log printing can be set to the same. For example, when printing logs to multiple clients, the log printing destination address can be set to a certain folder A in the log printing request under the service framework of the multiple clients. In this way, the multiple logs with corresponding unique identification codes obtained this time can be stored in a certain folder A, and the target log can be retrieved in folder A through the unique identification code.

[0102] Step S730: storing multiple logs with corresponding unique identification codes in the log printing destination address.

[0103] In this embodiment, the log with the unique identification code printed out by the log printing interface is stored in the log printing destination address corresponding to the log printing interface. Different log printing destination addresses have different storage locations for different logs.

[0104] Of course, in this embodiment, by setting the log printing destination address, all logs can be printed out at the same address, which is convenient for subsequent retrieval of logs at the address through a unique identification code.

[0105] In this embodiment, by setting the log printing destination address, all printed log outputs can be stored in one address, such as a folder, to facilitate subsequent retrieval and viewing of the logs.

[0106] Figure 8 yes Figure 2 The flowchart of step S270 in the embodiment shown is in an exemplary embodiment. Figure 8 As shown, in an exemplary embodiment, the process of retrieving logs from the multiple logs with corresponding unique identification codes using the unique identification codes corresponding to each client to obtain the target log may include steps S810 to S830, which are described in detail as follows:

[0107] Step S810: The unique identification code corresponding to the client whose logs are to be retrieved is used as the target unique identification code.

[0108] In this embodiment, the printed logs are all stored in the corresponding addresses. For example, for log printing requests with the same log printing destination address, the printed logs are stored in a folder. Since the printed logs will print out a unique identification code enclosed in brackets, the required target log can be obtained through the unique identification code. For example, for a company, a client can correspond to a unique identification code. During the printing process, the logs printed for all log printing requests of the company are all in a folder. Logs with different unique identification codes are printed in the folder. When it is necessary to retrieve the log of client A from the printed log with the unique identification code, the unique identification code of client A is a, and the target unique identification code can be set to a.

[0109] Step S830: Retrieving a log from multiple logs with corresponding unique identification codes using the target unique identification code to obtain a target log with the target unique identification code.

[0110] In this embodiment, all logs of the company with unique identification codes are retrieved using the unique identification code a, a large amount of log information is filtered, and the log with the unique identification code a is obtained.

[0111] In this embodiment, the required logs can be accurately retrieved from a large number of logs through the unique identification code, which greatly reduces the log retrieval time and does not cause omission of log data.

[0112] Figure 9 FIG. 1 is a schematic diagram showing the structure of a log retrieval device according to an exemplary embodiment. Figure 9 As shown, in an exemplary embodiment, the log retrieval device includes:

[0113] The unique identification code acquisition module 910 is configured to initialize the classes on the service framework of multiple clients respectively to obtain the unique identification code corresponding to each client;

[0114] The subclass acquisition module 930 is configured to respectively acquire at least one log printing interface of each client according to the log printing signal, and acquire a subclass of the log printing interface, where the subclass is obtained by inheriting the class corresponding to the unique identification code of the client where the log printing interface is located and adding an attribute;

[0115] The log printing module 950 is configured to print the logs of the log printing interface through a subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes;

[0116] The log retrieval module 970 is configured to retrieve the logs from the multiple logs with the corresponding unique identification codes using the unique identification codes corresponding to each client to obtain a target log.

[0117] In this embodiment, the above structure can add a corresponding unique identification code to the printed log during the log printing process. When the log is retrieved later, the target log can be retrieved by using the unique identification code, thereby improving the efficiency and accuracy of log retrieval.

[0118] In one embodiment, the unique identification code acquisition module 910 includes:

[0119] a string acquisition unit configured to acquire a string identifying each client, the string being a combination of one or more of a timestamp, a random string, a service number, and a client information digest of each client;

[0120] The unique identification code acquisition unit is configured to perform deduplication processing on the character string, construct a class on the service framework of the corresponding client according to the deduplication processed character string, and obtain the unique identification code corresponding to each client.

[0121] In one embodiment, the log printing module 950 includes:

[0122] A log printing requirement obtaining unit configured to obtain a log printing requirement from a corresponding service framework via a log printing interface;

[0123] An initial log obtaining unit is configured to print the log of the log printing interface according to the log printing requirement to obtain a plurality of initial logs;

[0124] The log printing unit is configured to add unique identification codes to multiple initial logs through a subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes.

[0125] In one embodiment, the initial log acquisition unit includes:

[0126] The print level acquisition section is configured to determine the log print level from the log print requirements;

[0127] The initial log acquisition section is configured to print the logs of the corresponding level in the log printing interface according to the log printing level, and obtain multiple initial logs of the corresponding level.

[0128] In one embodiment, the log printing unit includes:

[0129] The target location information acquisition section is configured to obtain the target location information from the log printing request;

[0130] The unique identification code adding section is configured to add the unique identification code corresponding to the subclass of the log printing interface to the target location in multiple initial logs according to the target location information. The target location is the location in the multiple initial logs pointed to by the target location information.

[0131] In one embodiment, the log printing module 950 further includes:

[0132] a print destination acquisition unit configured to acquire a log print destination address from a log print request;

[0133] The storage unit is configured to store a plurality of logs with corresponding unique identification codes in a log printing destination address.

[0134] In one embodiment, the log retrieval module 970 includes:

[0135] A target unique identification code acquisition unit is configured to use the unique identification code corresponding to the client whose logs are to be retrieved as the target unique identification code;

[0136] The target log acquisition unit is configured to retrieve logs from multiple logs with corresponding unique identification codes through the target unique identification code to obtain the target log with the target unique identification code.

[0137] It should be noted that the log retrieval device provided in the above embodiment and the log retrieval method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.

[0138] This embodiment also proposes an electronic device, including: one or more processors; a storage device for storing one or more computer programs. When the one or more computer programs are executed by the one or more processors, the electronic device implements the log retrieval method described in the above embodiment.

[0139] Figure 10 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application is shown.

[0140] It should be noted that Figure 10 The computer system 1600 of the electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present application.

[0141] like Figure 10As shown, computer system 1600 includes a central processing unit (CPU) 1601, which can perform various appropriate actions and processes according to the program stored in read-only memory (ROM) 1602 or the program loaded from storage portion 1608 into random access memory (RAM) 1603, such as executing the method in the above embodiment. Various programs and data required for system operation are also stored in RAM 1603. CPU 1601, ROM 1602 and RAM 1603 are connected to each other via bus 1604. Input / output (I / O) interface 1605 is also connected to bus 1604.

[0142] The following components are connected to the I / O interface 1605: an input section 1606 including a keyboard, a mouse, and the like; an output section 1607 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 1608 including a hard disk; and a communication section 1609 including a network interface card such as a LAN (Local Area Network) card or a modem. The communication section 1609 performs communication processing via a network such as the Internet. A drive 1610 is also connected to the I / O interface 1605 as needed. Removable media 1611, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1610 as needed, so that computer programs read from the removable media can be installed in the storage section 1608 as needed.

[0143] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1609, and / or installed from a removable medium 1611. When the computer program is executed by the central processing unit (CPU) 1601, the various functions defined in the system of the present application are executed.

[0144] It should be noted that the computer-readable medium shown in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable computer program. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0145] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0146] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. In some cases, the names of these units do not constitute limitations on the units themselves.

[0147] Another aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned log retrieval method. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently and not be incorporated into the electronic device.

[0148] Another aspect of the present application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the log retrieval method provided in each of the above embodiments.

[0149] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main ideas and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.

Claims

1. A log retrieval method, characterized in that: include: Obtain a character string identifying each client, the character string being a combination of one or more of a timestamp, a random string, a service number, and a client information digest of each client; Deduplication is performed on the character strings, and a class on the service framework of the corresponding client is constructed based on the deduplication-processed character strings to obtain a unique identification code corresponding to each client; According to the log printing signal, at least one log printing interface of each client is obtained respectively, and a subclass of the log printing interface is obtained. When the log printing interface is called, the log will be printed. The subclass is obtained by inheriting the class corresponding to the unique identification code of the client where the log printing interface is located and adding an attribute; Printing the log of the log printing interface through the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes; Logs are retrieved from the multiple logs with corresponding unique identification codes using the unique identification code corresponding to each client to obtain a target log.

2. The method according to claim 1, characterized in that The log of the log printing interface is printed by the subclass of the log printing interface to obtain multiple logs with corresponding unique identification codes, including: Obtaining log printing requirements from the corresponding service framework through the log printing interface; Print the log of the log printing interface according to the log printing requirement to obtain multiple initial logs; The multiple logs with corresponding unique identification codes are obtained by adding unique identification codes to the multiple initial logs through the subclass of the log printing interface.

3. The method according to claim 2, characterized in that The log of the log printing interface is printed according to the log printing requirement to obtain multiple initial logs, including: determining a log printing level from the log printing requirement; The logs of the corresponding level in the log printing interface are printed according to the log printing level to obtain a plurality of initial logs of the corresponding level.

4. The method according to claim 2, characterized in that The step of adding unique identification codes to the multiple initial logs through the subclass of the log printing interface to obtain the multiple logs with corresponding unique identification codes includes: Acquire target location information from the log printing request; According to the target location information, the unique identification codes corresponding to the subclasses of the log printing interface are respectively added to the target locations in the multiple initial logs, where the target locations are the locations in the multiple initial logs pointed to by the target location information.

5. The method according to claim 2, characterized in that After adding the unique identification codes to the multiple initial logs through the subclass of the log printing interface to obtain the multiple logs with corresponding unique identification codes, the method further includes: Obtaining a log printing destination address from the log printing request; The plurality of logs with corresponding unique identification codes are stored in the log printing destination address.

6. The method according to claim 1, characterized in that The process of retrieving a log from the plurality of logs with corresponding unique identification codes using the unique identification code corresponding to each client to obtain a target log includes: The unique identification code corresponding to the client whose logs are to be retrieved is used as the target unique identification code; Logs are retrieved from the multiple logs with corresponding unique identification codes using the target unique identification code to obtain a target log with the target unique identification code.

7. A log retrieval device, characterized in that: include: A unique identification code acquisition module is configured to obtain a string identifying each client, the string being a combination of one or more of a timestamp, a random string, a service number, and a client information digest of each client; perform deduplication processing on the string, and construct a class on the service framework of the corresponding client based on the deduplication processed string to obtain a unique identification code corresponding to each client; A subclass acquisition module is configured to respectively acquire the log printing interface of each client according to the log printing signal, and acquire a subclass of the log printing interface. When the log printing interface is called, the log will be printed. The subclass is obtained by inheriting the class corresponding to the unique identification code of the client where the log printing interface is located and adding an attribute; A log printing module configured to print the logs of the log printing interface through a subclass of the log printing interface to obtain a plurality of logs with corresponding unique identification codes; The log retrieval module is configured to retrieve the logs from the plurality of logs with corresponding unique identification codes using the unique identification codes corresponding to each client to obtain a target log.

8. An electronic device, characterized in that: include: one or more processors; The storage device is configured to store one or more computer programs, and when the one or more computer programs are executed by the one or more processors, the electronic device implements the method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Log tracking method, device and system, server and storage medium

    CN113448936A