Log capturing method and apparatus, electronic device, and storage medium

By embedding and cross-domain processing of log capture methods for cloud-native application frameworks and pages, the problem of difficulty in capturing error logs of HTML5 plugins in cloud-native applications is solved, achieving accurate error location and improved fault tolerance.

CN114185740BActive Publication Date: 2026-02-13GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111506136.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-10
Publication Date
2026-02-13
Estimated Expiration
2041-12-10

AI Technical Summary

Technical Problem

Existing cloud-native applications struggle to effectively and uniformly capture error logs generated by HTML5 plugins during runtime, resulting in insufficient troubleshooting and fault tolerance capabilities.

Method used

By identifying the application, framework, and plugin page whose logs are to be captured, the logs are captured using the capture methods corresponding to the framework and page, and stored on the server. This includes embedding and cross-domain processing of framework capture methods and page capture methods for different scenarios.

Benefits of technology

It enables accurate log capture of cloud-native applications, locating the file or line of code that causes the error, enhancing fault tolerance, and facilitating troubleshooting and risk elimination.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114185740B_ABST
    Figure CN114185740B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a log capturing method and device, electronic equipment and storage medium, the method comprises: determining the application program of the log to be captured, and determining the framework adopted by the application program of the log to be captured, and determining at least one page of the plug-in in the application program of the log to be captured; find the framework capturing mode corresponding to the framework, use the framework capturing mode to capture the log, and store it to the server; find the page capturing mode corresponding to the at least one page, use the page capturing mode to capture the log, and store it to the server. Thus, for different scenarios such as the framework adopted by the application program of the log to be captured, at least one page of the plug-in in the application program of the log to be captured, etc., the corresponding capturing mode is found, and the log is captured one by one, the fault tolerance capability of cloud native application program can be realized, the error file or even code line can be accurately and effectively located, and the solution of fault and the elimination of hidden danger have a positive promoting effect.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of Internet, and in particular, to a log capturing method and device, electronic equipment and storage medium. BACKGROUND

[0002] With the continuous expansion and diversification of business and demand, the architecture of application programs has evolved from traditional monolithic architecture to cloud native architecture. Using cloud native architecture can avoid the bottlenecks of monolithic architecture, such as long deployment time, difficult code maintenance, difficulty in modular expansion, and the possibility of system collapse caused by a small bug. Cloud native architecture has the advantages of on-demand use of custom services, scalable elasticity, sharing, high availability, remote monitoring, location-independent network access, remote deployment, standardized delivery, and the like.

[0003] In related technologies, application programs using cloud native architecture are referred to as cloud native application programs, which often run in the form of embedding html5 plugins. With the continuous expansion of cloud native application programs, there is an urgent need for a solution that can uniformly capture error logs generated by html5 plugins to enhance the fault tolerance of cloud native application programs, accurately and effectively locate the error files or even code lines, and positively promote the solution of faults and the elimination of hidden dangers. SUMMARY

[0004] To solve the above technical problem that with the continuous expansion of cloud native application programs, there is an urgent need for a solution that can uniformly capture error logs generated by html5 plugins to enhance the fault tolerance of cloud native application programs, accurately and effectively locate the error files or even code lines, and positively promote the solution of faults and the elimination of hidden dangers, embodiments of the present application provide a log capturing method, device, electronic equipment and storage medium.

[0005] In a first aspect of the embodiments of the present application, a log capturing method is first provided, the method comprising:

[0006] determining an application program to be captured, determining a framework adopted by the application program to be captured, and determining at least one page of a plugin in the application program to be captured;

[0007] finding a framework capturing manner corresponding to the framework, performing log capturing using the framework capturing manner, and storing to a server;

[0008] finding a page capturing manner corresponding to at least one of the pages, performing log capturing using the page capturing manner, and storing to the server.

[0009] In an optional implementation, the searching for the framework capturing mode corresponding to the framework and the log capturing by using the framework capturing mode comprises:

[0010] determining whether the framework is a target framework;

[0011] if the framework is the target framework, obtaining a first code of capturing exception corresponding to an application program of the log to be captured, searching for a framework capturing mode corresponding to the framework;

[0012] embedding the first code of capturing exception into the framework capturing mode, and performing log capturing by using the framework capturing mode with the code embedding.

[0013] In an optional implementation, the searching for the framework capturing mode corresponding to the framework and the log capturing by using the framework capturing mode further comprises:

[0014] if the framework is not the target framework, searching for a page capturing mode corresponding to a non-target framework;

[0015] embedding the first code of capturing exception into the page capturing mode, and performing log capturing by using the page capturing mode with the code embedding.

[0016] In an optional implementation, the searching for the page capturing mode corresponding to at least one of the pages and the log capturing by using the page capturing mode comprises:

[0017] obtaining a local log capturing requirement, and determining a target page in the at least one of the pages according to the local log capturing requirement;

[0018] obtaining a second code of capturing exception corresponding to the target page, and searching for a local page capturing mode corresponding to the target page;

[0019] embedding the second code of capturing exception into the local page capturing mode, and performing log capturing by using the local page capturing mode with the code embedding.

[0020] In an optional implementation, the searching for the page capturing mode corresponding to at least one of the pages and the log capturing by using the page capturing mode comprises:

[0021] obtaining a global log capturing requirement, and determining all of the pages in the at least one of the pages according to the global log capturing requirement;

[0022] obtaining a third code of capturing exception corresponding to all of the pages, and searching for a global page capturing mode corresponding to all of the pages;

[0023] The third code of the capturing exception is embedded into the global page capturing mode, and the global page capturing mode after the code embedding is used for log capturing.

[0024] In an optional embodiment, the method further comprises:

[0025] In an optional embodiment, the method further comprises:

[0026] If the second code of the capturing exception is stored in the target page, the second code corresponding to the target page is obtained, and the local page capturing mode corresponding to the target page is searched.

[0027] In an optional embodiment, the method further comprises:

[0028] If the second code of the capturing exception is not stored in the target page, the remaining pages in which the second code of the capturing exception is stored are determined.

[0029] In an optional embodiment, the remaining pages include any one of the pages other than the target page.

[0030] The first network information of the target page is obtained, and the second network information of the remaining pages is obtained.

[0031] If the first network information is consistent with the second network information, the second code of the capturing exception corresponding to the target page is obtained, and the local page capturing mode corresponding to the target page is searched.

[0032] The second code of the capturing exception is embedded into the local page capturing mode, and the local page capturing mode after the code embedding is used for log capturing.

[0033] If the first network information is not consistent with the second network information, cross-domain processing is performed, wherein the cross-domain processing includes that the client and the server respectively perform cross-domain settings.

[0034] In an optional embodiment, the method further comprises:

[0035] In an optional embodiment, the method further comprises:

[0036] If the third code for capturing exceptions corresponding to each of the pages is stored on each of the pages, the third code for capturing exceptions corresponding to all the pages is acquired, and a global page capturing mode corresponding to all the pages is searched.

[0037] In an optional embodiment, the method further comprises:

[0038] If the third code for capturing exceptions corresponding to each of the pages is not stored on each of the pages, third network information corresponding to each of the pages is acquired;

[0039] If the third network information corresponding to each of the pages is consistent, the third code for capturing exceptions corresponding to all the pages is acquired, and a global page capturing mode corresponding to all the pages is searched;

[0040] The third code for capturing exceptions is embedded in the global page capturing mode, and log capturing is performed by using the global page capturing mode after the code embedding.

[0041] If the third network information corresponding to each of the pages is not consistent, cross-domain processing is performed, wherein the cross-domain processing comprises cross-domain settings performed by a client and a server respectively.

[0042] In a second aspect of the embodiments of the present application, a log capturing device is provided, and the device comprises:

[0043] A program determining module is configured to determine an application program of logs to be captured;

[0044] A framework and page determining module is configured to determine a framework adopted by the application program of logs to be captured, and determine at least one page of a plug-in in the application program of logs to be captured;

[0045] A first capturing module is configured to search for a framework capturing mode corresponding to the framework, perform log capturing by using the framework capturing mode, and store the log capturing to a server;

[0046] A second capturing module is configured to search for a page capturing mode corresponding to at least one of the pages, perform log capturing by using the page capturing mode, and store the log capturing to the server.

[0047] In a third aspect of the embodiments of the present application, an electronic device is further provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;

[0048] The memory is configured to store a computer program;

[0049] The processor is configured to execute the program stored on the memory, and realize the log capturing method in the first aspect.

[0050] In a fourth aspect of the embodiments of the present application, a storage medium is further provided, wherein the storage medium stores instructions which, when executed on a computer, cause the computer to perform the log capturing method in the first aspect.

