A log processing method and device

By connecting the agent's jar package on the application instance, obtaining and matching log printing conditions, the problems of poor flexibility in existing log processing methods and waste of resources are solved, efficient and flexible log processing is achieved, and user experience is improved.

CN113778969BActive Publication Date: 2025-03-18BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110081935.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-21
Publication Date
2025-03-18
Estimated Expiration
2041-01-21

AI Technical Summary

Technical Problem

The existing log processing methods are poor in flexibility, waste system resources, and limited applicable scenarios, resulting in poor user experience.

Method used

By running the application and connecting the corresponding jar package of the agent on the application instance, obtaining the log printing conditions, matching the application instance and log printing conditions, determining the log to be printed, and modifying the bytecode for printing output processing.

Benefits of technology

It improves the flexibility and processing efficiency of log processing, saves system resources, expands the applicable scenarios of log processing, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113778969B_ABST
    Figure CN113778969B_ABST
Patent Text Reader

Abstract

The present invention discloses a log processing method and device, and relates to the field of computer technology. A specific implementation of the method includes: running an application program, wherein a jar package corresponding to an agent program is connected to an application instance of the application program; using the jar package corresponding to the agent program to obtain a log printing condition, matching the application instance with the log printing condition to determine a log to be printed; modifying the bytecode corresponding to the log to be printed, and performing print output processing on the log to be printed. This implementation improves the flexibility and processing efficiency of log processing, saves system resources, expands the applicable scenarios of log processing, and improves user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a log processing method and device. Background Art

[0002] The log records the behavior and running status of the application, which plays an important role in the data analysis of the application and the testing process of the application running status.

[0003] There are at least the following problems in the prior art:

[0004] The existing log processing methods have technical problems such as poor flexibility of log processing, waste of system resources, few applicable scenarios of log processing, and poor user experience. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a log processing method and device, which can improve the flexibility and processing efficiency of log processing, save system resources, expand the applicable scenarios of log processing, and improve user experience.

[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a log processing method is provided, comprising:

[0007] Run the application, where the application instance of the application is connected to the jar package corresponding to the agent program;

[0008] Use the jar package corresponding to the agent program to obtain the log printing conditions, match the application instance with the log printing conditions to determine the log to be printed;

[0009] Modify the bytecode corresponding to the log to be printed, and print the log to be printed.

[0010] Furthermore, before the step of obtaining the log printing condition by using the jar package corresponding to the proxy program, the method further includes the step of configuring the log printing condition, including:

[0011] Obtaining application information, wherein the application information includes an application instance;

[0012] Configure log printing conditions for application instances based on application requirements.

[0013] Furthermore, the step of configuring log printing conditions for the application instance according to application requirements also includes:

[0014] Determine the class, method, and array corresponding to the application instance;

[0015] Perform printing configuration for at least one of the class, method, and array corresponding to the application instance according to application requirements to determine log printing conditions.

[0016] Furthermore, the application information also includes an application number; and the log processing method further includes:

[0017] Construct a mapping table between application numbers and log printing conditions;

[0018] Storage mapping table.

[0019] Furthermore, the step of obtaining the log printing conditions by using the jar package corresponding to the proxy program includes:

[0020] Use the jar package corresponding to the proxy program to send a log printing condition acquisition request; wherein the log printing condition acquisition request includes the application number;

[0021] Receive the log print condition corresponding to the application number.

[0022] Furthermore, the step of matching the application instance with the log printing condition to determine the log to be printed includes:

[0023] Traversing the classes, methods, and arrays of the application instance, and determining matching items according to the log printing conditions, wherein the matching items include at least one of class matching items, method matching items, and array matching items;

[0024] The log to be printed is determined based on the matching items.

[0025] Furthermore, it also includes:

[0026] Update log printing conditions according to application requirements;

[0027] The jar package corresponding to the agent program is used to obtain the updated log printing conditions, the logs to be printed are determined according to the updated log printing conditions, and the logs to be printed are printed and output.

[0028] According to a second aspect of an embodiment of the present invention, a log processing device is provided, including:

[0029] A running module is used to run an application program, wherein the application instance of the application program is connected to a jar package corresponding to the agent program;

[0030] The matching module is used to obtain the log printing conditions by using the jar package corresponding to the agent program, and match the application instance with the log printing conditions to determine the log to be printed;

[0031] The processing module is used to modify the bytecode corresponding to the log to be printed and perform print output processing on the log to be printed.

[0032] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0033] one or more processors;

