Application exception processing method, device, equipment and medium based on log printing
By embedding the log printing plug-in in the application, using AOP to intercept and report exception information, the problem of low efficiency in application exception handling is solved, and unsensed automatic detection and efficient analysis are achieved.
Patent Information
- Application Number
- CN202111439379.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2041-11-30
AI Technical Summary
In the prior art, application exception handling efficiency is low and lacks targeted, resulting in poor user experience, and the log printing method is complex and costly, requiring users to intervene in communication and investigation.
Create a log printing plug-in to be embedded in the target installation package, use the plug-in to listen to the application, intercept old class function functions through the AOP principle, detect exceptions and report stack information, automatically build print functions and report logs, avoid user perception.
It realizes automatic detection of application exceptions without user perception, reduces data redundancy, improves exception handling efficiency, simplifies the investigation process, and improves analysis efficiency.
Smart Images

Figure CN114116400B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, equipment and medium for handling application exceptions based on log printing. Background Art
[0002] With the increasing popularity of smart devices, there are more and more applications available for users to choose from. When users encounter unexpected anomalies while using an application, it is difficult to directly print logs from the client to assist in troubleshooting the problem, as the application serves a wide range of users and their activity areas are relatively flexible and not fixed. Even if this is possible, it is inefficient and easily disturbs users, especially for problems that are difficult to troubleshoot, which has a greater impact on users.
[0003] In addition, the currently commonly used log printing methods all have relatively complex processes, high operating costs, and usually require user intervention, communication and troubleshooting, which affects the user experience. Summary of the Invention
[0004] In view of the above, it is necessary to provide an application exception handling method, device, equipment and medium based on log printing, aiming to solve the problem of low efficiency and lack of pertinence in application log printing.
[0005] A method for handling application exceptions based on log printing, the method comprising:
[0006] Create a log printing plug-in and embed the log printing plug-in into the target installation package;
[0007] Using the log printing plug-in, monitoring the target application installed based on the target installation package;
[0008] During the monitoring process, the function and parameter printing method sent by the target application through the specified page are received;
[0009] Compile the functional function and the parameter printing method into a class to obtain a target class;
[0010] Obtaining an old class corresponding to the target class, and intercepting the old class using the target class;
[0011] During the interception process, when a function exception is detected, the detected function is determined as an abnormal function, the abnormal stack information of the abnormal function is obtained, and the abnormal stack information is reported to the configuration terminal based on the message push mechanism;
[0012] When receiving the print position fed back by the configuration terminal based on the analysis of the exception stack information, constructing a print function based on the parameter printing method at the print position, and sending the print function to the target application;
[0013] When the target application is running, the print function is used to print logs, and the printed logs are reported to the configuration terminal.
[0014] According to a preferred embodiment of the present invention, intercepting the old class by using the target class includes:
[0015] Adopt AOP principle to obtain the functional functions of the old class;
[0016] Before executing the function function of the old class, the corresponding function in the target class is executed to obtain an execution result;
[0017] Returns the execution result.
[0018] According to a preferred embodiment of the present invention, the method further includes:
[0019] During the interception process, when the Exception class and / or a subclass of the Exception class is detected, a function that generates the Exception class and / or a subclass of the Exception class is obtained;
[0020] The acquired functional function is determined as the abnormal function.
[0021] According to a preferred embodiment of the present invention, the method further includes:
[0022] When receiving a running problem of the target application reported by a user, the target application is monitored by using the log printing plug-in.
[0023] According to a preferred embodiment of the present invention, the method further includes:
[0024] The configuration terminal uses the java.net.ConnectException function to locate the exception category and identifies sub-functions with failure risks in the exception function based on the ThreadPoolExecutor$Worker.run function;
[0025] The printing position is generated according to the exception type and the sub-function.
[0026] According to a preferred embodiment of the present invention, constructing a printing function based on the parameter printing method at the printing position includes:
[0027] Acquire the sub-function according to the printing position;
[0028] Add the parameter printing method in the sub-function to obtain the printing function.
[0029] According to a preferred embodiment of the present invention, when reporting the printed log to the configuration terminal, the method further includes:
[0030] Obtaining a pre-configured warning level list, wherein the warning level list stores a correspondence between abnormal categories and warning levels;
[0031] Query the warning level list using the abnormality category;
[0032] Determine the queried warning level corresponding to the abnormality category as the target level;
[0033] generating early warning information according to the target level;
[0034] The warning information is added to the printed log and reported to the configuration terminal.
[0035] An application exception handling device based on log printing, the application exception handling device based on log printing comprising:
[0036] A creation unit, configured to create a log printing plug-in and embed the log printing plug-in into a target installation package;
[0037] A monitoring unit, configured to monitor a target application installed based on the target installation package using the log printing plug-in;
[0038] A receiving unit, configured to receive, during the monitoring process, the function and parameter printing method issued by the target application via a specified page;
[0039] A compiling unit, configured to compile the functional function and the parameter printing method into a class to obtain a target class;
[0040] an interception unit, configured to obtain an old class corresponding to the target class, and intercept the old class using the target class;
[0041] A reporting unit is configured to, during the interception process, determine that a function is abnormal when an abnormal function is detected, obtain abnormal stack information of the abnormal function, and report the abnormal stack information to the configuration terminal based on a message push mechanism;
[0042] a sending unit, configured to, upon receiving a print position fed back by the configuration terminal based on parsing the exception stack information, construct a print function based on the parameter printing method at the print position, and send the print function to the target application;
[0043] The reporting unit is further configured to print a log using the print function when the target application is running, and report the printed log to the configuration terminal.
[0044] A computer device, comprising:
[0045] a memory storing at least one instruction; and
[0046] The processor executes the instructions stored in the memory to implement the application exception handling method based on log printing.
[0047] A computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the application exception handling method based on log printing.
[0048] It can be seen from the above technical solution that the present invention can create a log printing plug-in and embed the log printing plug-in into the target installation package, and use the log printing plug-in to monitor the target application installed based on the target installation package. During the monitoring process, the function function and parameter printing method issued by the target application through the specified page are received, the function function and the parameter printing method are compiled into a class to obtain the target class, the old class corresponding to the target class is obtained, and the target class is used to intercept the old class. While intercepting the old class, the functional characteristics of the old class are not affected, and the operation status of each function function is monitored. During the interception process, when a function function exception is detected, the detected function function is determined as an abnormal function, the exception stack information of the abnormal function is obtained, and based on the elimination The information push mechanism reports the exception stack information to the configuration terminal, automatically detects the exception of the application without the user's perception, and avoids affecting the user's use. When the printing position fed back by the configuration terminal based on the analysis of the exception stack information is received, a printing function is constructed at the printing position based on the parameter printing method, and the printing function is sent to the target application for targeted parameter printing. This not only effectively obtains the exception data, which is convenient for subsequent analysis and use, but also reduces data redundancy and improves analysis efficiency. When the target application is running, the printing function is used to print logs, and the printed logs are reported to the configuration terminal. When troubleshooting, there is no need to repeatedly package, put on the shelf, modify and print logs, which effectively improves the efficiency of exception handling. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 The flowchart of a preferred embodiment of the application exception handling method based on log printing of the present invention.
[0050] Figure 2 It is a functional module diagram of a preferred embodiment of the application exception handling device based on log printing of the present invention.
[0051] Figure 3 It is a structural diagram of a computer device according to a preferred embodiment of the present invention for implementing an application exception handling method based on log printing. DETAILED DESCRIPTION
[0052] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0053] like Figure 1 FIG. 1 is a flow chart of a preferred embodiment of the method for handling application exceptions based on log printing according to the present invention. The order of the steps in the flow chart can be changed and some steps can be omitted according to different requirements.
[0054] The application exception handling method based on log printing is applied to one or more computer devices, which are devices that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. Their hardware includes but is not limited to microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0055] The computer device may be any electronic product that can interact with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0056] The computer device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.
[0057] The server can be an independent server or 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, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0058] Among them, Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0059] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.
[0060] The network where the computer device is located includes but is not limited to the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.
[0061] S10: Create a log printing plug-in, and embed the log printing plug-in into the target installation package.
[0062] Specifically, the log printing plug-in encapsulates multiple functional functions for implementing functions such as log printing.
[0063] In this embodiment, the target application can be deployed in a variety of operating systems, such as Android system, IOS (IPhone Operation System) system, etc.
[0064] S11 , using the log printing plug-in to monitor the target application installed based on the target installation package.
[0065] Specifically, after the log printing plug-in is embedded in the installation package of the target application, when a device installs the target application based on the target installation package, real-time monitoring of the target application installed in the device can be achieved.
[0066] The target application may be any application, such as a self-developed application, etc., which is not limited by the present invention.
[0067] S12, during the monitoring process, receiving the function and parameter printing method sent by the target application through the designated page.
[0068] In this embodiment, the designated page may be pre-configured.
[0069] For example, for a financial management application, the designated page may be configured as the home page.
[0070] In this embodiment, the functional function refers to a function related to the service of the target application program and is used to execute the corresponding service.
[0071] In this embodiment, the parameter printing method refers to a specific way of printing parameters.
[0072] Specifically, the functional function and the parameter printing method are issued in the form of text strings, that is, in the form of codes.
[0073] S13, compile the functional function and the parameter printing method into a class to obtain a target class.
[0074] It should be noted that since the function function and the parameter printing method are in string format when issued and cannot be called directly, they first need to be compiled into a class for subsequent calling and execution of the corresponding functions.
[0075] S14, obtaining an old class corresponding to the target class, and using the target class to intercept the old class.
[0076] In this embodiment, the old class corresponding to the target class can be identified by the class name, etc., which will not be described in detail here.
[0077] The old class refers to the class originally used before the functional function and the parameter printing method are compiled into a class.
[0078] In at least one embodiment of the present invention, intercepting the old class using the target class includes:
[0079] Adopting AOP (Aspect Oriented Programming) principle to obtain the functional functions of the old class;
[0080] Before executing the function function of the old class, the corresponding function in the target class is executed to obtain an execution result;
[0081] Returns the execution result.
[0082] Among them, the AOP principle is the same as the AOP of the Java background. This embodiment adds logic before the function function of the old class and adds logic after the function function of the old class. The received function function and parameter printing method are compiled into a class and intercepted by AOP. In fact, it intercepts the old class and returns directly after the old class finishes processing the matter.
[0083] Through the above implementation, while intercepting the old class, the functional characteristics of the old class are not affected, and the monitoring of the running status of each functional function is achieved.
[0084] S15, during the interception process, when a function exception is detected, the detected function is determined as an abnormal function, the abnormal stack information of the abnormal function is obtained, and the abnormal stack information is reported to the configuration terminal based on a message push mechanism.
[0085] In at least one embodiment of the present invention, the method further comprises:
[0086] During the interception process, when the Exception class and / or a subclass of the Exception class is detected, a function that generates the Exception class and / or a subclass of the Exception class is obtained;
[0087] The acquired functional function is determined as the abnormal function.
[0088] The Exception class is an exception class. When the Exception class and its subclasses appear, it indicates an operation exception.
[0089] In this embodiment, information such as the exception type and the exception sub-function can be determined based on the exception stack information.
[0090] Through the above implementation, application anomalies can be automatically detected without the user's awareness, avoiding impact on user usage.
[0091] In at least one embodiment of the present invention, the method further comprises:
[0092] When receiving a running problem of the target application reported by a user, the target application is monitored by using the log printing plug-in.
[0093] Specifically, the subsequent execution method is similar to the previous one and will not be repeated here.
[0094] Through the above implementation, not only can the operation of the program be automatically monitored, but also when the user reports an anomaly based on the usage situation, it can respond automatically and in a timely manner, further improving the anomaly detection process and enhancing the user experience.
[0095] In this embodiment, the exception targeted may be a simple exception or an exception scenario that is difficult to resolve, etc., and the present invention is not limited thereto.
[0096] S16 , when receiving the print position fed back by the configuration terminal based on the analysis of the exception stack information, constructing a print function based on the parameter printing method at the print position, and sending the print function to the target application.
[0097] In this embodiment, the configuration terminal may include a terminal responsible for handling exceptions, such as a background system for developing an application program.
[0098] In at least one embodiment of the present invention, the method further comprises:
[0099] The configuration terminal uses the java.net.ConnectException function to locate the exception category and identifies sub-functions with failure risks in the exception function based on the ThreadPoolExecutor$Worker.run function;
[0100] The printing position is generated according to the exception type and the sub-function.
[0101] Wherein, the ava.net.ConnectException function is an exception category positioning function, which is used to determine the category of the exception;
[0102] The ThreadPoolExecutor$Worker.run function is a fault identification function used to capture methods and functions with fault risks.
[0103] In the above embodiment, the configuration terminal generates the print location based on the java.net.ConnectException function and the ThreadPoolExecutor$Worker.run function, so that the log is subsequently printed at the print location.
[0104] Specifically, constructing a printing function based on the parameter printing method at the printing position includes:
[0105] Acquire the sub-function according to the printing position;
[0106] Add the parameter printing method in the sub-function to obtain the printing function.
[0107] Through the above implementation, a parameter printing method can be automatically added at the printing location where a fault or abnormality risk is determined, so that parameter printing can be performed in a targeted manner. This not only effectively obtains abnormal data for subsequent analysis, but also reduces data redundancy and improves analysis efficiency.
[0108] In at least one embodiment of the present invention, when sending the print function to the target application, the method further includes:
[0109] Prompt information is added to the print function, wherein the prompt information is equivalent to prompting the user of the target application to run the target application within a preset time range, and the number of runs is greater than or equal to the configured number of runs.
[0110] The preset time range can be customized, such as within 10 minutes.
[0111] The number of configurations can be customized, such as 5 times.
[0112] Through the above implementation, when issuing the print function, the user can be prompted to operate the target application as many times as possible within a certain period of time, so as to obtain more logs as data support for subsequent log analysis to improve the accuracy of the analysis.
[0113] S17, when the target application is running, using the print function to print the log, and reporting the printed log to the configuration terminal.
[0114] Specifically, when reporting the printed log to the configuration terminal, the method further includes:
[0115] Obtaining a pre-configured warning level list, wherein the warning level list stores a correspondence between abnormal categories and warning levels;
[0116] Query the warning level list using the abnormality category;
[0117] Determine the queried warning level corresponding to the abnormality category as the target level;
[0118] generating early warning information according to the target level;
[0119] The warning information is added to the printed log and reported to the configuration terminal.
[0120] Through the above implementation, different levels of warnings can be issued according to different abnormality categories, so that different priorities can be subsequently processed according to different levels.
[0121] Furthermore, after the printed log is reported to the configuration terminal, relevant staff can assist in log analysis, or the configuration terminal can automatically parse the log to identify the cause of the fault and eliminate the fault in a timely manner.
[0122] For example: after embedding a log printing plug-in in the application's installation package, when a program exception is detected, the exception is reported to the background system in a timely manner, and the function that may cause the exception is analyzed. Further, a parameter printing method is added to the function that may cause the exception to generate a printing function. At this time, the generated printing function will be used to obtain targeted logs for possible abnormal functions, and the obtained logs will be returned to the background system to facilitate the background system to analyze and resolve the cause of the exception.
[0123] This embodiment eliminates the need to repeatedly package, upload, modify, and print logs when troubleshooting problems, effectively improving exception handling efficiency.
[0124] It should be noted that in order to further improve the security of data and prevent data from being maliciously tampered with, the log printing plug-in can be stored in the blockchain node.
[0125] It can be seen from the above technical solution that the present invention can create a log printing plug-in and embed the log printing plug-in into the target installation package, and use the log printing plug-in to monitor the target application installed based on the target installation package. During the monitoring process, the function function and parameter printing method issued by the target application through the specified page are received, the function function and the parameter printing method are compiled into a class to obtain the target class, the old class corresponding to the target class is obtained, and the target class is used to intercept the old class. While intercepting the old class, the functional characteristics of the old class are not affected, and the operation status of each function function is monitored. During the interception process, when a function function exception is detected, the detected function function is determined as an abnormal function, the exception stack information of the abnormal function is obtained, and based on the elimination The information push mechanism reports the exception stack information to the configuration terminal, automatically detects the exception of the application without the user's perception, and avoids affecting the user's use. When the printing position fed back by the configuration terminal based on the analysis of the exception stack information is received, a printing function is constructed at the printing position based on the parameter printing method, and the printing function is sent to the target application for targeted parameter printing. This not only effectively obtains the exception data, which is convenient for subsequent analysis and use, but also reduces data redundancy and improves analysis efficiency. When the target application is running, the printing function is used to print logs, and the printed logs are reported to the configuration terminal. When troubleshooting, there is no need to repeatedly package, put on the shelf, modify and print logs, which effectively improves the efficiency of exception handling.
[0126] like Figure 2 , which is a functional module diagram of a preferred embodiment of the application exception handling device based on log printing of the present invention. The application exception handling device based on log printing 11 includes a creation unit 110, a monitoring unit 111, a receiving unit 112, a compilation unit 113, an interception unit 114, a reporting unit 115, and a sending unit 116. The module / unit referred to in the present invention refers to a series of computer program segments that can be executed by the processor 13 and can perform fixed functions, which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0127] The creation unit 110 creates a log printing plug-in and embeds the log printing plug-in into a target installation package.
[0128] Specifically, the log printing plug-in encapsulates multiple functional functions for implementing functions such as log printing.
[0129] In this embodiment, the target application can be deployed in a variety of operating systems, such as Android system, IOS (IPhone Operation System) system, etc.
[0130] The monitoring unit 111 uses the log printing plug-in to monitor the target application installed based on the target installation package.
[0131] Specifically, after the log printing plug-in is embedded in the installation package of the target application, when a device installs the target application based on the target installation package, real-time monitoring of the target application installed in the device can be achieved.
[0132] The target application may be any application, such as a self-developed application, etc., which is not limited by the present invention.
[0133] During the monitoring process, the receiving unit 112 receives the function and parameter printing method sent by the target application through the designated page.
[0134] In this embodiment, the designated page may be pre-configured.
[0135] For example, for a financial management application, the designated page may be configured as the home page.
[0136] In this embodiment, the functional function refers to a function related to the service of the target application program and is used to execute the corresponding service.
[0137] In this embodiment, the parameter printing method refers to a specific way of printing parameters.
[0138] Specifically, the functional function and the parameter printing method are issued in the form of text strings, that is, in the form of codes.
[0139] The compiling unit 113 compiles the functional function and the parameter printing method into a class to obtain a target class.
[0140] It should be noted that since the function function and the parameter printing method are in string format when issued and cannot be called directly, they first need to be compiled into a class for subsequent calling and execution of the corresponding functions.
[0141] The interception unit 114 obtains an old class corresponding to the target class, and intercepts the old class using the target class.
[0142] In this embodiment, the old class corresponding to the target class can be identified by the class name, etc., which will not be described in detail here.
[0143] The old class refers to the class originally used before the functional function and the parameter printing method are compiled into a class.
[0144] In at least one embodiment of the present invention, the interception unit 114 intercepting the old class using the target class includes:
[0145] Adopting AOP (Aspect Oriented Programming) principle to obtain the functional functions of the old class;
[0146] Before executing the function function of the old class, the corresponding function in the target class is executed to obtain an execution result;
[0147] Returns the execution result.
[0148] Among them, the AOP principle is the same as the AOP of the Java background. This embodiment adds logic before the function function of the old class and adds logic after the function function of the old class. The received function function and parameter printing method are compiled into a class and intercepted by AOP. In fact, it intercepts the old class and returns directly after the old class finishes processing the matter.
[0149] Through the above implementation, while intercepting the old class, the functional characteristics of the old class are not affected, and the monitoring of the running status of each functional function is achieved.
[0150] During the interception process, when the reporting unit 115 detects a function exception, it determines the detected function as an abnormal function, obtains the abnormal stack information of the abnormal function, and reports the abnormal stack information to the configuration terminal based on the message push mechanism.
[0151] In at least one embodiment of the present invention, during the interception process, when an Exception class and / or a subclass of the Exception class is detected, a function that generates the Exception class and / or the subclass of the Exception class is obtained;
[0152] The acquired functional function is determined as the abnormal function.
[0153] The Exception class is an exception class. When the Exception class and its subclasses appear, it indicates an operation exception.
[0154] In this embodiment, information such as the exception type and the exception sub-function can be determined based on the exception stack information.
[0155] Through the above implementation, application anomalies can be automatically detected without the user's awareness, avoiding impact on user usage.
[0156] In at least one embodiment of the present invention, when a user reports an operation problem of the target application, the log printing plug-in is used to monitor the target application.
[0157] Specifically, the subsequent execution method is similar to the previous one and will not be repeated here.
[0158] Through the above implementation, not only can the operation of the program be automatically monitored, but also when the user reports an anomaly based on the usage situation, it can respond automatically and in a timely manner, further improving the anomaly detection process and enhancing the user experience.
[0159] In this embodiment, the exception targeted may be a simple exception or an exception scenario that is difficult to resolve, etc., and the present invention is not limited thereto.
[0160] Upon receiving the print position fed back by the configuration terminal based on the analysis of the exception stack information, the issuing unit 116 constructs a print function based on the parameter printing method at the print position, and issues the print function to the target application.
[0161] In this embodiment, the configuration terminal may include a terminal responsible for handling exceptions, such as a background system for developing an application program.
[0162] In at least one embodiment of the present invention, the configuration terminal uses the java.net.ConnectException function to locate the exception category and identifies the sub-function with a fault risk in the exception function based on the ThreadPoolExecutor$Worker.run function;
[0163] The printing position is generated according to the exception type and the sub-function.
[0164] Wherein, the ava.net.ConnectException function is an exception category positioning function, which is used to determine the category of the exception;
[0165] The ThreadPoolExecutor$Worker.run function is a fault identification function used to capture methods and functions with fault risks.
[0166] In the above embodiment, the configuration terminal generates the print location based on the java.net.ConnectException function and the ThreadPoolExecutor$Worker.run function, so that the log is subsequently printed at the print location.
[0167] Specifically, the issuing unit 116 constructs a printing function based on the parameter printing method at the printing position, including:
[0168] Acquire the sub-function according to the printing position;
[0169] Add the parameter printing method in the sub-function to obtain the printing function.
[0170] Through the above implementation, a parameter printing method can be automatically added at the printing location where a fault or abnormality risk is determined, so that parameter printing can be performed in a targeted manner. This not only effectively obtains abnormal data for subsequent analysis, but also reduces data redundancy and improves analysis efficiency.
[0171] In at least one embodiment of the present invention, when the print function is sent to the target application, prompt information is added to the print function, wherein the prompt information is equivalent to prompting the user of the target application to run the target application within a preset time range, and the number of runs is greater than or equal to the configured number of times.
[0172] The preset time range can be customized, such as within 10 minutes.
[0173] The number of configurations can be customized, such as 5 times.
[0174] Through the above implementation, when issuing the print function, the user can be prompted to operate the target application as many times as possible within a certain period of time, so as to obtain more logs as data support for subsequent log analysis to improve the accuracy of the analysis.
[0175] When the target application is running, the reporting unit 115 prints logs using the print function and reports the printed logs to the configuration terminal.
[0176] Specifically, when the printed log is reported to the configuration terminal, a pre-configured warning level list is obtained, wherein the warning level list stores a correspondence between abnormal categories and warning levels;
[0177] Query the warning level list using the abnormality category;
[0178] Determine the queried warning level corresponding to the abnormality category as the target level;
[0179] generating early warning information according to the target level;
[0180] The warning information is added to the printed log and reported to the configuration terminal.
[0181] Through the above implementation, different levels of warnings can be issued according to different abnormality categories, so that different priorities can be subsequently processed according to different levels.
[0182] Furthermore, after the printed log is reported to the configuration terminal, relevant staff can assist in log analysis, or the configuration terminal can automatically parse the log to identify the cause of the fault and eliminate the fault in a timely manner.
[0183] For example: after embedding a log printing plug-in in the application's installation package, when a program exception is detected, the exception is reported to the background system in a timely manner, and the function that may cause the exception is analyzed. Further, a parameter printing method is added to the function that may cause the exception to generate a printing function. At this time, the generated printing function will be used to obtain targeted logs for possible abnormal functions, and the obtained logs will be returned to the background system to facilitate the background system to analyze and resolve the cause of the exception.
[0184] This embodiment eliminates the need to repeatedly package, upload, modify, and print logs when troubleshooting problems, effectively improving exception handling efficiency.
[0185] It should be noted that in order to further improve the security of data and prevent data from being maliciously tampered with, the log printing plug-in can be stored in the blockchain node.
[0186] It can be seen from the above technical solution that the present invention can create a log printing plug-in and embed the log printing plug-in into the target installation package, and use the log printing plug-in to monitor the target application installed based on the target installation package. During the monitoring process, the function function and parameter printing method issued by the target application through the specified page are received, the function function and the parameter printing method are compiled into a class to obtain the target class, the old class corresponding to the target class is obtained, and the target class is used to intercept the old class. While intercepting the old class, the functional characteristics of the old class are not affected, and the operation status of each function function is monitored. During the interception process, when a function function exception is detected, the detected function function is determined as an abnormal function, the exception stack information of the abnormal function is obtained, and based on the elimination The information push mechanism reports the exception stack information to the configuration terminal, automatically detects the exception of the application without the user's perception, and avoids affecting the user's use. When the printing position fed back by the configuration terminal based on the analysis of the exception stack information is received, a printing function is constructed at the printing position based on the parameter printing method, and the printing function is sent to the target application for targeted parameter printing. This not only effectively obtains the exception data, which is convenient for subsequent analysis and use, but also reduces data redundancy and improves analysis efficiency. When the target application is running, the printing function is used to print logs, and the printed logs are reported to the configuration terminal. When troubleshooting, there is no need to repeatedly package, put on the shelf, modify and print logs, which effectively improves the efficiency of exception handling.
[0187] like Figure 3 FIG. 1 is a structural diagram of a computer device according to a preferred embodiment of the present invention for implementing an application exception handling method based on log printing.
[0188] The computer device 1 may include a memory 12 , a processor 13 , and a bus, and may further include a computer program stored in the memory 12 and executable on the processor 13 , such as an application exception handling program based on log printing.
[0189] Those skilled in the art will understand that the schematic diagram is merely an example of the computer device 1 and does not constitute a limitation on the computer device 1. The computer device 1 may have either a bus structure or a star structure. The computer device 1 may also include more or less other hardware or software than shown in the figure, or a different arrangement of components. For example, the computer device 1 may also include input and output devices, network access devices, etc.
[0190] It should be noted that the computer device 1 is only an example. Other existing or future electronic products that are suitable for the present invention should also be included in the scope of protection of the present invention and included here by reference.
[0191] The memory 12 includes at least one type of readable storage medium, including a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 12 may be an internal storage unit of the computer device 1, such as a mobile hard disk of the computer device 1. In other embodiments, the memory 12 may also be an external storage device of the computer device 1, such as a plug-in mobile hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device 1. Furthermore, the memory 12 may also include both an internal storage unit of the computer device 1 and an external storage device. The memory 12 can not only be used to store application software installed on the computer device 1 and various types of data, such as the code of the application exception handling program based on log printing, but can also be used to temporarily store data that has been output or is about to be output.
[0192] In some embodiments, the processor 13 may be composed of an integrated circuit, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The processor 13 is the control core (Control Unit) of the computer device 1, connecting the various components of the entire computer device 1 using various interfaces and circuits. It executes or executes programs or modules stored in the memory 12 (such as executing an application exception handling program based on log printing) and calls data stored in the memory 12 to perform various functions of the computer device 1 and process data.
[0193] The processor 13 executes the operating system of the computer device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned embodiments of the application exception handling method based on log printing, for example Figure 1 Steps shown.
[0194] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to implement the present invention. The one or more modules / units may be a series of computer-readable instruction segments capable of performing specific functions, which describe the execution process of the computer program in the computer device 1. For example, the computer program may be divided into a creation unit 110, a monitoring unit 111, a receiving unit 112, a compilation unit 113, an interception unit 114, a reporting unit 115, and a delivery unit 116.
[0195] The integrated unit implemented in the form of a software functional module can be stored in a computer-readable storage medium. The software functional module stored in a storage medium includes a number of instructions for causing a computer device (which can be a personal computer, computer equipment, or network equipment, etc.) or a processor to execute the portion of the application exception handling method based on log printing described in various embodiments of the present invention.
[0196] If the modules / units integrated in the computer device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the present invention can also implement all or part of the processes in the above-mentioned method embodiments by instructing relevant hardware devices through a computer program. The computer program can be stored in a computer-readable storage medium. When executed by a processor, the computer program can implement the steps of each of the above-mentioned method embodiments.
[0197] The computer program includes computer program code, which may be in source code form, object code form, executable file, or some intermediate form. The computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory, etc.
[0198] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0199] Blockchain, as used in this article, refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, the platform product service layer, and the application service layer.
[0200] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 The figure shows that only one straight line is used, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13.
[0201] Although not shown, the computer device 1 may also include a power supply (such as a battery) to power various components. Preferably, the power supply can be logically connected to the at least one processor 13 via a power management device, thereby implementing functions such as charging management, discharging management, and power consumption management through the power management device. The power supply may also include one or more DC or AC power supplies, a recharging device, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components. The computer device 1 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be detailed here.
[0202] Furthermore, the computer device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the computer device 1 and other computer devices.
[0203] Optionally, the computer device 1 may further include a user interface, which may be a display or an input unit (such as a keyboard). Optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display may also be appropriately referred to as a display screen or a display unit, and is used to display information processed in the computer device 1 and to display a visual user interface.
[0204] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0205] Figure 3 Only the computer device 1 having components 12-13 is shown, and it can be understood by those skilled in the art that Figure 3 The structure shown does not constitute a limitation on the computer device 1 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0206] Combine Figure 1 The memory 12 in the computer device 1 stores a plurality of instructions to implement an application exception handling method based on log printing, and the processor 13 can execute the plurality of instructions to implement:
[0207] Create a log printing plug-in and embed the log printing plug-in into the target installation package;
[0208] Using the log printing plug-in, monitoring the target application installed based on the target installation package;
[0209] During the monitoring process, the function and parameter printing method sent by the target application through the specified page are received;
[0210] Compile the functional function and the parameter printing method into a class to obtain a target class;
[0211] Obtaining an old class corresponding to the target class, and intercepting the old class using the target class;
[0212] During the interception process, when a function exception is detected, the detected function is determined as an abnormal function, the abnormal stack information of the abnormal function is obtained, and the abnormal stack information is reported to the configuration terminal based on the message push mechanism;
[0213] When receiving the print position fed back by the configuration terminal based on the analysis of the exception stack information, constructing a print function based on the parameter printing method at the print position, and sending the print function to the target application;
[0214] When the target application is running, the print function is used to print logs, and the printed logs are reported to the configuration terminal.
[0215] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0216] In the several embodiments provided herein, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical functional division, and actual implementation may employ other division methods.
[0217] The present invention can be used in a wide variety of general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0218] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0219] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional modules.
[0220] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0221] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the invention is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0222] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices described in the present invention may also be implemented by a single unit or device through software or hardware. Terms such as first and second are used to indicate names and do not imply any particular order.
[0223] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for handling application exceptions based on log printing, characterized in that: The application exception handling method based on log printing includes: Create a log printing plug-in and embed the log printing plug-in into the target installation package; Using the log printing plug-in, monitoring the target application installed based on the target installation package; During the monitoring process, receiving the function and parameter printing method issued by the target application through the specified page; Compile the functional function and the parameter printing method into a class to obtain a target class; Obtaining an old class corresponding to the target class, and intercepting the old class using the target class; During the interception process, when a function exception is detected, the detected function is determined as an abnormal function, the abnormal stack information of the abnormal function is obtained, and the abnormal stack information is reported to the configuration terminal based on the message push mechanism; When receiving the print position fed back by the configuration terminal based on the analysis of the exception stack information, constructing a print function based on the parameter printing method at the print position, and sending the print function to the target application; When the target application is running, using the print function to print a log, and reporting the printed log to the configuration terminal; When the print function is sent to the target application, the method further includes: Prompt information is added to the print function, wherein the prompt information is used to prompt the user of the target application to run the target application within a preset time range, and the number of runs is greater than or equal to the configured number of runs.
2. The application exception handling method based on log printing according to claim 1, characterized in that: The utilizing the target class to intercept the old class comprises: Adopt AOP principle to obtain the functional functions of the old class; Before executing the function function of the old class, the corresponding function in the target class is executed to obtain an execution result; Returns the execution result.
3. The application exception handling method based on log printing according to claim 1, characterized in that: The method further comprises: During the interception process, when the Exception class and / or a subclass of the Exception class is detected, the function that generates the Exception class and / or the subclass of the Exception class is obtained; The acquired functional function is determined as the abnormal function.
4. The application exception handling method based on log printing according to claim 1, characterized in that: The method further comprises: When receiving a running problem of the target application reported by a user, the target application is monitored by using the log printing plug-in.
5. The application exception handling method based on log printing according to claim 1, characterized in that: The method further comprises: The configuration terminal uses the java.net.ConnectException function to locate the exception category and identifies sub-functions with failure risks in the exception function based on the ThreadPoolExecutor$Worker.run function; The printing position is generated according to the exception type and the sub-function.
6. The application exception handling method based on log printing according to claim 5, characterized in that: The constructing of a printing function based on the parameter printing method at the printing position comprises: Acquire the sub-function according to the printing position; Add the parameter printing method in the sub-function to obtain the printing function.
7. The application exception handling method based on log printing according to claim 5, characterized in that: When reporting the printed log to the configuration terminal, the method further includes: Obtaining a pre-configured warning level list, wherein the warning level list stores a correspondence between abnormal categories and warning levels; Query the warning level list using the abnormality category; Determine the queried warning level corresponding to the abnormality category as the target level; generating early warning information according to the target level; The warning information is added to the printed log and reported to the configuration terminal.
8. An application exception handling device based on log printing, characterized in that: The application exception handling device based on log printing includes: A creation unit, configured to create a log printing plug-in and embed the log printing plug-in into a target installation package; A monitoring unit, configured to monitor a target application installed based on the target installation package using the log printing plug-in; A receiving unit, configured to receive, during the monitoring process, the function and parameter printing method issued by the target application via a specified page; A compiling unit, configured to compile the functional function and the parameter printing method into a class to obtain a target class; an interception unit, configured to obtain an old class corresponding to the target class, and intercept the old class using the target class; A reporting unit is configured to, during the interception process, determine that a function is abnormal when an abnormal function is detected, obtain abnormal stack information of the abnormal function, and report the abnormal stack information to the configuration terminal based on a message push mechanism; a sending unit, configured to, upon receiving a print position fed back by the configuration terminal based on parsing the exception stack information, construct a print function based on the parameter printing method at the print position, and send the print function to the target application; The reporting unit is further configured to print a log using the print function when the target application is running, and report the printed log to the configuration terminal; When sending the print function to the target application, it is also used to: Prompt information is added to the print function, wherein the prompt information is used to prompt the user of the target application to run the target application within a preset time range, and the number of runs is greater than or equal to the configured number of runs.
9. A computer device, characterized in that: The computer device comprises: a memory storing at least one instruction; and The processor executes the instructions stored in the memory to implement the application exception handling method based on log printing according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor in a computer device to implement the application exception handling method based on log printing according to any one of claims 1 to 7.
Citation Information
Patent Citations
Application program analysis method and device
CN107291586A
Abnormal log monitoring method and device and electronic equipment
CN113094225A