[0051] In a fifth aspect of the embodiments of the present application, a computer program product containing instructions which, when executed on a computer, cause the computer to perform the log capturing method in the first aspect is further provided.

[0052] The technical solution provided by the embodiments of the present application determines the application program of the log to be captured, and determines the framework adopted by the application program of the log to be captured, and determines at least one page of the plug-in in the application program of the log to be captured, finds a framework capturing manner corresponding to the framework, performs log capturing by using the framework capturing manner, and stores to a server, finds a page capturing manner corresponding to the at least one page, performs log capturing by using the page capturing manner, and stores to the server. In this way, for different scenarios such as the framework adopted by the application program of the log to be captured and at least one page of the plug-in in the application program of the log to be captured, the corresponding capturing manner is found, and the log capturing is performed one by one in a targeted manner, which can enhance the fault tolerance capability of the cloud native application program, can accurately and effectively locate the error file or even the code line, and has a positive promoting effect on solving the fault and eliminating the hidden danger. BRIEF DESCRIPTION OF DRAWINGS

[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and serve to explain the principles of the present application together with the specification.

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those skilled in the field, other drawings can also be obtained based on these drawings without any creative effort.

[0055] Figure 1 An implementation flowchart of a log capturing method shown in the embodiments of the present application;

[0056] Figure 2 An implementation flowchart of another log capturing method shown in the embodiments of the present application;

[0057] Figure 3 An implementation flowchart of another log capturing method shown in the embodiments of the present application;

[0058] Figure 4 A structure diagram of a log capturing device shown in the embodiments of the present application;

[0059] Figure 5 This is a schematic diagram of the structure of an electronic device shown in an embodiment of the present invention. Detailed Implementation

[0060] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0061] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0062] like Figure 1 The diagram illustrates the implementation flow of a log capture method according to an embodiment of the present invention. This method is applied to a processor and may specifically include the following steps:

[0063] S101, determine the application whose logs are to be captured, determine the framework used by the application whose logs are to be captured, and determine at least one page of the plugin in the application whose logs are to be captured.

[0064] In this embodiment of the invention, there are multiple applications, i.e., multiple APPs. At this time, one application can be selected for log capture, specifically error log capture, to enhance the fault tolerance of the application. It can accurately and effectively locate the file or even line of code that is erroneous, which has a positive promoting effect on solving faults and eliminating hidden dangers.

[0065] Based on this, in this embodiment of the invention, the application to be captured can be determined, which may specifically be an application using a cloud-native architecture (cloud-native application), and the framework used by the application to be captured can be determined, and at least one page of the plugin in the application to be captured can be determined.

[0066] For example, in the embodiment of the present application, the cloud-native application to be captured log is determined, further, the framework (such as vue) adopted by the cloud-native application to be captured log is determined, and at least one html5 page of the html5 plug-in in the cloud-native application to be captured log is determined.

[0067] It should be noted that the framework adopted by the application to be captured log may be, for example, an MVVM framework such as vue, react, angular, the plug-in in the application to be captured log may be, for example, an html5 plug-in, and the at least one page of the corresponding plug-in may be, for example, an html5 page, and the embodiment of the present application does not limit this.

[0068] S102, find a framework capturing mode corresponding to the framework, perform log capturing by using the framework capturing mode, and store to a server.

[0069] In the embodiment of the present application, for the framework adopted by the application to be captured log, a framework capturing mode corresponding to the framework can be found, so that log capturing can be performed by using the framework capturing mode and stored to a server. In this way, for the framework adopted by the application to be captured log and the like, the corresponding capturing mode is found, and log capturing is performed one by one in a targeted manner and stored to a server.

[0070] In the embodiment of the present application, for the framework adopted by the application to be captured log, it can be judged whether the framework is a target framework, if the framework is a target framework, a first code for capturing an exception corresponding to the application to be captured log is obtained, a framework capturing mode corresponding to the framework is found, the first code for capturing the exception is embedded into the framework capturing mode, and log capturing is performed by using the framework capturing mode after code embedding.

[0071] For example, for the framework adopted by the cloud-native application to be captured log, it is judged whether the framework is an MVVM (Model-View-ViewModel) framework, if the framework is an MVVM framework, a first code for capturing an exception corresponding to the cloud-native application to be captured log is obtained, a framework capturing mode corresponding to the framework is found, the first code for capturing the exception is embedded into the framework capturing mode, and log capturing is performed by using the framework capturing mode after code embedding.

[0072] If the cloud-native application to be captured logs adopts the vue2.x framework, the config.errorHandler method (i.e., the above framework capture method) is used, specifically Vue.config.errorHandler = function (err, vm, info) {capture the first code of the exception}. The information in err is: message is the exception information; name is the exception name; script is the exception script url; line is the exception line number; column is the exception column number; stack is the exception stack information. vm is the Vue instance that throws the exception, and info is the Vue-specific error information, such as the life cycle hook where the error occurs.

[0073] If the cloud-native application to be captured logs adopts the React16.x framework, the ErrorBoundary method (i.e., the above framework capture method) is used. Specifically, class ErrorBoundary extends React.Component {capture the first code of the exception}, and in the first code for capturing the exception, the componentDidCatch (error, info) function is used to capture the code, and logErrorToMyService is used to upload the specific exception log to the server.

[0074] If the cloud-native application to be captured logs adopts the angular7 framework, the above framework capture method uses an ErrorHandler created by inheriting the @angular / core interface, and then implements the handleError() method, and then handles the exception in the providers configuration through AppGlobalErrorhandler. Thus, the framework capture method is different for different frameworks, and the exception log can be captured for different frameworks.

[0075] In addition, for the framework adopted by the application to be captured logs, if the framework is not the target framework, the corresponding page capture method of the non-target framework is found, the first code for capturing the exception is embedded in the page capture method, and the page capture method embedded with the code is used for log capture. It should be noted that the page capture method here includes the page capture method and the global page capture method, which will be described in detail later.

[0076] For example, if the framework adopted by the cloud-native application whose logs are to be captured is not an MVVM framework, a page capturing manner corresponding to the non-MVVM framework can be found, the first code for capturing the exception is embedded in the page capturing manner, and the page capturing manner after the code embedding is used for log capturing. In this way, for the cloud-native application whose logs are to be captured and which adopts the MVVM framework and the non-MVVM framework, there are corresponding capturing manners, and the exception logs of different frameworks can be captured respectively. The MVVM framework exception, the non-MVVM framework exception, and other logs can be uploaded to the exception log server and stored.

[0077] S103, find a page capturing manner corresponding to at least one of the pages, use the page capturing manner for log capturing, and store to the server.

[0078] In the embodiment of the application, for at least one page of the plug-in in the application whose logs are to be captured, a page capturing manner corresponding to the at least one page can be found, the page capturing manner is used for log capturing, and the log is stored to the server. In this way, for at least one page of the plug-in in the application whose logs are to be captured, a corresponding capturing manner is found, and log capturing is performed one by one.

[0079] Specifically, as shown in Figure 2 Another embodiment of the log capturing method provided by the application is shown in the flowchart of the implementation process of the method, which is applied to a processor and can specifically include the following steps:

[0080] S201, obtain a local log capturing requirement, and determine a target page in at least one of the pages according to the local log capturing requirement.

[0081] In the embodiment of the application, according to the requirement of (exception) log capturing, for at least one page of the plug-in in the application whose logs are to be captured, it can be first determined whether to capture (exception) logs locally or globally, and if the (exception) logs are captured locally, a local log capturing requirement can be set in advance.

[0082] Based on this, in the embodiment of the application, a local log capturing requirement can be obtained, so that it can be known that (exception) logs are captured locally. Further, for at least one page of the plug-in in the application whose logs are to be captured, a target page in at least one of the pages can be determined according to the local log capturing requirement.

[0083] For example, in the embodiment of the present application, the local log capture requirement is acquired, in which a certain html5 page is recorded, based on which it can be known that the log is captured (abnormally) locally, and further, for at least one html5 page of the html5 plug-in of the cloud native application to be captured, the target html page of the at least one html5 page can be determined according to the local log capture requirement.

[0084] In S202, the second code for capturing exceptions corresponding to the target page is acquired, and the local page capture mode corresponding to the target page is found.

[0085] In the embodiment of the present application, on the one hand, the second code for capturing exceptions corresponding to the target page can be acquired, and on the other hand, the local page capture mode corresponding to the target page can be found.

[0086] For example, in the embodiment of the present application, on the one hand, the second code for capturing exceptions corresponding to the target html page is acquired, and on the other hand, the local page capture mode corresponding to the target html page, i.e. the try catch mode, can be found.

[0087] In the embodiment of the present application, it can be detected whether the second code for capturing exceptions corresponding to the target page is stored in the target page, if the second code for capturing exceptions is stored in the target page, the second code corresponding to the target page is acquired, and the local page capture mode corresponding to the target page is found.

[0088] For example, in the embodiment of the present application, it is detected whether the second code for capturing exceptions corresponding to the target html page is stored in the target html page, if the second code for capturing exceptions is stored in the target html page, it indicates that the code for capturing exceptions is located in the target html page, at this time, the second code corresponding to the target html page can be acquired, and the try catch mode corresponding to the target html page is found.

[0089] In addition, if the second code for capturing exceptions is not stored in the target page, the remaining pages in which the second code for capturing exceptions is stored are determined, wherein the remaining pages include any page other than the target page in at least one page. The first network information of the target page is acquired, and the second network information of the remaining pages is acquired, if the first network information is consistent with the second network information, it can jump to S202. If the first network information is not consistent with the second network information, cross-domain processing is performed, wherein the cross-domain processing includes that the client and the server perform cross-domain setting respectively.

[0090] For example, if the second code for capturing the exception is not stored in the target html page, it indicates that the code for capturing the exception is located in the remaining html pages, and the remaining html pages including any html page except the target html page in the at least one html page can be determined.

[0091] For example, the target html page is html page a, and the remaining html page is html page b, and the case is that the exception occurs in the html page a, but the code for capturing the exception is in the html page b. Based on this, the first network information of the target html page is acquired, the second network information of the remaining html page is acquired, if the first network information is consistent with the second network information, it indicates that the cross-domain processing is not needed, and the step S202 is jumped to continue to be executed.

[0092] If the first network information is not consistent with the second network information, the cross-domain processing is needed, and the cross-domain processing includes that the client and the server respectively perform the cross-domain setting. Specifically, the script attribute crossorigin is configured as anonymous in the client, and the Access-Control-Allow-Origin needs to be added in the server side. In this way, the local exception, the cross-domain exception, the non-cross-domain exception and the like can be uploaded to the exception log server and stored.

[0093] It should be noted that the first network information can be specifically the network protocol, the ip address and the port number used by the target page, and the second network information can be specifically the network protocol, the ip address and the port number used by the remaining page, and the embodiment of the application is not limited thereto.

[0094] S203, the second code for capturing the exception is embedded into the local page capturing mode, and the local page capturing mode after the code embedding is used for log capturing.

[0095] In the embodiment of the application, the second code for capturing the exception can be embedded into the local page capturing mode, and the local page capturing mode after the code embedding is used for log capturing, so that the exception log in the target page can be captured.

[0096] For example, if the exception is captured in the target html page, the second code for capturing the exception is embedded into the try catch mode, and the try catch mode after the code embedding is used for log capturing, that is, the try{…}catch(e){the second code for capturing the exception} is used to capture the local exception.

[0097] Specifically, as Figure 3As shown, an implementation flow diagram of another log capturing method provided by the embodiment of the present application is shown, which is applied to a processor and can specifically include the following steps:

[0098] S301, obtaining a global log capturing requirement, and determining all the pages in at least one page according to the global log capturing requirement.

[0099] In the embodiment of the present application, according to the requirement of (abnormal) log capturing, for at least one page of the plug-in in the application program to be captured, it can be firstly determined whether to capture (abnormal) log locally or globally, and if it is to capture (abnormal) log globally, the global log capturing requirement can be set in advance.

[0100] Based on this, in the embodiment of the present application, the global log capturing requirement can be obtained, so that it can be known that (abnormal) log is captured globally, and further, for at least one page of the plug-in in the application program to be captured, all the pages in at least one page can be determined according to the global log capturing requirement.

[0101] For example, in the embodiment of the present application, the global log capturing requirement is obtained, wherein all html5 pages are recorded in the global log capturing requirement, based on which it can be known that (abnormal) log is captured globally, and further, for at least one html5 page of the html5 plug-in in the cloud native application to be captured, all the html5 pages in at least one html5 page can be determined according to the global log capturing requirement.

[0102] S302, obtaining a third code for capturing an exception corresponding to all the pages, and searching for a global page capturing manner corresponding to all the pages.

[0103] In the embodiment of the present application, on the one hand, the third code for capturing an exception corresponding to all the pages can be obtained, and on the other hand, the global page capturing manner corresponding to all the pages can be searched, for example, in the embodiment of the present application, on the one hand, the third code for capturing an exception corresponding to all the html5 pages is obtained, and on the other hand, the global page capturing manner corresponding to all the html5 pages, i.e. the manner of window.onerror, can be searched.

[0104] In the embodiment of the present application, it is detected whether the third code for capturing an exception corresponding to each page in all the pages is stored on each page, if the third code for capturing an exception corresponding to each page is stored on each page, the third code for capturing an exception corresponding to all the pages is obtained, and the global page capturing manner corresponding to all the pages is searched.

[0105] For example, in the embodiment of the present application, it is detected whether the third code corresponding to the capture exception of each html5 page is stored on each html5 page. If the third code corresponding to the capture exception of each html5 page is stored on each html5 page, as shown in Table 1 below, the third code corresponding to the capture exception of all html5 pages is acquired, and the global html5 page capture mode corresponding to all html5 pages is searched.

[0106] html5 page Third code to capture exceptions Code stored html5 page html5 page a Third code 1 to capture exceptions html5 page a html5 page b Second code to capture exceptions html5 page b …… …… ……

[0107] Table 1

[0108] In addition, if the third code corresponding to the capture exception of each page is not stored on each page, the third network information corresponding to each page is acquired. If the third network information corresponding to each page is consistent, the step S302 is jumped to and the execution is continued. If the third network information corresponding to each page is not consistent, cross-domain processing is performed, wherein the cross-domain processing includes cross-domain settings performed by the client and the server respectively.

[0109] For example, if the third code corresponding to the capture exception of each html5 page is not stored on each html5 page, for example, the exception occurs in the html5 page a, but the code for capturing the exception is in the html5 page b. At this time, the third network information corresponding to each html5 page is acquired. If the third network information corresponding to each html5 page is consistent, the step S302 is jumped to and the execution is continued.

[0110] If the third network information corresponding to each html5 page is not consistent, cross-domain processing is performed, wherein the cross-domain processing includes cross-domain settings performed by the client and the server respectively. Specifically, the script attribute crossorigin is configured as anonymous on the client side, and Access-Control-Allow-Origin needs to be added on the server side.

[0111] It should be noted that the third network information can be specifically the network protocol, the IP address and the port number used by each page, and the embodiment of the present application does not limit this.

[0112] S303, the third code for capturing the exception is embedded into the global html5 page capture mode, and the global html5 page capture mode after the code embedding is used for log capture.

[0113] In the embodiment of the present application, the third code for capturing the exception can be embedded into the global html5 page capture mode, and the global html5 page capture mode after the code embedding is used for log capture, so that the exception log inside all html5 pages can be captured.

[0114] For example, if all html5 html5 pages need to capture exceptions in the process of doing an operation, the third code for capturing exceptions is embedded in the way of window.onerror, and the log capture is performed by using the embedded window.onerror, that is, in the way of window.onerror = function (errorMessage, scriptURI, lineNo, columnNo, error) {specific code for capturing exceptions}, where: errorMessage is exception information; scriptURI is exception file path; lineNo is exception line number; columnNo is exception column number; and error is exception stack information.

[0115] Through the above description of the technical solutions provided by the embodiments of the present application, the application program to be captured is determined, the framework adopted by the application program to be captured is determined, at least one page of the plug-in in the application program to be captured is determined, the framework capture mode corresponding to the framework is found, the log capture is performed by using the framework capture mode, and is stored to the server, the page capture mode corresponding to the at least one page is found, the log capture is performed by using the page capture mode, and is stored to the server.

[0116] In this way, for different scenarios such as the framework adopted by the application program to be captured, at least one page of the plug-in in the application program to be captured, etc., the corresponding capture mode is found in different scenarios such as local, global, cross-domain, MVVM (Model-View-ViewModel: Model-View-ViewModel), and the log capture is performed one by one in a targeted manner. The local exception, global exception, cross-domain exception, non-cross-domain exception, MVVM architecture exception, non-MVVM architecture exception, etc. The logs are uploaded to the exception log server and stored, which can enhance the fault tolerance of the cloud native application, accurately and effectively locate the error file or even the code line, and has a positive promoting effect on solving faults and eliminating hidden dangers.