[0034] a storage device for storing one or more programs,

[0035] When one or more programs are executed by one or more processors, the one or more processors implement any of the above-mentioned log processing methods.

[0036] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, any of the above-mentioned log processing methods is implemented.

[0037] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts a running application, in which the application instance of the application is connected to a jar package corresponding to the agent program; the jar package corresponding to the agent program is used to obtain the log printing condition, and the application instance is matched with the log printing condition to determine the log to be printed; the bytecode corresponding to the log to be printed is modified, and the log to be printed is processed by print output. Therefore, the technical means overcomes the technical problems that the flexibility of log processing is poor, system resources are wasted, the applicable scenarios of log processing are few, and the user experience is poor in the existing log processing method because the code logic for printing the log must exist in advance at the location where the log needs to be printed, and the log to be printed can only be determined according to the log level, thereby achieving the technical effect of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenarios of log processing, and improving user experience.

[0038] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0040] Figure 1 is a schematic diagram of the main process of the log processing method provided according to the first embodiment of the present invention;

[0041] Figure 2 is a schematic diagram of the main process of the log processing method provided according to the second embodiment of the present invention;

[0042] Figure 3 is a schematic diagram of main modules of a log processing device provided according to an embodiment of the present invention;

[0043] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0044] Figure 5It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0045] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0046] Figure 1 Schematic diagram of the main flow of the log processing method provided according to the first embodiment of the present invention; Figure 1 As shown, the log processing method provided by the embodiment of the present invention mainly includes:

[0047] Step S101, running the application, wherein the application instance of the application is connected to a jar package corresponding to the agent program.

[0048] Specifically, according to an embodiment of the present invention, before or after running the application, the jar package corresponding to the agent program (i.e., logAgent.jar) is dynamically connected to the application instance of the application, so that the log printing conditions corresponding to the application can be subsequently obtained through the logAgent.jar, and the application instance is matched with the log printing conditions to determine the log to be printed, thereby achieving the technical effect of improving log processing efficiency and enhancing the flexibility of log processing.

[0049] Step S102: using the jar package corresponding to the proxy program to obtain the log printing condition, matching the application instance with the log printing condition to determine the log to be printed.

[0050] According to the embodiment of the present invention, the latest log printing condition is obtained by using the jar package corresponding to the agent program, and then the application instance is matched with the log printing condition to determine the log to be printed.

[0051] According to a specific implementation of an embodiment of the present invention, since the above-mentioned logAgent.jar is dynamically connected to the application instance of the application, for each application instance connected to the logAgent.jar ar package, logAgent.jar is used to obtain the corresponding log printing conditions, thereby achieving that each application instance can obtain the latest log printing conditions corresponding to the application, saving system resources, expanding the applicable scenarios of log processing, and improving log processing efficiency.

[0052] Further, according to an embodiment of the present invention, before the step of obtaining the log printing condition by using the jar package corresponding to the proxy program, the log processing method further includes the step of configuring the log printing condition, including:

[0053] Obtaining application information, wherein the application information includes an application instance;

[0054] Configure log printing conditions for application instances based on application requirements.

[0055] Through the above settings, the log printing conditions corresponding to each application are determined according to the application requirements of each application (such as testing requirements, data processing requirements, and the application requirements indicate the type of log to be printed), thereby improving the flexibility of log processing.

[0056] Preferably, according to an embodiment of the present invention, the step of configuring log printing conditions for the application instance according to application requirements further includes:

[0057] Determine the class, method, and array corresponding to the application instance;

[0058] Perform printing configuration for at least one of the class, method, and array corresponding to the application instance according to application requirements to determine log printing conditions.

[0059] Through the above settings, the printing configuration is performed separately in combination with the application requirements and the classes, methods and / or arrays specifically corresponding to the application instances (whether a class, a method and / or an array corresponding to the configuration application instance is printed), and then the log printing conditions are generated, which is conducive to the subsequent rapid matching of the log printing conditions with the application instances during the application running process, and the rapid determination of the logs to be printed, so as to improve the log processing efficiency.

[0060] Exemplarily, according to an embodiment of the present invention, the above application information further includes an application number; and the log processing method further includes:

[0061] Construct a mapping table between application numbers and log printing conditions;

[0062] Storage mapping table.

[0063] Through the above settings, the purpose of building a mapping table is to facilitate logAgent.jar to quickly obtain the log printing conditions corresponding to the application, further improve the log processing efficiency, and enhance the user experience.

[0064] Specifically, according to an embodiment of the present invention, the step of obtaining the log printing conditions by using the jar package corresponding to the agent program includes:

[0065] Use the jar package corresponding to the proxy program to send a log printing condition acquisition request; wherein the log printing condition acquisition request includes the application number;

[0066] Receive the log print condition corresponding to the application number.

[0067] According to a specific implementation of an embodiment of the present invention, the configuration process of the log printing conditions is configured through a CMS (Content Management System) management platform. After the CMS management platform receives a log printing condition acquisition request containing an application number sent by logAgent.jar, it obtains the corresponding log printing condition from a storage device according to the application number, and sends the log printing condition to the application to facilitate subsequent determination of the log to be printed.

[0068] Further, according to an embodiment of the present invention, the step of matching the application instance with the log printing condition to determine the log to be printed includes:

[0069] Traversing the classes, methods, and arrays of the application instance, and determining matching items according to the log printing conditions, wherein the matching items include at least one of class matching items, method matching items, and array matching items;

[0070] The log to be printed is determined based on the matching items.

[0071] Through the above settings, by traversing the classes, methods and arrays in the application instance, matching processing can be performed quickly and comprehensively, and then the log to be printed is determined, thereby improving the accuracy of log processing.

[0072] Step S103, modifying the bytecode corresponding to the log to be printed, and performing print output processing on the log to be printed.

[0073] Through the above settings, after determining the log to be printed, you only need to modify the bytecode to execute the print output processing. Since the bytecode modification operation can be implemented using any log framework or third-party tools, it avoids the problem of narrow log processing application scenarios in the prior art due to the need to completely rely on the log framework to adjust the log level.

[0074] Furthermore, according to an embodiment of the present invention, the log processing method further includes:

[0075] Update log printing conditions according to application requirements;

[0076] The jar package corresponding to the agent program is used to obtain the updated log printing conditions, the logs to be printed are determined according to the updated log printing conditions, and the logs to be printed are printed and output.

[0077] Through the above settings, the log printing conditions can be updated according to changes in application requirements, so that the logs to be printed are determined according to the updated log printing conditions, which further improves the flexibility of log processing, expands the applicable scenarios of log processing, and improves the user experience.

[0078] According to the technical solution of the embodiment of the present invention, an application is run, wherein a jar package corresponding to the agent program is connected to the application instance of the application; the log printing condition is obtained by using the jar package corresponding to the agent program, and the application instance is matched with the log printing condition to determine the log to be printed; the bytecode corresponding to the log to be printed is modified, and the log to be printed is processed by print output. Therefore, the technical problem that the flexibility of log processing is poor, system resources are wasted, the applicable scenarios of log processing are few, and the user experience is poor in the existing log processing method because the code logic for printing the log must exist in advance at the location where the log needs to be printed, and the log to be printed can only be determined according to the log level is overcome, thereby achieving the technical effect of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenarios of log processing, and improving user experience.

[0079] Figure 2 Schematic diagram of the main flow of the log processing method provided according to the second embodiment of the present invention; Figure 2 As shown, the log processing method provided by the embodiment of the present invention mainly includes:

[0080] Step S201, obtaining application information.

[0081] Specifically, according to an embodiment of the present invention, the above application information includes an application number, an application contact, an IP list of an application instance, etc., as shown in the following table:

[0082]

[0083] Through the above settings, before configuring the log printing conditions, the application information is obtained first, so as to determine the log printing conditions corresponding to each application based on the application requirements of each application (such as testing requirements, data processing requirements, application requirements indicate the type of log to be printed) to improve the flexibility of log processing.

[0084] Step S202, determining the class, method and array corresponding to the application instance; performing printing configuration for at least one of the class, method and array corresponding to the application instance according to application requirements to determine log printing conditions.

[0085] Specifically, according to a specific implementation of an embodiment of the present invention, the following table provides an example of configuring log printing conditions:

[0086]

[0087]

