CN115543669A - Log acquisition method and device, nonvolatile storage medium and processor - Google Patents

Log acquisition method and device, nonvolatile storage medium and processor Download PDF

Info

Publication number
CN115543669A
CN115543669A CN202211148897.3A CN202211148897A CN115543669A CN 115543669 A CN115543669 A CN 115543669A CN 202211148897 A CN202211148897 A CN 202211148897A CN 115543669 A CN115543669 A CN 115543669A
Authority
CN
China
Prior art keywords
code
target
log
agent
object code
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.)
Pending
Application number
CN202211148897.3A
Other languages
Chinese (zh)
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.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp 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 China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202211148897.3A priority Critical patent/CN115543669A/en
Publication of CN115543669A publication Critical patent/CN115543669A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/079Root cause analysis, i.e. error or fault diagnosis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a log obtaining method and device, a nonvolatile storage medium and a processor. Wherein, the method comprises the following steps: determining a target object and acquiring a first target code of the target object, wherein the target object is determined from a running system through an agent program; adding a second object code into the first object code through an agent program to obtain a third object code, wherein the second object code is data used for acquiring a log of a target object; replacing the first object code with a third object code by the agent; and running the third target code through the agent program to obtain the log of the target object. The method and the device solve the technical problems that the running of the system is interrupted and the redeployment is needed when the log function is added to the running system by utilizing the prior art.

Description

Log obtaining method and device, nonvolatile storage medium and processor
Technical Field
The present application relates to the field of computer technologies, and in particular, to the field of non-intrusive function addition for a real-time operating system, and in particular, to a log acquisition method and apparatus, a non-volatile storage medium, and a processor.
Background
The content in the log record of the system relates to the business handling and the flow direction of the flow, so the log record is an important basis for ensuring the correctness of the business and knowing the flow direction, and the related log output of the computer system is extremely important. In the prior art, in order to optimize a system, the bloated code is reduced, a service log only has a key method or an important link, if a log output function is added to other links or an abnormal reason of a certain method is positioned, the code needs to be redeveloped and the redeployment of a project is completed, and the problems of high redevelopment and deployment cost, complex operation and the like exist.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the application provides a log obtaining method and device, a nonvolatile storage medium and a processor, so as to at least solve the technical problems that the running of a system is interrupted and redeployment is needed when a log function is added to the running system by using the prior art.
According to an aspect of an embodiment of the present application, there is provided a log obtaining method, including: determining a target object and acquiring a first target code of the target object, wherein the target object is determined from a running system through an agent program; adding a second object code into the first object code through the agent program to obtain a third object code, wherein the second object code is data used for acquiring a log of the target object; replacing the first object code with a third object code by the agent; and running the third target code through the agent program to obtain the log of the target object.
Optionally, determining the target object comprises: creating a judgment class, registering the judgment class, and determining whether the judgment object is a target object or not through the judgment class, wherein the judgment object is stored in a running system; and in the case that the judgment object is not the target object, outputting a target character, wherein the target character is used for indicating that the judgment object is not the target object.
Optionally, before the agent adds the second object code to the first object code, the log obtaining method further includes: creating a converter implementation class, registering the created converter implementation class, and loading the registered converter implementation class, wherein the converter implementation class comprises: converting an interface; creating an agent method implementation class, registering the created agent method implementation class, and loading the registered agent method implementation class, wherein the agent method implementation class is used for implementing an agent program.
Optionally, the agent adding the second object code to the first object code, comprising: the method comprises the steps of obtaining a first object code, determining a conversion interface, starting an agent program through the conversion interface, and mapping the first object code into the agent program to obtain the first object code.
Optionally, the agent program adds the second object code to the first object code, further comprising: monitoring the running process of the first target code, and determining nodes with log functions; and acquiring a second object code, and adding the second object code to the first object code at the node with the added log function.
Optionally, the agent obtains the log of the target object through a third target code, including: running the first target code; stopping running the first target code at the node with the added log function, and starting running the second target code; and outputting the log of the target object.
Optionally, after obtaining the log of the target object, the method includes: and after the second target code finishes running, instructing the running system to continue running according to a preset sequence, wherein the preset sequence is a running sequence defined by the running system.
According to another aspect of the embodiments of the present application, there is also provided a log obtaining apparatus, where the apparatus is applied to the above agent program, and includes: the determining module is used for determining a target object and acquiring a first target code of the target object, wherein the target object is determined by the agent program from a running system; the adding module is used for adding a second target code into the first target code to obtain a third target code, wherein the second target code is data used for acquiring a log of a target object; the replacing module is used for replacing the first target code with a third target code; and the acquisition module is used for acquiring the log of the target object through the third target code.
According to another aspect of the embodiments of the present application, a non-volatile storage medium is further provided, where the non-volatile storage medium includes a stored computer program, and a device in which the non-volatile storage medium is located executes the log obtaining method by running the computer program.
According to another aspect of the embodiments of the present application, there is also provided a processor configured to execute a program stored in a memory, where the program executes to perform the log obtaining method described above.
In the embodiment of the application, a target object is determined, and a first target code of the target object is obtained, wherein the target object is determined from a running system through an agent program; adding a second object code into the first object code through the agent program to obtain a third object code, wherein the second object code is data used for acquiring a log of the target object; replacing the first object code with a third object code by the agent; the method includes the steps that a third target code is used for obtaining a log of a target object through an agent program, instrumentation is achieved through a Java language, codes capable of achieving a log function are inserted into a running system through the agent program, the log function is added to the system on the premise that the online system environment is not damaged, the system has the function of completely printing online parameter information, the position where problems occur is conveniently and quickly located under the condition that the system is abnormal or parameters are wrong, the technical effect that a pluggable log output function is added to the running system is achieved, and the technical problems that the running of the system is interrupted and the log function needs to be redeployed when the running system is added with the log function in the prior art are solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
FIG. 1 is a flow chart of a log acquisition method according to an embodiment of the present application;
fig. 2 is a structural diagram of a log obtaining apparatus according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a log acquisition method according to an embodiment of the present application;
fig. 4 is a schematic diagram of an implementation process of a proxy mechanism according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application without making any creative effort shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the accompanying drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, some terms or terms appearing in the description of the embodiments of the present application are applicable to the following explanations:
instrumentation: the method is an interface under Java toolkit, namely Java, lang, instance, and the interface provides a function of registering a class file converter (ClassFileTransformer), acquiring all loaded classes, and the like, and allows modification of the loaded and unloaded classes, the bottom layer implementation of Instrumentation depends on a Java Virtual Machine Tool Interface (JVMTI), the JVMTI is an external extension interface set provided by a Java Virtual Machine (JVM), the JVMTI depends on event driving, when the JVM executes, callbacks of some events are triggered, and service extension of an original system can be realized according to the interface of the callbacks.
Dynamic library JVMTI Agent: is a dynamic library that provides tools for implementing load functions and for implementing agent offload functions at agent boot time.
attach: an agent mechanism loads an agent through an attach mechanism and can directly operate a target process.
Attach API: the Application Programming Interface (API) is used for attaching an agent tool program to the target JVM, and the Attach API can be used for monitoring the running process of the target JVM and running an additional agent program of the target JVM.
agent (proxy): a program that provides monitoring and management of system functions.
Class (c): the reference data type in java contains the attributes of the class and the method that implements the class.
class File: the term defined in the virtual machine specification file is an array of byte codes bytes.
Hook function: the method is part of a windows message processing mechanism, and can filter all messages and events at a system level by setting a hook application program to access messages which cannot be accessed under normal conditions.
transform: for implementing the method for converting class files and returning a new file of a replacement class.
transformer: one interface is a ClassFileTransformer interface instance, and the interface has only one transform method. In the processing process of the virtual machine jvmtiEventClassFileLoadHook, a transform method of an instrumentation Impl is called finally, then the transform method of a self-defined transform class is entered, the processed byte code is returned to replace the original byte array (byte [ ]), and then the class analysis stage is entered.
jvmtiEventClassFileLoadHook: the event corresponding to the JVMTI is mainly called when a bytecode file is read and called back.
A premain: an association mechanism is used for loading an agent program when a virtual machine is started and carrying out byte code change in a java program.
agentmain: an association mechanism is used for loading an agent program through an attach mechanism when a virtual machine runs and changing byte codes in a java program.
java agent: is an argument in the java command that can be used to specify a jar packet.
loadAgent (method): the method is used for loading the agent written in java language and deployed in the list of java.
Jar: the code in java can be packaged and stored in the form of jar after packaging.
In the related art, when the JVMTI provided by java is used for realizing the corresponding agent, the agent is developed by adopting C language or C + + language. In addition, instrumentation has the following limitations: 1) Both the Premain and the agentmain modify the byte code after the class loading, that is, the parameter must contain the parameter of class type, and it is not possible to generate a non-existent class by using byte code file and custom class name. 2) Redefining the way that bytecode modification of classes is ultimately all classes has the following limitations: (1) the parent of the new class and the old class must be the same; (2) The interfaces of the new class and the old class need to be the same, and the number of the interfaces is the same; (3) The accessors of the new class and the old class are consistent, and the attribute number and the attribute name are also consistent; (4) New and old classes must be modified by specified types of variables such as private type variable (private), static type variable (static), and non-inheritable type variable (final); (5) the compound can be repaired; because the log obtaining method provided by the embodiment of the application is used for performing log enhancement operation on the existing functions and methods, the limitation of Instrumentation is avoided.
In accordance with an embodiment of the present application, there is provided a method for log retrieval, where the steps illustrated in the flowcharts of the figures may be carried out in a computer system such as a set of computer executable instructions, and where a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be carried out in an order different than the order presented herein.
Fig. 1 is a flowchart of a log obtaining method according to an embodiment of the present application, and as shown in fig. 1, the method includes the following steps:
step S102, a target object is determined, and a first target code of the target object is obtained, wherein the target object is determined from a running system through an agent program.
In step S102, a target object to which a log function is to be added is determined for the running system, where the target object refers to a method or a process link in the running system.
And step S104, adding a second object code into the first object code through the agent program to obtain a third object code, wherein the second object code is data for acquiring a log of the target object.
In step S104, after the target object is determined, the bytecode file in the target object (i.e., the first target code) is mapped into the agent program, and the bytecode file for implementing the logging function (i.e., the second target code) is added thereto, so that the bytecode file (i.e., the third target code) that can implement both the original function and the logging function is obtained.
And step S106, replacing the first object code with a third object code through the agent program.
When the agent program runs, the original bytecode file (i.e., the first object code) is replaced with the bytecode file (i.e., the third object code) that can simultaneously implement the original function and the logging function, which is obtained in step S104.
And step S108, running the third object code through the agent program to acquire the log of the object.
In step S108, the third object code is run by the agent, so as to obtain the log of the object,
through the steps, an Agent (Agent) independent of an application program can be constructed by utilizing an Instrumentation technology, the Agent is utilized to monitor and assist the program running on the JVM, certain types of definitions can be replaced and modified, the purpose of increasing a log function is realized, the dynamic log output of certain key points is realized, and the comprehensive monitoring of the system is realized.
According to an optional embodiment of the present application, the determining the target object includes the following steps: creating a judgment class, registering the judgment class, and determining whether the judgment object is a target object or not through the judgment class, wherein the judgment object is stored in a running system; in the case where the determination object is not the target object, a target character indicating that the determination object is not the target object is output.
In the embodiment, a judgment class is created for determining a target object which needs to be added with a log function; for example, using the equals method in java, a judgment class (classname. Equals) for judging whether the name of the target class is equal to the name of the class that needs to add the log function and is recorded in the agent program is created, and the target object is determined in the running system using the judgment class. And aiming at any judgment object, if the log function is determined to be required to be added according to the judgment result, entering an agent program through a hook function, and running a code capable of realizing the log function. If the judgment result shows that the log function does not need to be added, outputting a character for prompting that the judgment object does not need to add the log function, for example, outputting return null. Wherein the judgment object is essentially bytecode/code in the running system.
According to another optional embodiment of the present application, before the agent adds the second object code to the first object code, the log obtaining method further includes the following steps: creating a converter implementation class, registering the created converter implementation class, and loading the registered converter implementation class, wherein the converter implementation class comprises: converting an interface; creating an agent method implementation class, registering the created agent method implementation class, and loading the registered agent method implementation class, wherein the agent method implementation class is used for implementing an agent program.
In the present embodiment, a converter implementation class is created, which has a function of changing the bytecode of the runtime, and the created converter implementation class includes a ClassFileTransformer interface (i.e., a conversion interface), and a method of making the ClassFileTransformer interface implement the transform, which realizes a function of changing the bytecode file of the runtime system without interrupting the system, and realizes a printing function of log information therein. In this embodiment, a proxy method implementation class is also created for implementing the proxy program. The registering and loading of the judgment class, the registering and loading of the converter implementation class and the registering and loading of the proxy method implementation class are hot deployment steps in Instrumentation, and for each newly created class, two processes of registering and reloading are required, because for a newly created class, a code in the newly created class can be executed only after hot deployment; the registration process is equivalent to registering the newly created class; and reloading the registered class after registration to enable the code contained in the newly created class to be executed, so that the function corresponding to the class is realized. For example, the newly created converter implementation class is registered and loaded, so that the registered converter implementation class can re-modify the bytecode of the class, and the information in jvm is the modified bytecode information.
It should be noted that each class transform method is loaded and executed once.
According to yet another alternative embodiment of the present application, the agent adding the second object code to the first object code includes obtaining the first object code: determining a conversion interface, starting an agent program through the conversion interface, and mapping the first object code into the agent program to obtain the first object code.
In this embodiment, a bytecode file of an operating system is changed by the following method, a converter implementation class created in the above embodiment and deployed by hot is determined first, a converter implementation class that implements a ClassFileTransformer interface is added to an agent, and a target class to which a log function is to be added is reflected to the agent. Reflecting the target class to which the log function is to be added into the agent essentially maps the code of the target object to which the log function is to be added (i.e., the first target code) into the agent.
According to some preferred embodiments of the present application, the agent adding the second object code to the first object code further comprises: monitoring the running process of the first target code and determining a node with a log function; and acquiring a second object code, and adding the second object code to the first object code at the node with the added log function.
In this embodiment, after mapping a code of a target object (i.e., a first target code) into an agent program, monitoring an operation process of the first target code, where it is to be noted that the code mapped into the agent program is completely the same as the code in the target object, and an operation process of the code is also synchronous, and when monitoring that the code runs to a node that is predefined and triggers a log function, the code enters the agent program through a hook function, and a code that implements the log function (i.e., a second target code) is inserted into the agent program, so as to obtain a code (i.e., a third target code) that can implement both a function corresponding to the first target code and the log function.
According to an optional embodiment of the present application, the agent obtains the log of the target object through the third object code, including the following steps: running the first target code; stopping running the first target code at the node with the added log function, and starting running the second target code; and after the second target code is executed, continuing to execute the data which is not executed in the first target code.
In this embodiment, after the code for implementing the log function is inserted, each time the target object runs to this node, the hook function is triggered, the agent program is entered, the code for implementing the log function (i.e., the second target code) is run, and the run result is output, where the output run result is the log of the target object.
According to another optional embodiment of the present application, after obtaining the log of the target object, the method includes: and after the second target code finishes running, instructing the running system to continue running according to a preset sequence, wherein the preset sequence is a running sequence defined by the running system.
Because the log obtaining method provided by the application has the characteristic of not influencing the currently running online system, after the execution of the codes for realizing the log function is finished, the agent program is exited, and the codes which are not run in the target object are continuously run. In the whole process, JVMTI depends on event driving, namely when a target object runs to a node which is added with a log function, a hook function is triggered, the JVMTI is triggered, an agent program which enters the JVM through the JVMTI is executed in the JVM, a code for realizing the log function is run, when the code for realizing the log function is completely executed, the call back which is equivalent to the trigger event is carried out, the code which is not run in the code of the target object is continuously run, and the agent program does not run the code for realizing the log function any more.
Fig. 2 is a structural diagram of a log obtaining apparatus according to an embodiment of the present application, which is applied to the above agent program, and the apparatus includes, as shown in fig. 2: a determining module 20, configured to determine a target object and obtain a first target code of the target object, where the target object is determined by the agent from the running system; the adding module 22 is configured to add a second object code to the first object code to obtain a third object code, where the second object code is data used to obtain a log of the target object; a replacement module 24, configured to replace the first object code with a third object code; and the obtaining module 26 is used for obtaining the log of the target object through the third target code.
It should be noted that, reference may be made to the description related to the embodiment shown in fig. 1 for a preferred implementation of the embodiment shown in fig. 2, and details are not described here again.
According to the present embodiment, an implementation of log obtaining is provided, and fig. 3 is a schematic diagram of a log obtaining method, as shown in fig. 3, obtaining logs is implemented by a compiling environment and an online running environment together; specifically, in a compiling environment, compiling a Java file into a class-type bytecode file by using a Java Development Kit (JDK), inputting the class-type bytecode file into a JVM in an online operating environment, loading the bytecode file by the JVM, then performing real-time compilation (interpretation execution) on the bytecode file, and inputting a result of the real-time compilation into an operating system; meanwhile, if the on-line operating environment triggers the hook function, a log function is added to the target object through an agent mechanism (agent), a new class with the added log function is input to a byte array (byte array) corresponding to the original class type byte code file, and the modified class is reloaded by the JVM. Fig. 4 is a schematic diagram of an implementation process of an agent mechanism, such as the virtual machine start agent mechanism (attach JVM) shown in fig. 4, a dependency tool package (tools. Jar) is loaded by a dependency injection method (dependency), and in a specific implementation, a code file of a running system is loaded by this step; instantiating the obtained code file by a Virtualmachine. Determining a target object from a running system, and loading a code file (namely first target code) of the target object; next, calling java agent, jar through loadAgent (jar), and when the method is specifically implemented, equivalently loading a code file (namely, a second target code) for realizing a log function; and finally, inputting the instantiated tools, namely the first object code, and java, jar, namely the second object code into a running object virtual machine (running JVM), adding the second object code into the first object code in the object virtual machine, and generating a third object code.
Specifically, requesting the first JVM to load a corresponding agent through an attach mechanism of the JVM when the JVM runs includes the following steps: the first step is as follows: creating and initializing a method-JPLISAgent which can realize the loading function when the agent is started; the second step: analyzing parameters in an extension packet, namely MANIFEST.MF, in the proxy project; the third step: instantiating an instrumentation lmpl instance; the fourth step: monitoring a ClassFileLoadHoook event; the fifth step: calling a method of a loading target class of the instrumentation lmpl and a corresponding agent program (loadclasssandcallentmain), and sixthly: the method realizes data analysis of an Agent project (MANIFEST. MF) and completes calling of an agentmain method of an Agent Class (Agent-Class) specified in the method. Through the steps, an implementation class for realizing a ClassFileTransformer interface is established by determining a target class and a target method of an on-line log embedded point, an agent program inlet is compiled, and a packed agent jar is loaded, so that an on-line server runs a program to finish attach to a target jvm, on-line log information is collected, the instrumentation operation on the on-line log is finished, and the log analysis requirement on a target system is realized.
The embodiment of the application further provides a nonvolatile storage medium, which includes a stored computer program, wherein the device where the nonvolatile storage medium is located executes the log obtaining method by running the computer program.
The nonvolatile storage medium stores a program for executing the following functions: determining a target object and acquiring a first target code of the target object, wherein the target object is determined from a running system through an agent program; adding a second object code into the first object code through the agent program to obtain a third object code, wherein the second object code is data used for acquiring a log of the target object; replacing the first object code with a third object code by the agent; and acquiring the log of the target object through the third target code by the agent program.
The embodiment of the application also provides a processor, which is used for running the program stored in the memory, wherein the log obtaining method is executed when the program runs.
The processor is used for running a program for executing the following functions: determining a target object and acquiring a first target code of the target object, wherein the target object is determined from a running system through an agent program; adding a second object code into the first object code through the agent program to obtain a third object code, wherein the second object code is data used for acquiring a log of the target object; replacing the first object code with a third object code by the agent; and acquiring the log of the target object through the third target code by the agent program.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, in essence or part of the technical solutions contributing to the related art, or all or part of the technical solutions, may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (10)

1. A log obtaining method, comprising:
determining a target object and acquiring a first target code of the target object, wherein the target object is determined from a running system through an agent program;
adding a second object code into the first object code through the agent program to obtain a third object code, wherein the second object code is data used for acquiring a log of the target object;
replacing, by the agent, the first object code with the third object code;
and running the third target code through the agent program to obtain a log of the target object.
2. The method of claim 1, wherein determining a target object comprises:
creating a judgment class, registering the judgment class, and determining whether a judgment object is the target object or not through the judgment class, wherein the judgment object is stored in the running system;
and in the case that the judgment object is not the target object, outputting a target character, wherein the target character is used for indicating that the judgment object is not the target object.
3. The method of claim 1, wherein prior to the agent adding a second object code to the first object code, the log retrieval method further comprises:
creating a converter implementation class, registering the created converter implementation class, and loading the registered converter implementation class, wherein the converter implementation class includes: converting an interface;
creating an agent method implementation class, registering the created agent method implementation class, and loading the registered agent method implementation class, wherein the agent method implementation class is used for implementing the agent program.
4. The method of claim 3, wherein the agent adding a second object code to the first object code comprises: the first object code is obtained and the first object code is obtained,
and determining the conversion interface, starting the agent program through the conversion interface, and mapping the first target code into the agent program to obtain the first target code.
5. The method of claim 4, wherein the agent adds a second object code to the first object code, further comprising:
monitoring the running process of the first target code, and determining nodes with log functions;
and acquiring the second object code, and adding the second object code to the first object code at the node with the added log function.
6. The method of claim 5, wherein the agent obtaining the log of the target object via the third object code comprises:
running the first object code;
and stopping running the first target code at the node with the added log function, starting running the second target code, and outputting the log of the target object.
7. The method of claim 6, after obtaining the log of the target object, comprising:
after the second target code finishes running, instructing the running system to continue running according to a preset sequence, wherein the preset sequence is a running sequence defined by the running system.
8. A log obtaining apparatus applied to the agent program according to claim 1, comprising:
the determining module is used for determining a target object and acquiring a first target code of the target object, wherein the target object is determined by the agent program from a running system;
the adding module is used for adding a second object code into the first object code to obtain a third object code, wherein the second object code is data used for acquiring a log of the target object;
a replacing module, configured to replace the first object code with the third object code;
and the acquisition module is used for acquiring the log of the target object through the third target code.
9. A nonvolatile storage medium, comprising a stored computer program, wherein a device on which the nonvolatile storage medium is located executes the log obtaining method according to any one of claims 1 to 7 by executing the computer program.
10. A processor configured to execute a program stored in a memory, wherein the program when executed performs the log obtaining method of any one of claims 1 to 7.
CN202211148897.3A 2022-09-20 2022-09-20 Log acquisition method and device, nonvolatile storage medium and processor Pending CN115543669A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211148897.3A CN115543669A (en) 2022-09-20 2022-09-20 Log acquisition method and device, nonvolatile storage medium and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211148897.3A CN115543669A (en) 2022-09-20 2022-09-20 Log acquisition method and device, nonvolatile storage medium and processor