[0117] Corresponding to the above method embodiments, the embodiments of the present application also provide a log capture device, as shown in Figure 4 The device can include a program determination module 410, a framework / page determination module 420, a first capture module 430, and a second capture module 440.

[0118] The program determination module 410 is configured to determine an application program to be captured.

[0119] The framework / page determination module 420 is configured to determine a framework adopted by the application program to be captured, and determine at least one page of a plug-in in the application program to be captured.

[0120] The first capture module 430 is used to find the frame capture method corresponding to the frame, use the frame capture method to capture logs, and store them on the server.

[0121] The second capture module 440 is used to find the page capture method corresponding to at least one of the pages, use the page capture method to capture logs, and store them in the server.

[0122] This invention also provides an electronic device, such as... Figure 5 As shown, it includes a processor 51, a communication interface 52, a memory 53, and a communication bus 54. The processor 51, the communication interface 52, and the memory 53 communicate with each other through the communication bus 54.

[0123] Memory 53 is used to store computer programs;

[0124] When processor 51 executes the program stored in memory 53, it performs the following steps:

[0125] The system identifies the application whose logs are to be captured, the framework used by the application, and at least one page of a plugin within the application. It then locates a framework capture method corresponding to the framework, uses that method to capture logs, and stores the logs on the server. Finally, it locates a page capture method corresponding to at least one of the pages, uses that method to capture logs, and stores the logs on the server.

[0126] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.

[0127] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0128] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0129] The processor described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; or can be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0130] In yet another embodiment provided by the present application, a storage medium is provided, which stores instructions that, when executed on a computer, cause the computer to perform the log capturing method according to any one of the above embodiments.

[0131] In yet another embodiment provided by the present application, a computer program product is provided, which contains instructions that, when executed on a computer, cause the computer to perform the log capturing method according to any one of the above embodiments.

[0132] In the above embodiments, the implementation can be wholly or partially in software, hardware, firmware or any combination thereof. When implemented in software, the implementation can be in the form of computer program product. The computer program product includes one or more computer instructions. When loaded and executed by a computer, the computer program instructions generate the processes or functions described in the embodiments of the present application wholly or partially. The computer can be a general purpose computer, a special purpose computer, a computer network or other programmable apparatus. The computer instructions can be stored in a storage medium or transferred from one storage medium to another storage medium, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) manner. The storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. containing one or more available media sets. The available medium can be a magnetic medium (for example, floppy disk, hard disk, magnetic tape), an optical medium (for example, DVD) or a semiconductor medium (for example, solid state disk (SSD)) etc.

[0133] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0134] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0135] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A log capture method, characterized by, The method comprises: determining an application to be captured, determining a framework adopted by the application to be captured, and determining at least one page of a plug-in in the application to be captured; finding a framework capturing mode corresponding to the framework, performing log capturing by using the framework capturing mode, and storing to a server; finding a page capturing mode corresponding to at least one page, performing log capturing by using the page capturing mode, comprising: obtaining a local log capturing requirement, determining a target page in the at least one page according to the local log capturing requirement; obtaining a second code of a capturing exception corresponding to the target page, and finding a local page capturing mode corresponding to the target page; embedding the second code of the capturing exception into the local page capturing mode, performing log capturing by using the local page capturing mode after code embedding; and storing to the server; the obtaining of the second code of the capturing exception corresponding to the target page and the finding of the local page capturing mode corresponding to the target page comprise: detecting whether the second code of the capturing exception corresponding to the target page is stored in the target page; if the second code of the capturing exception is stored in the target page, obtaining the second code corresponding to the target page, and finding the local page capturing mode corresponding to the target page; if the second code of the capturing exception is not stored in the target page, determining remaining pages in which the second code of the capturing exception is stored; wherein the remaining pages comprise any page in the at least one page except the target page; obtaining first network information of the target page, and obtaining second network information of the remaining pages; if the first network information is consistent with the second network information, obtaining the second code of the capturing exception corresponding to the target page, and finding the local page capturing mode corresponding to the target page; embedding the second code of the capturing exception into the local page capturing mode, and performing log capturing by using the local page capturing mode after code embedding; if the first network information is not consistent with the second network information, performing cross-domain processing, wherein the cross-domain processing comprises cross-domain settings of a client and a server respectively.

2. The method of claim 1, wherein, the finding of the framework capturing mode corresponding to the framework and the performing of log capturing by using the framework capturing mode comprise: judging whether the framework is a target framework; if the framework is the target framework, obtaining a first code of a capturing exception corresponding to the application to be captured, and finding a framework capturing mode corresponding to the framework; embedding the first code of the capturing exception into the framework capturing mode, and performing log capturing by using the framework capturing mode after code embedding.

3. The method of claim 2, wherein, the finding of the framework capturing mode corresponding to the framework and the performing of log capturing by using the framework capturing mode further comprise: if the framework is not the target framework, finding a page capturing mode corresponding to a non-target framework; embedding the first code of the capturing exception into the page capturing mode, and performing log capturing by using the page capturing mode after code embedding.

4. The method of claim 1, wherein, The page capturing method corresponding to at least one of the pages is found, and log capturing is performed by using the page capturing method, and the method comprises: obtaining global log capturing requirements, and determining all the pages in at least one of the pages according to the global log capturing requirements; obtaining third codes for capturing exceptions corresponding to all the pages, and finding global page capturing methods corresponding to all the pages; embedding the third codes for capturing exceptions into the global page capturing methods, and performing log capturing by using the global page capturing methods after the codes are embedded.

5. The method of claim 4, wherein, The method further comprises: if the third codes for capturing exceptions corresponding to each of the pages are not stored on each of the pages, obtaining third network information corresponding to each of the pages; if the third network information corresponding to each of the pages is consistent, obtaining the third codes for capturing exceptions corresponding to all the pages, and finding the global page capturing methods corresponding to all the pages; 6. The method of claim 5, wherein, embedding the third codes for capturing exceptions into the global page capturing methods, and performing log capturing by using the global page capturing methods after the codes are embedded. if the third network information corresponding to each of the pages is not consistent, performing cross-domain processing, wherein the cross-domain processing comprises cross-domain settings performed by the client and the server respectively. The device comprises: a program determining module configured to determine an application program of logs to be captured; a framework and page determining module configured to determine a framework adopted by the application program of the logs to be captured, and determine at least one page of a plug-in in the application program of the logs to be captured; 7. A log capture apparatus, characterized by, a first capturing module configured to find a framework capturing method corresponding to the framework, perform log capturing by using the framework capturing method, and store the logs in a server; a second capturing module configured to find a page capturing method corresponding to at least one of the pages, perform log capturing by using the page capturing method, and store the logs in the server, wherein the second capturing module comprises: a local log capturing requirement obtaining sub-module configured to obtain a local log capturing requirement, and determine a target page in at least one of the pages according to the local log capturing requirement; a second code for capturing exceptions obtaining sub-module configured to obtain a second code for capturing exceptions corresponding to the target page, and find a local page capturing method corresponding to the target page; a second code embedding sub-module configured to embed the second code for capturing exceptions into the local page capturing method, perform log capturing by using the local page capturing method after the codes are embedded, and store the logs in the server. The acquiring the second code of the capture exception corresponding to the target page and searching the local page capture mode corresponding to the target page comprises: detecting whether the second code of the capture exception corresponding to the target page is stored in the target page; if the second code of the capture exception is stored in the target page, acquiring the second code corresponding to the target page and searching the local page capture mode corresponding to the target page; if the second code of the capture exception is not stored in the target page, determining the remaining pages storing the second code of the capture exception; wherein the remaining pages comprise any page except the target page in at least one page; acquiring first network information of the target page and second network information of the remaining pages; if the first network information is consistent with the second network information, acquiring the second code of the capture exception corresponding to the target page and searching the local page capture mode corresponding to the target page; embedding the second code of the capture exception into the local page capture mode, and performing log capture by using the local page capture mode after the code embedding; if the first network information is not consistent with the second network information, performing cross-domain processing, wherein the cross-domain processing comprises cross-domain settings of the client and the server respectively.

8. An electronic device, comprising: The device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus. The memory is used for storing a computer program. The processor is used for executing the program stored in the memory to realize the method steps in any one of claims 1 to 6.

9. A storage medium having stored thereon a computer program, characterized in that The program is executed by the processor to realize the method in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Program monitoring method and device, computing equipment and storage medium

    CN110321275A

  • SDK module for web front-end error and performance monitoring and calling method thereof

    CN112965718A