[0088] The above table shows the configuration of log printing conditions of a specific implementation of an embodiment of the present invention, wherein an exact match refers to the configuration of printing (true) or not printing (false) when the class / method / array (where the array refers to the input parameter list) information is exactly the same as that provided in the application instance; fuzzy matching includes matching the entire class, matching a specific range of classes, and matching all.

[0089] Through the above settings, the printing configuration is performed separately in combination with the application requirements and the classes, methods and / or arrays specifically corresponding to the application instances (whether a class, a method and / or an array corresponding to the configuration application instance is printed), and then the log printing conditions are generated, which is conducive to the subsequent rapid matching of the log printing conditions with the application instances during the application running process, and the rapid determination of the logs to be printed, so as to improve the log processing efficiency.

[0090] Step S203, constructing a mapping table of application numbers and log printing conditions; and storing the mapping table.

[0091] Through the above settings, the printing configuration is performed separately in combination with the application requirements and the classes, methods and / or arrays specifically corresponding to the application instances (whether a class, a method and / or an array corresponding to the configuration application instance is printed), and then the log printing conditions are generated, which is conducive to the subsequent rapid matching of the log printing conditions with the application instances during the application running process, and the rapid determination of the logs to be printed, so as to improve the log processing efficiency.

[0092] Step S204: dynamically connect the jar package corresponding to the proxy program to the application instance of the application program, and run the application program.

[0093] Specifically, according to an embodiment of the present invention, before or after running the application, the jar package corresponding to the agent program (i.e., logAgent.jar) is dynamically connected to the application instance of the application, so that the log printing conditions corresponding to the application can be subsequently obtained through the logAgent.jar, and the application instance is matched with the log printing conditions to determine the log to be printed, thereby achieving the technical effect of improving log processing efficiency and enhancing the flexibility of log processing.

[0094] Step S205, using the jar package corresponding to the proxy program to send a log printing condition acquisition request; wherein the log printing condition acquisition request includes an application number; and receiving the log printing condition corresponding to the application number.

[0095] According to the embodiment of the present invention, the latest log printing condition is obtained by using the jar package corresponding to the agent program, and then the application instance is matched with the log printing condition to determine the log to be printed.

[0096] According to a specific implementation of an embodiment of the present invention, since the above-mentioned logAgent.jar is dynamically connected to the application instance of the application, for each application instance connected to the logAgent.jar ar package, logAgent.jar is used to obtain the corresponding log printing conditions, thereby achieving that each application instance can obtain the latest log printing conditions corresponding to the application, saving system resources, expanding the applicable scenarios of log processing, and improving log processing efficiency.

[0097] Step S206, traversing the classes, methods and arrays of the application instance, determining matching items according to the log printing conditions, and determining the log to be printed according to the matching items.

[0098] Specifically, according to an embodiment of the present invention, the above-mentioned matching item includes at least one of a class matching item, a method matching item and an array matching item.

[0099] According to a specific implementation of an embodiment of the present invention, after the CMS management platform obtains the application instance IP of the application to print logs, logAgent.jar calls the jvm.loadAgent() method to dynamically attach (dynamically connect) to the application instance of the application. After the jvm (Java Virtual Machine) on the application instance detects logAgent.jar, it will create an InstrumentationImpl object and execute the loadClassAndCallAgentMain() method to pass the InstrumentationImpl object to logAgent.jar, wherein the InstrumentationImpl object will provide all the class information that the jvm has loaded. The code conversion logic or bytecode enhancement logic in logAgent.jar obtains all the class information that the jvm has loaded through the InstrumentationImpl object, and then performs a loop judgment. For each class, it will match according to the above log printing conditions (according to the class name, method name, and method parameter list). If the match is successful and the result corresponding to the log printing condition is true, the bytecode enhancement tool inserts the code for printing the input parameter log before the matching item, that is:

[0100] LOGGER.info("

Call parameter

[0101] Insert the code returned by the print method after the match, ie:

[0102] LOGGER.info("

Call out parameters

[0103] If the result of the matching item in the log printing condition is false, the inserted code is rolled back to the initial loading state; if there is no matching item, no processing is performed, and the next class / method / array matching is continued, and the above steps are executed repeatedly until all classes / methods / arrays are traversed.

[0104] Through the above settings, by traversing the classes, methods and arrays in the application instance, matching processing can be performed quickly and comprehensively, and then the log to be printed is determined, thereby improving the accuracy of log processing.

[0105] Step S207, modifying the bytecode corresponding to the log to be printed, and performing print output processing on the log to be printed.

[0106] Through the above settings, after determining the log to be printed, you only need to modify the bytecode to execute the print output processing. Since the bytecode modification operation can be implemented using any log framework or third-party tools, it avoids the problem of narrow log processing application scenarios in the prior art due to the need to completely rely on the log framework to adjust the log level.

[0107] Furthermore, according to an embodiment of the present invention, the log processing method further includes:

[0108] Update log printing conditions according to application requirements;

[0109] The jar package corresponding to the agent program is used to obtain the updated log printing conditions, the logs to be printed are determined according to the updated log printing conditions, and the logs to be printed are printed and output.

[0110] Through the above settings, the log printing conditions can be updated according to changes in application requirements, so that the logs to be printed are determined according to the updated log printing conditions, which further improves the flexibility of log processing, expands the applicable scenarios of log processing, and improves the user experience.

[0111] According to the technical solution of the embodiment of the present invention, an application is run, wherein a jar package corresponding to the agent program is connected to the application instance of the application; the log printing condition is obtained by using the jar package corresponding to the agent program, and the application instance is matched with the log printing condition to determine the log to be printed; the bytecode corresponding to the log to be printed is modified, and the log to be printed is processed by print output. Therefore, the technical problem that the flexibility of log processing is poor, system resources are wasted, the applicable scenarios of log processing are few, and the user experience is poor in the existing log processing method because the code logic for printing the log must exist in advance at the location where the log needs to be printed, and the log to be printed can only be determined according to the log level is overcome, thereby achieving the technical effect of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenarios of log processing, and improving user experience.

[0112] Figure 3 is a schematic diagram of the main modules of the log processing device provided according to an embodiment of the present invention; Figure 3 As shown, the log processing device 300 provided in the embodiment of the present invention mainly includes:

[0113] The running module 301 is used to run the application program, wherein the application instance of the application program is connected to a jar package corresponding to the agent program.

[0114] Specifically, according to an embodiment of the present invention, before or after running the application, the jar package corresponding to the agent program (i.e., logAgent.jar) is dynamically connected to the application instance of the application, so that the log printing conditions corresponding to the application can be subsequently obtained through the logAgent.jar, and the application instance is matched with the log printing conditions to determine the log to be printed, thereby achieving the technical effect of improving log processing efficiency and enhancing the flexibility of log processing.

[0115] The matching module 302 is used to obtain the log printing condition by using the jar package corresponding to the agent program, and match the application instance with the log printing condition to determine the log to be printed.

[0116] According to the embodiment of the present invention, the matching module 302 is used to obtain the latest log printing condition by using the jar package corresponding to the agent program, and then match the log printing condition according to the application instance to determine the log to be printed.

[0117] According to a specific implementation of an embodiment of the present invention, since the above-mentioned logAgent.jar is dynamically connected to the application instance of the application, for each application instance connected to the logAgent.jar ar package, logAgent.jar is used to obtain the corresponding log printing conditions, thereby achieving that each application instance can obtain the latest log printing conditions corresponding to the application, saving system resources, expanding the applicable scenarios of log processing, and improving log processing efficiency.

[0118] Further, according to an embodiment of the present invention, the log processing device 300 further includes a log printing condition configuration module. Before the step of obtaining the log printing condition by using the jar package corresponding to the agent program, the log printing condition configuration module is used to:

[0119] Obtaining application information, wherein the application information includes an application instance;

[0120] Configure log printing conditions for application instances based on application requirements.

[0121] Through the above settings, the log printing conditions corresponding to each application are determined according to the application requirements of each application (such as testing requirements, data processing requirements, and the application requirements indicate the type of log to be printed), thereby improving the flexibility of log processing.

[0122] Preferably, according to an embodiment of the present invention, the log printing condition configuration module is further used for:

[0123] Determine the class, method, and array corresponding to the application instance;

[0124] Perform printing configuration for at least one of the class, method, and array corresponding to the application instance according to application requirements to determine log printing conditions.

[0125] Through the above settings, the printing configuration is performed separately in combination with the application requirements and the classes, methods and / or arrays specifically corresponding to the application instances (whether a class, a method and / or an array corresponding to the configuration application instance is printed), and then the log printing conditions are generated, which is conducive to the subsequent rapid matching of the log printing conditions with the application instances during the application running process, and the rapid determination of the logs to be printed, so as to improve the log processing efficiency.

[0126] Exemplarily, according to an embodiment of the present invention, the log processing device 300 further includes a storage module, which is used to:

[0127] Construct a mapping table between application numbers and log printing conditions;

[0128] Storage mapping table.

[0129] Through the above settings, the purpose of building a mapping table is to facilitate logAgent.jar to quickly obtain the log printing conditions corresponding to the application, further improve the log processing efficiency, and enhance the user experience.

[0130] Specifically, according to an embodiment of the present invention, the matching module 302 is further used for:

[0131] Use the jar package corresponding to the proxy program to send a log printing condition acquisition request; wherein the log printing condition acquisition request includes the application number;

[0132] Receive the log print condition corresponding to the application number.

[0133] According to a specific implementation of an embodiment of the present invention, the configuration process of the log printing conditions is configured through a CMS (Content Management System) management platform. After the CMS management platform receives a log printing condition acquisition request containing an application number sent by logAgent.jar, it obtains the corresponding log printing condition from a storage device according to the application number, and sends the log printing condition to the application to facilitate subsequent determination of the log to be printed.

[0134] Further, according to an embodiment of the present invention, the matching module 302 is further configured to:

[0135] Traversing the classes, methods, and arrays of the application instance, and determining matching items according to the log printing conditions, wherein the matching items include at least one of class matching items, method matching items, and array matching items;

[0136] The log to be printed is determined based on the matching items.

[0137] Through the above settings, by traversing the classes, methods and arrays in the application instance, matching processing can be performed quickly and comprehensively, and then the log to be printed is determined, thereby improving the accuracy of log processing.

[0138] The processing module 303 is used to modify the bytecode corresponding to the log to be printed, and perform print output processing on the log to be printed.

[0139] Through the above settings, after determining the log to be printed, you only need to modify the bytecode to execute the print output processing. Since the bytecode modification operation can be implemented using any log framework or third-party tools, it avoids the problem of narrow log processing application scenarios in the prior art due to the need to completely rely on the log framework to adjust the log level.

[0140] Further, according to an embodiment of the present invention, the log processing device 300 further includes an update module, which is used to:

[0141] Update log printing conditions according to application requirements;

[0142] The jar package corresponding to the agent program is used to obtain the updated log printing conditions, the logs to be printed are determined according to the updated log printing conditions, and the logs to be printed are printed and output.

[0143] Through the above settings, the log printing conditions can be updated according to changes in application requirements, so that the logs to be printed are determined according to the updated log printing conditions, which further improves the flexibility of log processing, expands the applicable scenarios of log processing, and improves the user experience.

[0144] According to the technical solution of the embodiment of the present invention, an application is run, wherein a jar package corresponding to the agent program is connected to the application instance of the application; the log printing condition is obtained by using the jar package corresponding to the agent program, and the application instance is matched with the log printing condition to determine the log to be printed; the bytecode corresponding to the log to be printed is modified, and the log to be printed is processed by print output. Therefore, the technical problem that the flexibility of log processing is poor, system resources are wasted, the applicable scenarios of log processing are few, and the user experience is poor in the existing log processing method because the code logic for printing the log must exist in advance at the location where the log needs to be printed, and the log to be printed can only be determined according to the log level is overcome, thereby achieving the technical effect of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenarios of log processing, and improving user experience.

[0145] Figure 4 An exemplary system architecture 400 to which the log processing method or log processing device according to the embodiment of the present invention can be applied is shown.

[0146] like Figure 4 As shown, the system architecture 400 may include terminal devices 401, 402, 403, a network 404 and a server 405 (this architecture is only an example, and the components included in the specific architecture may be adjusted according to the specific application). The network 404 is used to provide a medium for a communication link between the terminal devices 401, 402, 403 and the server 405. The network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0147] The user can use the terminal devices 401, 402, 403 to interact with the server 405 through the network 404 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 401, 402, 403, such as data processing applications, log processing applications, log printing applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0148] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0149] The server 405 may be a server that provides various services, such as a server that (performs log processing / data processing) for users using the terminal devices 401, 402, and 403 (only as an example). The server may analyze and process the received data such as log printing conditions, and feed back the processing results (such as the log to be printed - only as an example) to the terminal device.

[0150] It should be noted that the log processing method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the log processing device is generally disposed in the server 405 .

[0151] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0152] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0153] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0154] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0155] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.

[0156] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, 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 may 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 or 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 invention, a computer-readable storage medium may 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 invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0157] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order 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 flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0158] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a module, a matching module and a processing module. The names of these modules do not constitute a limitation on the modules themselves in some cases. For example, the running module may also be described as "a module for running an application, wherein a jar package corresponding to an agent program is connected to the application instance of the application".

[0159] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: running an application, wherein the application instance of the application is connected to a jar package corresponding to the agent program; using the jar package corresponding to the agent program to obtain log printing conditions, matching the application instance with the log printing conditions to determine the log to be printed; modifying the bytecode corresponding to the log to be printed, and performing print output processing on the log to be printed.

[0160] According to the technical solution of the embodiment of the present invention, an application is run, wherein a jar package corresponding to the agent program is connected to the application instance of the application; the log printing condition is obtained by using the jar package corresponding to the agent program, and the application instance is matched with the log printing condition to determine the log to be printed; the bytecode corresponding to the log to be printed is modified, and the log to be printed is processed by print output. Therefore, the technical problem that the flexibility of log processing is poor, system resources are wasted, the applicable scenarios of log processing are few, and the user experience is poor in the existing log processing method because the code logic for printing the log must exist in advance at the location where the log needs to be printed, and the log to be printed can only be determined according to the log level is overcome, thereby achieving the technical effect of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenarios of log processing, and improving user experience.

[0161] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A log processing method, characterized in that: include: Run the application, wherein the application instance of the application is connected to a jar package corresponding to the agent program; Configuring log printing conditions; specifically including: obtaining application information, wherein the application information includes an application instance; configuring log printing conditions for the application instance according to application requirements; Using the jar package corresponding to the agent program to obtain the log printing condition, matching the application instance with the log printing condition to determine the log to be printed; Modify the bytecode corresponding to the log to be printed, and print and output the log to be printed; The step of configuring log printing conditions for the application instance according to application requirements also includes: Determine the class, method and array corresponding to the application instance; Perform printing configuration for at least one of the class, method, and array corresponding to the application instance according to application requirements to determine log printing conditions.

2. The log processing method according to claim 1, characterized in that: The application information also includes an application number; and the log processing method also includes: Constructing a mapping table between the application number and the log printing condition; The mapping table is stored.

3. The log processing method according to claim 2, characterized in that: The step of obtaining the log printing conditions by using the jar package corresponding to the agent program includes: Using the jar package corresponding to the proxy program to send a log printing condition acquisition request; wherein the log printing condition acquisition request includes the application number; A log printing condition corresponding to the application number is received.

4. The log processing method according to claim 1, characterized in that: The step of matching the application instance with the log printing condition to determine the log to be printed includes: Traversing the classes, methods and arrays of the application instance, and determining matching items according to the log printing condition, wherein the matching items include at least one of class matching items, method matching items and array matching items; The log to be printed is determined according to the matching item.

5. The log processing method according to claim 4, characterized in that: Also includes: Updating the log printing conditions according to application requirements; The updated log printing condition is obtained by using the jar package corresponding to the agent program, the log to be printed is determined according to the updated log printing condition, and the log to be printed is processed for print output.

6. A log processing device, characterized in that: include: A running module, used to run an application program, wherein the application instance of the application program is connected to a jar package corresponding to the agent program; A log printing condition configuration module, used to obtain application information, wherein the application information includes an application instance; and configure log printing conditions for the application instance according to application requirements; A matching module, used to obtain log printing conditions by using the jar package corresponding to the agent program, and match the application instance with the log printing conditions to determine the log to be printed; A processing module, used for modifying the bytecode corresponding to the log to be printed, and performing print output processing on the log to be printed; Among them, the log printing condition configuration module is also used to determine the class, method and array corresponding to the application instance; according to application requirements, print configuration is performed for at least one of the class, method and array corresponding to the application instance to determine the log printing condition.

7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

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

Citation Information

Patent Citations

  • Log generating method and device, computer equipment and storage medium

    CN108228461A

  • Method and device for printing log

    CN108984134A

  • Log storage method, apparatus and device, and computer readable medium

    CN110908967A