Publications (1)

Publication Number Publication Date
CN115543669A true CN115543669A (en) 2022-12-30

Family

ID=84727605

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211148897.3A Pending CN115543669A (en) 2022-09-20 2022-09-20 Log acquisition method and device, nonvolatile storage medium and processor

Country Status (1)

Country Link
CN (1) CN115543669A (en)

Similar Documents

Publication Publication Date Title
US8464225B2 (en) Method and system for adaptive, generic code instrumentation using run-time or load-time generated inheritance information for diagnosis and monitoring application performance and failure
US8578339B2 (en) Automatically adding bytecode to a software application to determine database access information
US9411616B2 (en) Classloader/instrumentation approach for invoking non-bound libraries
US9934128B2 (en) Dynamic per-method probing during runtime
CN100492290C (en) Method for acquiring and converting the state of component in the time of operation during software dynamic evolvement
CN110941528B (en) Log buried point setting method, device and system based on fault
US10042658B1 (en) Automatically adding bytecode to a software application to determine network communication information
US8141035B2 (en) Method for accessing internal states of objects in object oriented programming
KR100750834B1 (en) A method of data call stack tracing in data monitoring of JAVA byte code and a device for storing the method in compter program type
CN111158741B (en) Method and device for monitoring dependency relationship change of service module on third party class library
US20160259712A1 (en) System and method for determination of code coverage for software applications in a network environment
CN103186463B (en) Determine the method and system of the test specification of software
US7624381B1 (en) Portable detection of start and completion of object construction
CN114895935A (en) Method and device for flashing vehicle ECU, electronic equipment and storage medium
CN112558947B (en) Program call tracking method, device and storage medium
CN108228266B (en) Method and device for starting Fragment component between different plug-ins under Android plug-in framework
CN111259042B (en) Dynamic query method and system
CN112445706A (en) Program abnormal code acquisition method and device, electronic equipment and storage medium
Südholt A model of components with non-regular protocols
CN111625225A (en) Program specified data output method and device
CN115543669A (en) Log acquisition method and device, nonvolatile storage medium and processor
CN115756424A (en) Method, device and equipment for generating MVP (multifunction vehicle platform) code
CN114816984A (en) JAVA program regression test method and test device
CN116501596A (en) Application program testing method and device
US7082376B1 (en) State full test method executor

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