CN113900908B - Log updating method and device, electronic equipment and storage medium - Google Patents

Log updating method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113900908B
CN113900908B CN202111387344.9A CN202111387344A CN113900908B CN 113900908 B CN113900908 B CN 113900908B CN 202111387344 A CN202111387344 A CN 202111387344A CN 113900908 B CN113900908 B CN 113900908B
Authority
CN
China
Prior art keywords
log
file
plug
local client
application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111387344.9A
Other languages
Chinese (zh)
Other versions
CN113900908A (en
Inventor
吴嘉鑫
李杉
刘伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202111387344.9A priority Critical patent/CN113900908B/en
Publication of CN113900908A publication Critical patent/CN113900908A/en
Application granted granted Critical
Publication of CN113900908B publication Critical patent/CN113900908B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3093Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The disclosure relates to a log updating method, a device, an electronic device and a storage medium, wherein the log updating method comprises the following steps: monitoring log storage information of a local client; when the log storage information indicates that a compression packet exists in a preset storage area of a local client, traversing the compression packet to obtain a target class comprising an updated log and a compiling file of log data, wherein the log data is used for positioning fault information of a preset service application running in the local client, and the compiling file is a file obtained by compiling a log file added with the log; and updating the log data of the service application in the local client according to the target class in the compiled file to obtain a log updating result. And updating the log data of the service application in the local client by utilizing the target class in the compiled file, and dynamically adding the log.

Description

Log updating method and device, electronic equipment and storage medium
Technical Field
The disclosure relates to the technical field of file processing, and in particular relates to a log updating method, a log updating device, electronic equipment and a storage medium.
Background
With the increase of various application APP and tools, the applications running on the terminal are diversified, and problems such as blocking, black screen, page unable refreshing and the like can occur in the running process of the applications, the current fault positioning mode is analyzed through data recorded by the applications, but due to the continuous increase of the application installation quantity, the application log data is often greatly reduced when the application running data is recorded, at this time, if the fault problem of a certain terminal equipment/equipment model needs to be positioned, the problem cannot be positioned because enough logs are not added.
In the related art, when solving the fault location problem, the common way is: adding a log into the code again, compiling the code, generating apk for a user to use, and observing the log; however, the log adding mode has the defects of great time and labor consumption when the codes are recompiled, log adding is not completed each time, the log is needed to be added again and packed, the log adding mode is inflexible, and the user is required to be contacted each time to install an apk with an added log, so that the method is complicated.
Disclosure of Invention
The disclosure provides a log updating method, a log updating device and electronic equipment, so as to at least solve the problem that in the related art, a user is required to install an apk for adding a log by recompiling codes, and the problem is complicated for the user. The technical scheme of the present disclosure is as follows:
According to a first aspect of an embodiment of the present disclosure, there is provided a log updating method applied to an application monitoring platform, including: monitoring log storage information of a local client; when the log storage information indicates that a compressed package exists in a preset storage area of the local client, traversing the compressed package to obtain a target class comprising an updated log and a compiling file of log data, wherein the log data is used for positioning fault information of a preset service application running in the local client, and the compiling file is a file obtained by compiling a log file added with a log; and updating the log data of the service application in the local client according to the target class in the compiled file to obtain a log updating result.
Optionally, before the monitoring the log storage information of the local client, the method further includes: acquiring a plug-in operation class predefined by the local client, wherein a file updating strategy is defined under the plug-in operation class; starting a query thread in the file updating strategy, wherein the query thread is used for sending a query request to a server every interval preset time length, the query request is used for requesting to query whether an application file corresponding to a user application identifier corresponding to the local client exists in the server, and downloading the application file stored in the server to a preset storage area of the local client when the application file exists in the server and is inconsistent with the file identifier of the application file of the local client; and packaging the compiled plug-in operation class and the application file to obtain a compressed package.
Optionally, after the packaging the compiled plug-in running class and the application file to obtain a compressed package, the method further includes: creating a log updating module, and storing the packed compressed package in the log updating module; calling a packing plug-in under the log updating module, wherein the packing plug-in is used for reading the position of the compressed package stored in the log updating module and calling a path generation strategy in a virtual machine to load the position path of the compressed package; compiling the packaging plug-in, and releasing the compiled packaging plug-in to a project plug-in library.
Optionally, after the publishing the compiled package plug-in to the project plug-in library, the method further comprises: calling the packaging plug-ins in the project plug-in library by adopting a preset service application running by the local client; and acquiring a position path of the compressed packet of the packing plug-in to load the compressed packet based on the position path.
Optionally, before the obtaining the plug-in running class predefined by the local client, the method further includes: monitoring an application running state of a preset service application running in the local client; acquiring a user application identifier with a fault under the condition that the application running state indicates that the preset service application running in the local client fails; when the fault information of the user application identification faults cannot be queried according to the recorded application running data, uploading a compressed packet containing log data and a target class of an update log to the server; and generating a fault report based on the fault information and the user application identifier when the fault information of the user application identifier with faults can be queried according to the recorded application running data.
Optionally, the step of uploading the compressed packet containing the log data and the target class of the update log to the server includes: inquiring a target class of log data to be added and the log data used for determining fault information to obtain a log file to be added; compiling all log files to be added to obtain compiled files; and uploading the compiled file to the server.
Optionally, the step of uploading the compiled file to a server includes: packaging the compiled files, and naming the packaged compiled files according to time stamps; and uploading the compiled file named according to the time stamp to the server.
According to another aspect of the embodiments of the present disclosure, there is also provided a log updating apparatus applied to an application monitoring platform, including: the monitoring unit is used for monitoring log storage information of the local client; the traversing unit is used for traversing the compression package to obtain a target class comprising updated logs and a compiling file of log data when the log storage information indicates that the compression package exists in a preset storage area of the local client, wherein the log data are used for positioning fault information of a preset service application running in the local client, and the compiling file refers to a file obtained by compiling the log file added with the logs; and the updating unit is used for updating the log data of the service application in the local client according to the target class in the compiling file to obtain a log updating result.
Optionally, the method further comprises: the first acquisition unit is configured to acquire a plug-in operation class predefined by the local client before the log storage information of the local client is monitored, wherein a file updating strategy is defined under the plug-in operation class; an opening unit, configured to open a query thread in the file update policy, where the query thread is configured to send a query request to a server for requesting to query whether an application file corresponding to a user application identifier corresponding to the local client exists in the server, and if the application file exists in the server and is inconsistent with the file identifier of the application file of the local client, download the application file stored in the server to a preset storage area of the local client; and the packing unit is used for packing the compiled plug-in operation class and the application file to obtain a compressed package.
Optionally, the method further comprises: the creating unit is used for creating a log updating module after the compiled plug-in running class and the application file are packaged to obtain a compressed package, and storing the packaged compressed package in the log updating module; the first calling unit is arranged for calling a packing plug-in under the log updating module, wherein the packing plug-in is used for reading the position of the compressed packet stored in the log updating module and calling a path generating strategy in the virtual machine to load the position path of the compressed packet; the compiling unit is used for compiling the packaging plug-ins and publishing the compiled packaging plug-ins to the project plug-in library.
Optionally, the method further comprises: the second calling unit is used for calling the packaging plug-ins in the project plug-in library by adopting a preset service application operated by the local client after the compiled packaging plug-ins are issued to the project plug-in library; and the second acquisition unit is used for acquiring a position path of the compressed packet of the packing plug-in unit so as to load the compressed packet based on the position path.
Optionally, the method further comprises: the first monitoring module is configured to monitor an application running state of a preset service application running in the local client before the plug-in running class predefined by the local client is obtained; a third obtaining unit, configured to obtain a user application identifier with a fault when the application running state indicates that a preset service application running in the local client has the fault; the uploading unit is used for uploading a compressed packet containing log data and a target class of an update log to the server when the fault information of the user application identifier faults cannot be queried according to the recorded application running data; and the generating unit is used for generating a fault report based on the fault information and the user application identifier when the fault information of the user application identifier with faults can be queried according to the recorded application running data.
Optionally, the uploading unit includes: the query module is used for querying a target class of the log data to be added and the log data for determining fault information to obtain a log file to be added; the compiling module is used for compiling all log files to be added to obtain compiled files; and the uploading module is used for uploading the compiled file to the server.
Optionally, the uploading module includes: the packing sub-module is used for packing the compiled files and naming the packed compiled files according to time stamps; and the uploading sub-module is used for uploading the compiled file named according to the time stamp to the server.
According to another aspect of the embodiments of the present disclosure, there is provided an electronic device including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the log update method as described above.
According to another aspect of the embodiments of the present disclosure, there is also provided a computer-readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the log updating method as set forth in any one of the above.
According to another aspect of the embodiments of the present disclosure, there is also provided a computer program product, including a computer program, wherein the computer program, when executed by a processor, implements the log updating method described above.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: and updating the log data of the service application in the local client by utilizing the target class in the compiling file, dynamically adding the log, and not needing to repackage and compile apk to the user, thereby saving time and not needing to communicate with the user.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure and do not constitute an undue limitation on the disclosure.
FIG. 1 is a schematic diagram illustrating an implementation environment of a log update method, according to an example embodiment.
Fig. 2 is a flow chart illustrating a log update method according to an example embodiment.
Fig. 3 is a block diagram illustrating a log updating apparatus according to an exemplary embodiment.
Detailed Description
In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the disclosure described herein may be capable of operation in sequences other than those illustrated or described herein. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
To facilitate an understanding of the invention by those skilled in the art, some terms or nouns involved in the various embodiments of the invention are explained below:
JavaAgents: is a JVM "plug-in," a manufacturable jar file that is capable of providing bytecode (a binary file consisting of a series of OP code/data pairs, an intermediate code) operations using Instrumentation API provided by the JVM.
The Class file is a file compiled from a source file written in Java language and can be executed by a Java virtual machine.
Gradle engineering does not provide a compiling and packing function by itself and is responsible for defining a framework of flows and rules.
The application monitoring platform can be applied to various application monitoring platforms/tool monitoring platforms, wherein the application monitoring platform can be operated in a local client or a remote development client, and the application monitoring platform can monitor the operation state and operation data of each terminal device.
In the application, the log data of the service application can be recorded through a third-party log system which is associated with the service application but is independent of the service application, so as to assist in monitoring the running state of the service application.
In the method, log information of each application (application types include but are not limited to voice application, video application, course application, office application and the like) can be automatically updated, so that when application faults/application problems occur, package log data do not need to be compiled again, a user does not need to be contacted to install an apk for adding a log, log query time is greatly saved, and fault positioning efficiency and accuracy are improved. The present application is described in detail below in connection with various embodiments thereof.
FIG. 1 is a schematic diagram illustrating an implementation environment of a log update method, according to an example embodiment. Referring to fig. 1, the implementation environment:
including an electronic terminal 110 and a server 120.
The electronic terminal 110 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, or other electronic devices with display functions. The electronic terminal 110 has a function of rendering a front page corresponding to any application/tool. In some embodiments, the electronic terminal 110 is provided with a browser client/local client, and the electronic terminal 110 renders a front-end page corresponding to any application/tool by running the browser client.
Note that, the electronic terminal 110 refers to one of a plurality of terminals, and the present embodiment is only illustrated by the electronic terminal 110. Those skilled in the art will recognize that the number of terminals may be greater or lesser. For example, the number of the terminals may be only several, or the number of the terminals may be tens or hundreds, or more, and the number and the device type of the terminals are not limited in the embodiments of the present disclosure.
Server 120 may be a server, multiple servers, cloud server, cloud computing platform, or virtualization center. In some embodiments, the server 120 is a background server of any application or any plurality of applications, the server 120 stores resources for rendering pages belonging to the any application or any plurality of applications, and the server 120 provides background services for page rendering of any application or any plurality of applications based on the stored resources.
The electronic terminal 110 communicates with the server 120 through a wireless network or a wired network. The electronic terminal 110 runs a browser client, responds to the page rendering instruction, and the website corresponding to the page rendering instruction belongs to an application corresponding to the server 120, obtains resources for rendering the page corresponding to the website by communicating with the server 120, and renders the page corresponding to the website based on the obtained resources. It should be noted that, the server 120 generally refers to one of multiple servers, where each server is a background server of a different application, and the electronic terminal 110 performs rendering on a page of the different application by communicating with the background server of the different application.
Fig. 2 is a flowchart illustrating a log update method according to an exemplary embodiment, and the log update method is used in an application monitoring platform as shown in fig. 2, and includes the following steps.
In step S201, log storage information of the local client is monitored.
The local client may refer to a terminal device running an application/tool, for example, a mobile terminal (including but not limited to a mobile phone, a tablet), a wearable device, a notebook, etc., and the present embodiment is illustrated by a mobile terminal to which an application running JAVA programs belongs, and will be described in detail in this application.
The log storage information may refer to information of a location/link path storing the running state/log data of each application/tool, including but not limited to: storage area, data link path, package information (class containing packaged log data and update log).
When monitoring log storage information of a local client, the method comprises the following steps: every certain interval of time (the specific time is not limited, for example, 30s, 20s, 1min, etc.), a certain preset storage area of the local client is accessed to read log storage information.
In step S202, when the log storage information indicates that there is a compressed package in the preset storage area of the local client, the compressed package is traversed to obtain a compiled file including a target class of the updated log and log data, where the log data is used to locate fault information of a preset service application running in the local client, and the compiled file is a file obtained by compiling the log file to which the log has been added.
The preset storage area may be a preset area for storing the application compression packet, and the size of the preset storage area may be set and adjusted according to the memory/storage size of each electronic terminal, and the preset storage area may be a fixed storage area or a buffer area. For example, a part of storage area/all area is divided in sd (Secure Digital Memory Card, sd for short) card as the preset storage area, or a part of area is set in the non-volatile memory of the electronic terminal as the preset storage area, by monitoring whether the sd card has the compressed package downloaded from the server, if so, the corresponding compressed package is loaded, and the compiled file therein is traversed.
The compressed package is downloaded from the server, and the file/compressed package stored in the server and having inconsistent file names corresponding to the application service identifier of the preset service application running on the local client is downloaded to the preset storage area of the local client. That is, if new compression includes occurrence in the preset storage area of the local client, the log data characterizing the service application is updated, and the code needs to be dynamically modified to add the compiled file containing the new log data to the system.
The log data stored in the compressed package is the historical running data of the service application, and the time stamps are added in the log data and are arranged according to the time sequence indicated by the time stamps. The log data includes, but is not limited to: user application identification (e.g., user Id), physical address of the local client, front-end page display content, user touch operations, processing threads, operating parameters, interface names, interface docking types, etc.
Sources of log data include, but are not limited to: the application itself and the third party system, wherein the third party system is application data recorded by the third party system independent of the preset service application, because the requirement of occupying memory is reduced, the historical operation data recorded by the service application itself is limited, and when the application operation fails, the problem that failure information cannot be checked possibly occurs, and at this time, the third party system is introduced in the application to record the operation data of the service application. Alternatively, the third party system may be a third party log system set up by the local client, or may be a system associated with the service application.
In the embodiment, the fault factor is inquired in an auxiliary way through the log recorded by the third-party system, and the local log file is automatically updated by adopting the plug-in; the application APP monitoring background is taken as a main body, and a local compiling file is updated by analyzing whether a preset storage area (for example, a storage disk indicated by an SD card) of the client side has updated compression packets or not so as to update a recorded log, so that when an application fault occurs, fault factors can be accurately positioned according to the dynamically updated log.
The target class stored in the compression package is for adding log data, by which the log data can be automatically modified/updated.
In step S203, according to the target class in the compiled file, the log data of the service application in the local client is updated, so as to obtain a log update result.
Through the steps, the log storage information of the local client can be monitored in real time, when the log storage information indicates that a compression packet exists in a preset storage area of the local client, the compression packet is traversed to obtain a compiling file comprising a target class for updating the log and log data, and then the log data of the service application in the local client is updated according to the target class in the compiling file to obtain a log updating result. In the embodiment, the log data of the service application in the local client can be updated according to the target class in the compiled file, when the application fault/application problem occurs, the packaged log data does not need to be recompiled, the apk for adding the log does not need to be installed by a contact user, the log query time is greatly saved, and the fault positioning efficiency and accuracy are improved, so that the problem that the user needs to install the apk for adding the log by recompiling the code in the related art is solved, and the problem that the user is complicated is solved.
In this embodiment, when updating log data of a service application in a local client, a preset package plug-in and a target class in a compiled file may be adopted to update the log data in the compiled file to an application service system running in the local client, where the local service system is used to run the preset service application.
The service application related in this embodiment may be an application written in a JAVA program, and the preset package plug-in used in the log update method may refer to a Gradle plug-in defined based on a JAVA Agent, for example, according to compiled file information, an Agent target class, redefining a bytecode of a corresponding class, and invoking a reconversion class method of Instrumentation, so that replacement of a compiled file is completed, and a compiled file with new added log data is added to the system and is run.
Optionally, before monitoring the log storage information of the local client, the log updating method further includes: acquiring a plug-in operation class predefined by a local client, wherein a file updating strategy is defined under the plug-in operation class; starting a query thread in a file updating strategy, wherein the query thread is used for sending a query request to a server every interval preset time length, the query request is used for requesting whether an application file corresponding to a user application identifier corresponding to a local client exists in the query server, and downloading the application file stored in the server to a preset storage area of the local client under the condition that the application file exists in the server and is inconsistent with the file identifier of the application file of the local client, wherein the application file contains added new log data; and packaging the compiled plug-in operation class and application file to obtain a compressed package.
In this embodiment, in order to use a plug-in for updating the log, the client program first needs to define a plug-in running class, such as the com skateboard. After defining the plug-in running class, a file update policy may be defined, for example, defining a static policy public static void agentmain (String arms, instrumentation instrumentation), in which a query thread is started, and a request is sent to the server at intervals of a preset duration (specific interval duration is not limited, for example, 30 s) to confirm whether the corresponding application user identifier of the local machine has a corresponding compressed packet.
In this embodiment, the user application identifier may refer to a user identifier allocated when the user registers to use the service application, where the type of the user application identifier may be a single number or letter, or may be a combination of numbers, letters and symbols, and the type and combination manner are not limited and are all within the scope of the present application. The user application identifier can be used for inquiring whether a corresponding compressed package exists in the server, if yes, the file name is inconsistent with the file name of the log compressed package of the current local client, and the updated compressed package/compressed file is indicated, and at the moment, the compressed package/compressed file needs to be downloaded to a preset storage area of the local client, and log data is updated in time. For example, whether the user id corresponding to the local has a corresponding jar packet or not is judged, if yes, and if not, the file name of the jar packet stored locally is inconsistent, the jar packet is downloaded to the local sd card.
After downloading the files, the compiled plug-in running Class and application files may be packaged to obtain a compressed package, e.g., by defining a MANIFAST. MF file, adding a Permain-Class: com. SkateBoard. LoggerAgents
Agent-Class: com.skateBoard.LoggerAgents, the file and compiled com.skateBoard.LoggerAgents were packaged in a compressed package.
By using the query thread, whether an application file corresponding to the user application identifier corresponding to the local client exists in the query server is requested, and the application file stored in the server is downloaded to a preset storage area of the local client, so that an update file uploaded to the server can be obtained in real time, and log update of the local client can be completed in time.
Optionally, after packaging the compiled plug-in running class and the application file to obtain the compressed package, the log updating method further includes: creating a log updating module, and storing the packed compressed package in the log updating module; calling a packing plug-in under the log updating module, wherein the packing plug-in is used for reading the position of a storage compression packet in the log updating module and calling a path in the virtual machine to generate a position path for loading the compression packet by a strategy; compiling the packaging plug-in, and releasing the compiled packaging plug-in to the project plug-in library.
In this embodiment, the location and access path of the compressed package stored in the preset storage area need to be determined by the package plug-in, so that a log update module needs to be created, for example, a plug-in project is created (which does not provide a compiling and packaging function, is responsible for defining a framework of a flow and a rule), a gradle plug-in is called (which may be a jar file, an item may be created by using an idea, or a gradle init command may be created), and the jar package of the packaged logagent is placed in a libs folder in a preset file (for example, a libs file is newly created) of the project, and is defined as a logagamentplug in. The gradle Plugin written in the embodiment inherits from Plugin, and calls LoggerAgent. Class. GetProtectionDomain (). GetCodeSource (). GetLocation (). ToURI (). GetPath () in the apply method to obtain the position of the compressed package.
After the specific location of the compressed packet is obtained, it needs to know how to access and read the compressed packet, and at this time, the obtained compressed packet location may be loaded by calling a virtual machine to generate an access path/location path, for example, by loading the jar packet location path that has just been obtained by using the loadAgent method of the virtual machine.
After the location path is generated, the gradle plugin may be compiled into a compressed package, e.g., the gradle plugin may be compiled into a jar package, named LoggerAgentPlugin, and published to the maven library.
By the embodiment, the plug-in of the update log can be obtained, and the link path can be generated, so that the compressed log file can be obtained by directly accessing the path when the subsequent update log is performed, the link of the file can be realized rapidly, and the file acquisition speed is improved.
Optionally, after publishing the compiled package plug-in to the project plug-in library, the log updating method further comprises: calling a packaging plug-in a project plug-in library by adopting a preset service application operated by a local client; the location path of the compressed package of the package plug-in is obtained to load the compressed package based on the location path. For example, the client project calls an apply plug in the project to reference the plug-in.
Optionally, before obtaining the plug-in running class predefined by the local client, the log updating method further includes: monitoring an application running state of a preset service application running in a local client; acquiring a user application identifier with a fault under the condition that the application running state indicates that a preset service application running in a local client fails; when failure information of a user application identifier failure cannot be queried according to recorded application running data, uploading a compressed packet containing log data and a target class of an update log to a server; when the fault information of the faults of the user application identification can be queried according to the recorded application running data, generating a fault report based on the fault information and the user application identification.
When a single user fails, for example, when an application crashes or ANR (Application Not Responding, when an application program does not respond, the system displays a non-response dialog box to the user), the application user identification (unique identifier) of the user can be obtained through other monitoring systems (namely, a third party system, such as a bug) and if the current log information is obtained, the problem cause/fault information can not be determined, an additional log is needed to analyze the fault information, at this time, when the fault information of the fault of the user application identification can be queried according to the recorded application running data, a fault report is generated based on the fault information and the user application identification, and the fault information can be timely and accurately obtained through the fault report.
Optionally, the step of uploading the compressed packet containing the log data and the target class of the update log to the server includes: inquiring a target class of log data to be added and the log data used for determining fault information to obtain a log file to be added; compiling all log files to be added to obtain compiled files; and uploading the compiled file to a server. Therefore, fault information can be accurately obtained, and targeted log uploading is completed.
For example, all java files to be logged are determined, a target class (which may also be indicated as a class method) to be logged is found, and a required log for determining a problem is added, where the log is often a used three-way log system for reporting data.
Optionally, the step of uploading the compiled file to the server includes: packaging the compiled files, and naming the packaged compiled files according to the time stamps; and uploading the compiled file named according to the time stamp to a server.
In this embodiment, all JAVA files modified with new log are compiled, through jdk's own command line tool, into class files (JAVA, JAVA files are source files written in JAVA language, and are compiled into class files, which are not executable files similar to exe, and can be executed by JAVA virtual machine), and then compiled into jar files, the compressed files are named according to time stamps, pushed to the server, and the server stores a corresponding compressed package (jar package) for each application service identifier.
By adding the time stamp, the indexing efficiency and the indexing accuracy can be improved, when the log data is analyzed later, the sequential analysis of the added time stamp is realized, the compressed files added with the time stamp are more reasonably arranged, and the compressed files can be arranged according to the time sequence, so that the subsequent traversal operation on the compressed files is facilitated, and the complete files are obtained quickly.
Embodiments of the present invention are described below in conjunction with alternative embodiments.
(1) When a problem occurs in a single user, for example, when an application crash or ANR occurs, the present embodiment may acquire a user id (unique identifier, i.e., the application user identifier described above) through another third party monitoring system (for example, a bug), and when the obtained information cannot determine the cause of the problem, it is necessary to locate the cause of the problem by means of an updated log or an additional log.
(2) Determining all java files to be added with logs, finding a class method to be added with the logs, and adding the required logs for determining problems, wherein the logs in the embodiment can be used as a third-party log system for reporting data.
(3) All JAVA files modified with new logs are compiled, through jdk's own command line tool, into class files (i.e. the above-mentioned compiled files, because JAVA is in JAVA. JAVA files are source files written in JAVA language, which need to be compiled into class files, class files are not executable files similar to. Exe, which can only be executed by JAVA virtual machines), and then compiled into jar files.
(4) And (3) naming the jar file according to the timestamp, pushing the jar file to a server, and storing a corresponding jar packet for each user id by the server.
(5) If the log needs to be dynamically updated, the client program first needs to define a com.skateboard.logeragent Class, define a static method public static void agentmain (String characters, instrumentation instrumentation), start a thread in the method, send a request to the server at intervals of a preset interval (for example, 30 s), determine whether a corresponding jar packet exists in the id corresponding to the client program, if so, and if not, and the file name of the jar packet stored locally is inconsistent, download the jar packet to the local sd card, then define a manifest.mf file, and add a per-Class: com.skateboard.logeragent.
Agent-Class: com.skateBoard.LoggerAgents, the file and compiled com.skateBoard.LoggerAgents were typed into Jar packages.
(6) Creating a gradle (a framework which does not provide compiling and packing functions and is responsible for defining flows and rules) plug-in engineering (namely the log updating module), writing a gradle plug-in (namely the packing plug-in, essentially a jar file, an item can be created by using idea or written by using gradle init commands), placing jar packages of the well-opened logagent into a libs folder in the libs file of the engineering, and defining the Plugin as logagantplug in, wherein the plug-in inherits from the plug in, and is called in the apply method:
LoggerAgent. Class. GetProtectionDomain (). GetCocodeSource (). GetLocation (). ToU RI (). GetPath (); the position of the jar packet is obtained, and then the loadAgent method of the VirtualMachine is called to load the newly obtained jar packet position path.
(7) The gradle plug-in is compiled into a jar package, named LoggerAgentPlugin and published to a maven library.
(8) The client engineering invokes an apply plug in the project to reference the plug-in.
(9) Monitoring whether a jar package downloaded from a server exists in an agent method of LoggerAgent (monitoring interval duration), if so, loading the corresponding jar package, traversing a class file in the jar package, calling a reconversion classes method of Instrumentation according to class file information, replacing the class file, adding a new class file added with log data into a system, and running the class file.
Through the embodiment, the code can be dynamically modified, a developer is assisted to dynamically add the log information, when the application fault/application problem occurs, the package log data is not required to be compiled again, the user is not required to be contacted to install the apk for adding the log, the log query time is greatly saved, and the fault positioning efficiency and accuracy are improved.
The invention is described below in connection with another embodiment.
Fig. 3 is a block diagram illustrating a log updating apparatus according to an exemplary embodiment. Referring to fig. 3, the apparatus includes a monitoring unit 301, a traversing unit 302, and an updating unit 303.
A monitoring unit 301 configured to perform monitoring of log storage information of the local client;
the traversing unit 302 is configured to execute traversing the compression packet to obtain a compiled file including a target class of an updated log and log data when the log storage information indicates that the compression packet exists in a preset storage area of the local client, wherein the log data is used for positioning fault information of a preset service application running in the local client, and the compiled file is a file obtained by compiling the log file added with the log;
and the updating unit 303 is configured to update the log data of the service application in the local client according to the target class in the compiled file to obtain a log updating result.
In the above log updating device, the monitoring unit 301 may monitor log storage information of the local client in real time, and when the log storage information indicates that there is a compressed packet in a preset storage area of the local client, the traversing unit 302 traverses the compressed packet to obtain a compiled file including a target class of an updated log and log data, and then the updating unit 303 updates the log data of the service application in the local client according to the target class in the compiled file to obtain a log updating result. In the embodiment, the log data of the service application in the local client can be updated according to the target class in the compiled file, when the application fault/application problem occurs, the packaged log data does not need to be recompiled, the apk for adding the log does not need to be installed by a contact user, the log query time is greatly saved, and the fault positioning efficiency and accuracy are improved, so that the problem that the user needs to install the apk for adding the log by recompiling the code in the related art is solved, and the problem that the user is complicated is solved.
Optionally, the log updating device further includes: the first acquisition unit is used for acquiring a plug-in operation class predefined by the local client before monitoring log storage information of the local client, wherein a file updating strategy is defined under the plug-in operation class; the starting unit is used for starting a query thread in the file updating strategy, wherein the query thread is used for sending a query request to the server every interval preset time length, the query request is used for requesting whether an application file corresponding to a user application identifier corresponding to the local client exists in the query server, and the application file stored in the server is downloaded to a preset storage area of the local client under the condition that the application file exists in the server and is inconsistent with the file identifier of the application file of the local client; and the packing unit is used for packing the compiled plug-in operation class and application file to obtain a compressed package.
Optionally, the log updating device further includes: the creation unit is used for creating a log updating module after packaging the compiled plug-in operation class and the application file to obtain a compressed package, and storing the packaged compressed package in the log updating module; the first calling unit is arranged for calling a packing plug-in under the log updating module, wherein the packing plug-in is used for reading the position of the storage compression packet in the log updating module and calling a path in the virtual machine to generate a position path for loading the compression packet by the strategy; the compiling unit is used for compiling the packaging plug-in and publishing the compiled packaging plug-in to the project plug-in library.
Optionally, the log updating device further includes: the second calling unit is used for calling the packaging plug-ins in the project plug-in library by adopting a preset service application operated by the local client after the compiled packaging plug-ins are released to the project plug-in library; and a second acquisition unit configured to acquire a position path of the compressed packet of the package plug-in to load the compressed packet based on the position path.
Optionally, the log updating device further includes: the first monitoring module is used for monitoring the application running state of a preset service application running in the local client before the predefined plug-in running class of the local client is obtained; the third acquisition unit is used for acquiring a user application identifier with faults when the application running state indicates that a preset service application running in the local client fails; the uploading unit is used for uploading a compressed packet containing log data and a target class for updating the log to the server when the fault information of the user application identifier faults cannot be queried according to the recorded application running data; and a generation unit configured to generate a fault report based on the fault information and the user application identifier when the fault information in which the user application identifier fails can be queried according to the recorded application operation data.
Optionally, the uploading unit includes: the query module is used for querying a target class of the log data to be added and the log data for determining fault information to obtain a log file to be added; the compiling module is used for compiling all log files to be added to obtain compiled files; and the uploading module is used for uploading the compiled file to the server.
Optionally, the uploading module includes: the packing sub-module is used for packing the compiled files and naming the packed compiled files according to the time stamp; and the uploading sub-module is used for uploading the compiled file named according to the time stamp to the server.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
According to another aspect of the embodiments of the present disclosure, there is provided an electronic device including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the log update method as described above.
The type of the electronic device in the application may include a terminal and may also include a server.
In an exemplary embodiment, a computer readable storage medium comprising instructions is also provided, which when executed by a processor of an electronic device, enable the electronic device to perform the log updating method as set forth in any one of the above.
Alternatively, the storage medium may be a non-transitory computer readable storage medium, which may be, for example, ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
In an exemplary embodiment, a computer program product is also provided, comprising a computer program, characterized in that the computer program, when executed by a processor, implements the above-mentioned log updating method.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (14)

1. The log updating method is characterized by being applied to an application monitoring platform and comprising the following steps of:
acquiring a plug-in operation class predefined by the local client, wherein a file updating strategy is defined under the plug-in operation class; starting a query thread in the file updating strategy, wherein the query thread is used for sending a query request to a server every interval preset time length, the query request is used for requesting to query whether an application file corresponding to a user application identifier corresponding to the local client exists in the server, and downloading the application file stored in the server to a preset storage area of the local client when the application file exists in the server and is inconsistent with the file identifier of the application file of the local client; packaging the compiled plug-in operation class and the application file to obtain a compressed package;
Monitoring log storage information of a local client;
when the log storage information indicates that a compressed package exists in a preset storage area of the local client, traversing the compressed package to obtain a target class and a compiling file, wherein the target class is used for adding log data, the log data can be automatically modified or updated through the target class, the log data is used for positioning fault information of a preset service application running in the local client, and the compiling file is a file obtained by compiling the log file added with the log;
and updating the log data of the service application in the local client according to the target class in the compiled file to obtain a log updating result.
2. The method for updating a log according to claim 1, further comprising, after said packaging the compiled plug-in running class and the application file to obtain a compressed package:
creating a log updating module, and storing the packed compressed package in the log updating module;
calling a packing plug-in under the log updating module, wherein the packing plug-in is used for reading the position of the compressed package stored in the log updating module and calling a path generation strategy in a virtual machine to load the position path of the compressed package;
Compiling the packaging plug-in, and releasing the compiled packaging plug-in to a project plug-in library.
3. The log updating method according to claim 2, further comprising, after said publishing the compiled package plug-in to a project plug-in library:
calling the packaging plug-ins in the project plug-in library by adopting a preset service application running by the local client;
and acquiring a position path of the compressed packet of the packing plug-in to load the compressed packet based on the position path.
4. The method of claim 1, further comprising, prior to said obtaining the local client predefined plug-in runtime class:
monitoring an application running state of a preset service application running in the local client;
acquiring a user application identifier with a fault under the condition that the application running state indicates that the preset service application running in the local client fails;
when the fault information of the user application identification faults cannot be queried according to the recorded application running data, uploading a compressed packet containing log data and a target class of an update log to the server;
And generating a fault report based on the fault information and the user application identifier when the fault information of the user application identifier with faults can be queried according to the recorded application running data.
5. The method of claim 4, wherein the step of uploading the compressed package containing the log data and the target class of the update log to the server comprises:
inquiring a target class of log data to be added and the log data used for determining fault information to obtain a log file to be added;
compiling all log files to be added to obtain compiled files;
and uploading the compiled file to the server.
6. The log updating method according to claim 5, wherein the step of uploading the compiled file to a server comprises:
packaging the compiled files, and naming the packaged compiled files according to time stamps;
and uploading the compiled file named according to the time stamp to the server.
7. A log updating device, applied to an application monitoring platform, comprising:
the monitoring unit is used for monitoring log storage information of the local client;
The traversal unit is used for traversing the compression package to obtain a target class including an updated log and a compiling file of log data when the log storage information indicates that the compression package exists in a preset storage area of the local client, wherein the target class is used for adding the log data, the log data can be automatically modified or updated through the target class, the log data is used for positioning fault information of a preset service application running in the local client, and the compiling file refers to a file obtained by compiling the log file added with the log;
the updating unit is used for updating the log data of the service application in the local client according to the target class in the compiling file to obtain a log updating result;
the log updating apparatus further includes: the first acquisition unit is configured to acquire a plug-in operation class predefined by the local client before the log storage information of the local client is monitored, wherein a file updating strategy is defined under the plug-in operation class; an opening unit, configured to open a query thread in the file update policy, where the query thread is configured to send a query request to a server for requesting to query whether an application file corresponding to a user application identifier corresponding to the local client exists in the server, and if the application file exists in the server and is inconsistent with the file identifier of the application file of the local client, download the application file stored in the server to a preset storage area of the local client; and the packing unit is used for packing the compiled plug-in operation class and the application file to obtain a compressed package.
8. The log updating apparatus according to claim 7, further comprising:
the creating unit is used for creating a log updating module after the compiled plug-in running class and the application file are packaged to obtain a compressed package, and storing the packaged compressed package in the log updating module;
the first calling unit is arranged for calling a packing plug-in under the log updating module, wherein the packing plug-in is used for reading the position of the compressed packet stored in the log updating module and calling a path generating strategy in the virtual machine to load the position path of the compressed packet;
the compiling unit is used for compiling the packaging plug-ins and publishing the compiled packaging plug-ins to the project plug-in library.
9. The log updating apparatus according to claim 8, further comprising:
the second calling unit is used for calling the packaging plug-ins in the project plug-in library by adopting a preset service application operated by the local client after the compiled packaging plug-ins are issued to the project plug-in library;
and the second acquisition unit is used for acquiring a position path of the compressed packet of the packing plug-in unit so as to load the compressed packet based on the position path.
10. The log updating apparatus according to claim 7, further comprising:
the first monitoring module is configured to monitor an application running state of a preset service application running in the local client before the plug-in running class predefined by the local client is obtained;
a third obtaining unit, configured to obtain a user application identifier with a fault when the application running state indicates that a preset service application running in the local client has the fault;
the uploading unit is used for uploading a compressed packet containing log data and a target class of an update log to the server when the fault information of the user application identifier faults cannot be queried according to the recorded application running data;
and the generating unit is used for generating a fault report based on the fault information and the user application identifier when the fault information of the user application identifier with faults can be queried according to the recorded application running data.
11. The log updating apparatus according to claim 10, wherein the uploading unit comprises:
the query module is used for querying a target class of the log data to be added and the log data for determining fault information to obtain a log file to be added;
The compiling module is used for compiling all log files to be added to obtain compiled files;
and the uploading module is used for uploading the compiled file to the server.
12. The log updating apparatus according to claim 11, wherein the uploading module comprises:
the packing sub-module is used for packing the compiled files and naming the packed compiled files according to time stamps;
and the uploading sub-module is used for uploading the compiled file named according to the time stamp to the server.
13. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the log updating method of any of claims 1 to 6.
14. A computer readable storage medium, which when executed by a processor of an electronic device, causes the electronic device to perform the log updating method of any of claims 1 to 6.
CN202111387344.9A 2021-11-22 2021-11-22 Log updating method and device, electronic equipment and storage medium Active CN113900908B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111387344.9A CN113900908B (en) 2021-11-22 2021-11-22 Log updating method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111387344.9A CN113900908B (en) 2021-11-22 2021-11-22 Log updating method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113900908A CN113900908A (en) 2022-01-07
CN113900908B true CN113900908B (en) 2024-02-23

Family

ID=79194826

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111387344.9A Active CN113900908B (en) 2021-11-22 2021-11-22 Log updating method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113900908B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10303663B1 (en) * 2014-06-12 2019-05-28 Amazon Technologies, Inc. Remote durable logging for journaling file systems
CN111309506A (en) * 2020-02-12 2020-06-19 中国平安人寿保险股份有限公司 Method, equipment, server and readable storage medium for positioning compiling errors
CN111435312A (en) * 2019-01-15 2020-07-21 北京嘀嘀无限科技发展有限公司 Application program management method and device and electronic equipment
CN111580813A (en) * 2020-03-25 2020-08-25 博雅信安科技(北京)有限公司 Automatic management method for Java class hot update
CN113497723A (en) * 2020-03-20 2021-10-12 阿里巴巴集团控股有限公司 Log processing method, log gateway and log processing system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10303663B1 (en) * 2014-06-12 2019-05-28 Amazon Technologies, Inc. Remote durable logging for journaling file systems
CN111435312A (en) * 2019-01-15 2020-07-21 北京嘀嘀无限科技发展有限公司 Application program management method and device and electronic equipment
CN111309506A (en) * 2020-02-12 2020-06-19 中国平安人寿保险股份有限公司 Method, equipment, server and readable storage medium for positioning compiling errors
CN113497723A (en) * 2020-03-20 2021-10-12 阿里巴巴集团控股有限公司 Log processing method, log gateway and log processing system
CN111580813A (en) * 2020-03-25 2020-08-25 博雅信安科技(北京)有限公司 Automatic management method for Java class hot update

Also Published As

Publication number Publication date
CN113900908A (en) 2022-01-07

Similar Documents

Publication Publication Date Title
US20150378864A1 (en) Systems and methods for instrumenting applications for performance monitoring
US7343523B2 (en) Web-based analysis of defective computer programs
US9588872B2 (en) Discovery of code paths
US20130167123A1 (en) Application debugging
CN109194606B (en) Attack detection system, method, computer device and storage medium
WO2014209359A1 (en) Hook framework
JP2009516239A (en) General purpose multi-instance method and GUI detection system for tracking and monitoring computer applications
US10725893B2 (en) System and method for determination of code coverage for software applications in a network environment
CN113568839A (en) Method, device, equipment and medium for software testing and statistical test coverage rate
CN109032631A (en) Application program service packs acquisition methods, device, computer equipment and storage medium
CN112769706B (en) Componentized routing method and system
CN112765032A (en) Program debugging method, device, equipment and storage medium
CN113050984A (en) Resource calling method and device, electronic equipment and storage medium
CN114115904A (en) Information processing method, information processing apparatus, server, and storage medium
US10216620B2 (en) Static code testing of active code
CN113900908B (en) Log updating method and device, electronic equipment and storage medium
CN112445706A (en) Program abnormal code acquisition method and device, electronic equipment and storage medium
CN112579475A (en) Code testing method, device, equipment and readable storage medium
US9841960B2 (en) Dynamic provision of debuggable program code
CN111258802A (en) Method for capturing application program crash information and related equipment
CN108304230B (en) Implementation method and device for adjusting application attribute and readable storage medium
CN110795358B (en) Code instrumentation detection method, apparatus, device and medium
CN114238129A (en) Method, device and equipment for generating interface data and storage medium
CN109408133A (en) A kind of method and apparatus starting component
US20120324426A1 (en) System and method to in-line script dependencies

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant