CN113778969A - Log processing method and device - Google Patents

Log processing method and device Download PDF

Info

Publication number
CN113778969A
CN113778969A CN202110081935.7A CN202110081935A CN113778969A CN 113778969 A CN113778969 A CN 113778969A CN 202110081935 A CN202110081935 A CN 202110081935A CN 113778969 A CN113778969 A CN 113778969A
Authority
CN
China
Prior art keywords
log
application
printing condition
printed
program
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
CN202110081935.7A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun 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 Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110081935.7A priority Critical patent/CN113778969A/en
Publication of CN113778969A publication Critical patent/CN113778969A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1203Improving or facilitating administration, e.g. print management
    • G06F3/1205Improving or facilitating administration, e.g. print management resulting in increased flexibility in print job configuration, e.g. job settings, print requirements, job tickets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1253Configuration of print job parameters, e.g. using UI at the client
    • G06F3/1254Automatic configuration, e.g. by driver
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Abstract

The invention discloses a log processing method and device, and relates to the technical field of computers. One embodiment of the method comprises: running an application program, wherein a jar packet corresponding to the agent program is connected to an application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; and modifying the byte code corresponding to the log to be printed, and printing and outputting the log to be printed. The method and the device improve the flexibility and the processing efficiency of log processing, save system resources, expand the applicable scenes of log processing and improve user experience.

Description

Log processing method and device
Technical Field
The invention relates to the technical field of computers, in particular to a log processing method and device.
Background
The log records the behavior and the running state of the application program, and the log plays an important role in the data analysis of the application program and the test process of the running condition of the application program.
The prior art has at least the following problems:
the existing log processing method has the technical problems of poor flexibility of log processing, waste of system resources, few applicable scenes of log processing and poor user experience.
Disclosure of Invention
In view of this, embodiments of the present invention provide a log processing method and apparatus, which can improve the flexibility and processing efficiency of log processing, save system resources, expand the applicable scenarios of log processing, and improve user experience.
To achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a log processing method including:
running an application program, wherein a jar packet corresponding to the agent program is connected to an application instance of the application program;
obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed;
and modifying the byte code corresponding to the log to be printed, and printing and outputting the log to be printed.
Further, before the step of obtaining the log printing condition by using the jar packet corresponding to the agent program, the method further comprises a step of configuring the log printing condition, and the method comprises the following steps:
acquiring application program information, wherein the application program information comprises an application instance;
and configuring log printing conditions for the application instances according to application requirements.
Further, the step of configuring the log printing condition for the application instance according to the application requirement further includes:
determining a class, a method and an array corresponding to the application instance;
and performing printing configuration on at least one of the class, the method and the array corresponding to the application instance according to the application requirement to determine the log printing condition.
Further, the application information further includes an application number; the log processing method further comprises the following steps:
constructing a mapping table of application program numbers and log printing conditions;
a mapping table is stored.
Further, the step of acquiring the log printing condition by using the jar packet corresponding to the agent program comprises the following steps:
sending a log printing condition acquisition request by using a jar packet corresponding to the agent program; the log printing condition acquisition request comprises an application program number;
a log printing condition corresponding to the application number is received.
Further, the step of matching the application instance with the log printing condition to determine the log to be printed includes:
traversing classes, methods and arrays of application instances, and determining matching items according to log printing conditions, wherein the matching items comprise at least one of class matching items, method matching items and array matching items;
and determining the log to be printed according to the matching item.
Further, still include:
updating the log printing conditions according to application requirements;
and acquiring the updated log printing condition by using the jar packet corresponding to the agent program, determining the log to be printed according to the updated log printing condition, and printing and outputting the log to be printed.
According to a second aspect of the embodiments of the present invention, there is provided a log processing apparatus including:
the running module is used for running the application program, wherein a jar packet corresponding to the agent program is connected to an application instance of the application program;
the matching module is used for acquiring the log printing conditions by using jar packets corresponding to the agent program and matching the application examples with the log printing conditions to determine logs to be printed;
and the processing module is used for modifying the byte codes corresponding to the logs to be printed and printing and outputting the logs to be printed.
According to a third aspect of embodiments of the present invention, there is provided an electronic apparatus, including:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement any of the log processing methods described above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer-readable medium on which a computer program is stored, the program, when executed by a processor, implementing any one of the log processing methods described above.
One embodiment of the above invention has the following advantages or benefits: the operating application program is adopted, wherein the jar packet corresponding to the agent program is connected to the application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; the technical means of modifying the byte code corresponding to the log to be printed and printing and outputting the log to be printed are adopted, so that the technical problems that the flexibility of log processing is poor, system resources are wasted, the applicable scenes of log processing are few, and the user experience is poor due to the fact that the code logic of the log to be printed must be pre-existed at the position where the log is to be printed in the existing log processing method and the log to be printed can only be determined according to the log level are solved, and the technical effects of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenes of log processing and improving the user experience are achieved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
fig. 1 is a schematic diagram of a main flow of a log processing method provided according to a first embodiment of the present invention;
fig. 2 is a schematic diagram of a main flow of a log processing method according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of the main modules of a log processing apparatus provided according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of a log processing method provided according to a first embodiment of the present invention; as shown in fig. 1, the log processing method provided by the embodiment of the present invention mainly includes:
and step S101, running an application program, wherein a jar packet corresponding to the agent program is connected to an application instance of the application program.
Specifically, according to the embodiment of the present invention, before or after the application program is run, a jar packet (i.e., log agent jar) corresponding to the agent program is dynamically connected to the application instance of the application program, so that a log printing condition corresponding to the application program is subsequently obtained through the log agent jar, and the log to be printed is determined by matching the application instance with the log printing condition, thereby achieving the technical effects of improving the log processing efficiency and improving the flexibility of log processing.
Step S102, obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed.
According to the embodiment of the invention, the latest log printing condition is obtained by using the jar packet corresponding to the agent program, and the log to be printed is determined by matching the application instance with the log printing condition.
According to a specific implementation manner of the embodiment of the invention, because the logagent.jar is dynamically connected to the application instance of the application program, for each application instance connected with the logagent.jar packet, the logagent.jar is respectively used for acquiring the corresponding log printing condition, so that each application instance can acquire the latest log printing condition corresponding to the application program, system resources are saved, the application scene of log processing is expanded, and the log processing efficiency is improved.
Further, according to an embodiment of the present invention, before the step of obtaining the log printing condition by using the jar packet corresponding to the agent, the log processing method further includes a step of configuring the log printing condition, including:
acquiring application program information, wherein the application program information comprises an application instance;
and configuring log printing conditions for the application instances according to application requirements.
Through the setting, the log printing condition corresponding to each application program is determined according to the application requirements (such as testing requirements and data processing requirements, and the application requirements indicate the log type to be printed), so that the flexibility of log processing is improved.
Preferably, according to an embodiment of the present invention, the step of configuring the log printing condition for the application instance according to the application requirement further includes:
determining a class, a method and an array corresponding to the application instance;
and performing printing configuration on at least one of the class, the method and the array corresponding to the application instance according to the application requirement to determine the log printing condition.
Through the setting, the printing configuration (whether a certain type, a certain method and/or a certain array corresponding to the application instance is configured to be printed or not) is respectively carried out by combining the application requirements and the type, the method and/or the array specifically corresponding to the application instance, so that the log printing condition is generated, the log printing condition can be favorably and rapidly matched with the application instance in the running process of the application program according to the log printing condition, the log to be printed can be rapidly determined, and the log processing efficiency can be improved.
Illustratively, according to an embodiment of the present invention, the application information further includes an application number; the log processing method further comprises the following steps:
constructing a mapping table of application program numbers and log printing conditions;
a mapping table is stored.
Through the setting, the purpose of constructing the mapping table is to facilitate log agents to quickly acquire log printing conditions corresponding to the application program, so that the log processing efficiency is further improved, and the user experience is improved.
Specifically, according to the embodiment of the present invention, the step of acquiring the log printing condition by using the jar packet corresponding to the agent includes:
sending a log printing condition acquisition request by using a jar packet corresponding to the agent program; the log printing condition acquisition request comprises an application program number;
a log printing condition corresponding to the application number is received.
According to a specific implementation manner of the embodiment of the present invention, the configuration process of the journal printing condition is configured through a CMS (Content Management System) Management platform, and after receiving a journal printing condition acquisition request including an application number sent by logagent.
Further, according to the embodiment of the present invention, the step of matching the application instance with the log printing condition to determine the log to be printed includes:
traversing classes, methods and arrays of application instances, and determining matching items according to log printing conditions, wherein the matching items comprise at least one of class matching items, method matching items and array matching items;
and determining the log to be printed according to the matching item.
Through the arrangement, the matching processing can be rapidly and comprehensively carried out by traversing the classes, the methods and the arrays in the application examples, so that the logs to be printed are determined, and the accuracy of log processing is improved.
And step S103, modifying the byte code corresponding to the log to be printed, and performing print output processing on the log to be printed.
Through the arrangement, after the log to be printed is determined, the printing output processing can be executed only by modifying the byte codes, and because the byte code modification operation can be realized by any log frame or a third-party tool and the like, the problem that the log processing application scene is narrow due to the fact that the log frame is completely depended on when the log level is adjusted in the prior art is solved.
Further, according to an embodiment of the present invention, the log processing method further includes:
updating the log printing conditions according to application requirements;
and acquiring the updated log printing condition by using the jar packet corresponding to the agent program, determining the log to be printed according to the updated log printing condition, and printing and outputting the log to be printed.
Through the setting, the log printing condition can be updated according to the change of the application requirement, so that the log to be printed is determined according to the updated log printing condition, the flexibility of log processing is further improved, the applicable scene of log processing is expanded, and the user experience is improved.
According to the technical scheme of the embodiment of the invention, the application program is operated, wherein the jar packet corresponding to the agent program is connected to the application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; the technical means of modifying the byte code corresponding to the log to be printed and printing and outputting the log to be printed are adopted, so that the technical problems that the flexibility of log processing is poor, system resources are wasted, the applicable scenes of log processing are few, and the user experience is poor due to the fact that the code logic of the log to be printed must be pre-existed at the position where the log is to be printed in the existing log processing method and the log to be printed can only be determined according to the log level are solved, and the technical effects of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenes of log processing and improving the user experience are achieved.
Fig. 2 is a schematic diagram of a main flow of a log processing method according to a second embodiment of the present invention; as shown in fig. 2, the log processing method provided by the embodiment of the present invention mainly includes:
in step S201, application information is acquired.
Specifically, according to the embodiment of the present invention, the application information includes an application number, an application contact, an IP list of an application instance, and the like, and examples are shown in the following table:
Figure BDA0002909675900000081
through the arrangement, before the step of configuring the log printing conditions, the application program information is acquired, so that the log printing conditions corresponding to the application programs are determined according to the application requirements (such as test requirements and data processing requirements, and the application requirements indicate the types of logs to be printed) of the application programs, and the flexibility of log processing is improved.
Step S202, determining a class, a method and an array corresponding to the application instance; and performing printing configuration on at least one of the class, the method and the array corresponding to the application instance according to the application requirement to determine the log printing condition.
Specifically, according to a specific implementation of an embodiment of the present invention, the following table provides an example of a configuration log printing condition:
Figure BDA0002909675900000082
Figure BDA0002909675900000091
the above table shows the configuration of the log printing condition of a specific implementation manner of the embodiment of the present invention, where the precise matching refers to configuring print (true) or not print (false) when the same is the same as the class/method/array (where the array is the entry list) information provided in the application instance; fuzzy matching includes matching the entire class, matching the specific range class, and matching the entire.
Through the setting, the printing configuration (whether a certain type, a certain method and/or a certain array corresponding to the application instance is configured to be printed or not) is respectively carried out by combining the application requirements and the type, the method and/or the array specifically corresponding to the application instance, so that the log printing condition is generated, the log printing condition can be favorably and rapidly matched with the application instance in the running process of the application program according to the log printing condition, the log to be printed can be rapidly determined, and the log processing efficiency can be improved.
Step S203, constructing a mapping table of application program numbers and log printing conditions; a mapping table is stored.
Through the setting, the printing configuration (whether a certain type, a certain method and/or a certain array corresponding to the application instance is configured to be printed or not) is respectively carried out by combining the application requirements and the type, the method and/or the array specifically corresponding to the application instance, so that the log printing condition is generated, the log printing condition can be favorably and rapidly matched with the application instance in the running process of the application program according to the log printing condition, the log to be printed can be rapidly determined, and the log processing efficiency can be improved.
And step S204, dynamically connecting the jar packet corresponding to the agent program to the application instance of the application program, and running the application program.
Specifically, according to the embodiment of the present invention, before or after the application program is run, a jar packet (i.e., log agent jar) corresponding to the agent program is dynamically connected to the application instance of the application program, so that a log printing condition corresponding to the application program is subsequently obtained through the log agent jar, and the log to be printed is determined by matching the application instance with the log printing condition, thereby achieving the technical effects of improving the log processing efficiency and improving the flexibility of log processing.
Step S205, sending a log printing condition acquisition request by using a jar packet corresponding to the agent program; the log printing condition acquisition request comprises an application program number; a log printing condition corresponding to the application number is received.
According to the embodiment of the invention, the latest log printing condition is obtained by using the jar packet corresponding to the agent program, and the log to be printed is determined by matching the application instance with the log printing condition.
According to a specific implementation manner of the embodiment of the invention, because the logagent.jar is dynamically connected to the application instance of the application program, for each application instance connected with the logagent.jar packet, the logagent.jar is respectively used for acquiring the corresponding log printing condition, so that each application instance can acquire the latest log printing condition corresponding to the application program, system resources are saved, the application scene of log processing is expanded, and the log processing efficiency is improved.
And S206, traversing the class, the method and the array of the application example, determining a matching item according to the log printing condition, and determining the log to be printed according to the matching item.
Specifically, according to the embodiment of the present invention, the matching items include at least one of a class matching item, a method matching item, and a group matching item.
According to a specific embodiment of the present invention, after acquiring an application instance IP of an application program to be logged by a CMS management platform, a log agent () method is called to dynamically attach to the application instance of the application program, jvm (Java Virtual Machine) on the application instance detects the log agent, creates an instrumentation im object and executes a loadclassmarandcoassargetmain () method, transfers the I instrumentation im object to the log agent, wherein the instrumentation im object provides all class information that jvm has loaded, a code conversion logic or a bytecode enhancement logic in the log agent jar acquires all class information that jvm has loaded through the instrumentation im object, then makes a loop judgment, and performs a matching on each class according to the log name, a log name matching method, and if the log name matching method is used to match the log name, a print the log name, a corresponding byte name, and a print parameter matching method, and if the log name matches the log name, namely:
logo. info ("[ call into ginseng ] - [" + jacksonuth. tojson (args) + "]");
inserting a code returned by the printing method after the matching item, namely:
logo. info ("[ call out ginseng ] - [" + jacksonutility. tojson (rtn) + "]);
if the corresponding result of the matching item in the log printing condition is false, returning the inserted code to an initial loading state; if no matching item exists, no processing is carried out, the next class/method/array matching is continuously executed, and the steps are executed in a circulating mode until the complete class/method/array is traversed.
Through the arrangement, the matching processing can be rapidly and comprehensively carried out by traversing the classes, the methods and the arrays in the application examples, so that the logs to be printed are determined, and the accuracy of log processing is improved.
And step S207, modifying the byte code corresponding to the log to be printed, and performing print output processing on the log to be printed.
Through the arrangement, after the log to be printed is determined, the printing output processing can be executed only by modifying the byte codes, and because the byte code modification operation can be realized by any log frame or a third-party tool and the like, the problem that the log processing application scene is narrow due to the fact that the log frame is completely depended on when the log level is adjusted in the prior art is solved.
Further, according to an embodiment of the present invention, the log processing method further includes:
updating the log printing conditions according to application requirements;
and acquiring the updated log printing condition by using the jar packet corresponding to the agent program, determining the log to be printed according to the updated log printing condition, and printing and outputting the log to be printed.
Through the setting, the log printing condition can be updated according to the change of the application requirement, so that the log to be printed is determined according to the updated log printing condition, the flexibility of log processing is further improved, the applicable scene of log processing is expanded, and the user experience is improved.
According to the technical scheme of the embodiment of the invention, the application program is operated, wherein the jar packet corresponding to the agent program is connected to the application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; the technical means of modifying the byte code corresponding to the log to be printed and printing and outputting the log to be printed are adopted, so that the technical problems that the flexibility of log processing is poor, system resources are wasted, the applicable scenes of log processing are few, and the user experience is poor due to the fact that the code logic of the log to be printed must be pre-existed at the position where the log is to be printed in the existing log processing method and the log to be printed can only be determined according to the log level are solved, and the technical effects of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenes of log processing and improving the user experience are achieved.
FIG. 3 is a schematic diagram of the main modules of a log processing apparatus provided according to an embodiment of the present invention; as shown in fig. 3, the log processing apparatus 300 according to the embodiment of the present invention mainly includes:
the running module 301 is configured to run an application program, where an application instance of the application program is connected with a jar package corresponding to the agent program.
Specifically, according to the embodiment of the present invention, before or after the application program is run, a jar packet (i.e., log agent jar) corresponding to the agent program is dynamically connected to the application instance of the application program, so that a log printing condition corresponding to the application program is subsequently obtained through the log agent jar, and the log to be printed is determined by matching the application instance with the log printing condition, thereby achieving the technical effects of improving the log processing efficiency and improving the flexibility of log processing.
The matching module 302 is configured to obtain a log printing condition by using a jar packet corresponding to the agent, and match the application instance with the log printing condition to determine a log to be printed.
According to the embodiment of the present invention, the matching module 302 is configured to obtain the latest log printing condition by using the jar packet corresponding to the agent, and further perform matching according to the application instance and the log printing condition to determine the log to be printed.
According to a specific implementation manner of the embodiment of the invention, because the logagent.jar is dynamically connected to the application instance of the application program, for each application instance connected with the logagent.jar packet, the logagent.jar is respectively used for acquiring the corresponding log printing condition, so that each application instance can acquire the latest log printing condition corresponding to the application program, system resources are saved, the application scene of log processing is expanded, and the log processing efficiency is improved.
Further, according to an embodiment of the present invention, the log processing apparatus 300 further includes a log printing condition configuration module, before the step of obtaining the log printing condition by using the jar packet corresponding to the agent, the log printing condition configuration module is configured to:
acquiring application program information, wherein the application program information comprises an application instance;
and configuring log printing conditions for the application instances according to application requirements.
Through the setting, the log printing condition corresponding to each application program is determined according to the application requirements (such as testing requirements and data processing requirements, and the application requirements indicate the log type to be printed), so that the flexibility of log processing is improved.
Preferably, according to an embodiment of the present invention, the log printing condition configuration module is further configured to:
determining a class, a method and an array corresponding to the application instance;
and performing printing configuration on at least one of the class, the method and the array corresponding to the application instance according to the application requirement to determine the log printing condition.
Through the setting, the printing configuration (whether a certain type, a certain method and/or a certain array corresponding to the application instance is configured to be printed or not) is respectively carried out by combining the application requirements and the type, the method and/or the array specifically corresponding to the application instance, so that the log printing condition is generated, the log printing condition can be favorably and rapidly matched with the application instance in the running process of the application program according to the log printing condition, the log to be printed can be rapidly determined, and the log processing efficiency can be improved.
Illustratively, according to an embodiment of the present invention, the log processing apparatus 300 further includes a storage module, configured to:
constructing a mapping table of application program numbers and log printing conditions;
a mapping table is stored.
Through the setting, the purpose of constructing the mapping table is to facilitate log agents to quickly acquire log printing conditions corresponding to the application program, so that the log processing efficiency is further improved, and the user experience is improved.
Specifically, according to an embodiment of the present invention, the matching module 302 is further configured to:
sending a log printing condition acquisition request by using a jar packet corresponding to the agent program; the log printing condition acquisition request comprises an application program number;
a log printing condition corresponding to the application number is received.
According to a specific implementation manner of the embodiment of the present invention, the configuration process of the journal printing condition is configured through a CMS (Content Management System) Management platform, and after receiving a journal printing condition acquisition request including an application number sent by logagent.
Further, according to an embodiment of the present invention, the matching module 302 is further configured to:
traversing classes, methods and arrays of application instances, and determining matching items according to log printing conditions, wherein the matching items comprise at least one of class matching items, method matching items and array matching items;
and determining the log to be printed according to the matching item.
Through the arrangement, the matching processing can be rapidly and comprehensively carried out by traversing the classes, the methods and the arrays in the application examples, so that the logs to be printed are determined, and the accuracy of log processing is improved.
And the processing module 303 is configured to modify the bytecode corresponding to the log to be printed, and perform print output processing on the log to be printed.
Through the arrangement, after the log to be printed is determined, the printing output processing can be executed only by modifying the byte codes, and because the byte code modification operation can be realized by any log frame or a third-party tool and the like, the problem that the log processing application scene is narrow due to the fact that the log frame is completely depended on when the log level is adjusted in the prior art is solved.
Further, according to the embodiment of the present invention, the log processing apparatus 300 further includes an updating module, configured to:
updating the log printing conditions according to application requirements;
and acquiring the updated log printing condition by using the jar packet corresponding to the agent program, determining the log to be printed according to the updated log printing condition, and printing and outputting the log to be printed.
Through the setting, the log printing condition can be updated according to the change of the application requirement, so that the log to be printed is determined according to the updated log printing condition, the flexibility of log processing is further improved, the applicable scene of log processing is expanded, and the user experience is improved.
According to the technical scheme of the embodiment of the invention, the application program is operated, wherein the jar packet corresponding to the agent program is connected to the application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; the technical means of modifying the byte code corresponding to the log to be printed and printing and outputting the log to be printed are adopted, so that the technical problems that the flexibility of log processing is poor, system resources are wasted, the applicable scenes of log processing are few, and the user experience is poor due to the fact that the code logic of the log to be printed must be pre-existed at the position where the log is to be printed in the existing log processing method and the log to be printed can only be determined according to the log level are solved, and the technical effects of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenes of log processing and improving the user experience are achieved.
Fig. 4 shows an exemplary system architecture 400 to which the log processing method or the log processing apparatus of the embodiment of the present invention can be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405 (this architecture is merely an example, and the components included in a particular architecture may be adapted according to application specific circumstances). The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have various communication client applications installed thereon, such as a data processing application, a log printing application, an instant messaging tool, a mailbox client, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server that provides various services, such as a server (for example only) that performs log processing/data processing on users using the terminal devices 401, 402, 403. The server may analyze and otherwise process the received data such as the log printing condition, and feed back the processing result (e.g., the log to be printed, just an example) to the terminal device.
It should be noted that the log processing method provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, the log processing apparatus is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the central processing unit (CP U) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a module, a matching module, and a processing module. The names of the modules do not limit the modules themselves in some cases, for example, the running module may also be described as "a module for running an application program, wherein an application instance of the application program is connected with a jar package corresponding to an agent program".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: running an application program, wherein a jar packet corresponding to the agent program is connected to an application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; and modifying the byte code corresponding to the log to be printed, and printing and outputting the log to be printed.
According to the technical scheme of the embodiment of the invention, the application program is operated, wherein the jar packet corresponding to the agent program is connected to the application instance of the application program; obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed; the technical means of modifying the byte code corresponding to the log to be printed and printing and outputting the log to be printed are adopted, so that the technical problems that the flexibility of log processing is poor, system resources are wasted, the applicable scenes of log processing are few, and the user experience is poor due to the fact that the code logic of the log to be printed must be pre-existed at the position where the log is to be printed in the existing log processing method and the log to be printed can only be determined according to the log level are solved, and the technical effects of improving the flexibility and processing efficiency of log processing, saving system resources, expanding the applicable scenes of log processing and improving the user experience are achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A log processing method, comprising:
running an application program, wherein a jar packet corresponding to an agent program is connected to an application instance of the application program;
obtaining a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed;
and modifying the byte code corresponding to the log to be printed, and printing and outputting the log to be printed.
2. The log processing method according to claim 1, wherein before the step of obtaining the log printing condition by using the jar packet corresponding to the agent, the method further comprises a step of configuring the log printing condition, comprising:
acquiring application program information, wherein the application program information comprises an application instance;
and configuring log printing conditions for the application examples according to application requirements.
3. The log processing method according to claim 2, wherein the step of configuring the log printing condition for the application instance according to the application requirement further comprises:
determining a class, a method and an array corresponding to the application instance;
and performing printing configuration on at least one of the class, the method and the array corresponding to the application instance according to the application requirement so as to determine the log printing condition.
4. The log processing method according to claim 2, wherein the application information further includes an application number; the log processing method further comprises the following steps:
constructing a mapping table of the application program number and the log printing condition;
and storing the mapping table.
5. The log processing method according to claim 4, wherein the step of obtaining the log printing condition by using jar packets corresponding to the agent comprises:
sending a log printing condition acquisition request by using a jar packet corresponding to the agent program; wherein, the log printing condition acquisition request comprises the application program number;
and receiving a log printing condition corresponding to the application program number.
6. The log processing method according to claim 3, wherein the step of matching the application instance with the log printing condition to determine the log to be printed comprises:
traversing the class, the method and the array of the application instance, and determining a matching item according to the log printing condition, wherein the matching item comprises at least one of a class matching item, a method matching item and an array matching item;
and determining the log to be printed according to the matching item.
7. The log processing method according to claim 6, further comprising:
updating the log printing condition according to application requirements;
and acquiring updated log printing conditions by using jar packets corresponding to the agent program, determining logs to be printed according to the updated log printing conditions, and printing and outputting the logs to be printed.
8. A log processing apparatus, comprising:
the running module is used for running an application program, wherein a jar packet corresponding to the agent program is connected to an application instance of the application program;
the matching module is used for acquiring a log printing condition by using a jar packet corresponding to the agent program, and matching the application instance with the log printing condition to determine a log to be printed;
and the processing module is used for modifying the byte codes corresponding to the logs to be printed and carrying out printing output processing on the logs to be printed.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202110081935.7A 2021-01-21 2021-01-21 Log processing method and device Pending CN113778969A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110081935.7A CN113778969A (en) 2021-01-21 2021-01-21 Log processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110081935.7A CN113778969A (en) 2021-01-21 2021-01-21 Log processing method and device

Publications (1)

Publication Number Publication Date
CN113778969A true CN113778969A (en) 2021-12-10

Family

ID=78835534

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110081935.7A Pending CN113778969A (en) 2021-01-21 2021-01-21 Log processing method and device

Country Status (1)

Country Link
CN (1) CN113778969A (en)

Similar Documents

Publication Publication Date Title
CN110858172A (en) Automatic test code generation method and device
CN111427701A (en) Workflow engine system and business processing method
CN110896362B (en) Fault detection method and device
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN110275701B (en) Data processing method, device, medium and computing equipment
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN113541987A (en) Method and device for updating configuration data
CN112948138A (en) Method and device for processing message
CN114070889B (en) Configuration method, traffic forwarding device, storage medium, and program product
CN113778969A (en) Log processing method and device
CN113556370A (en) Service calling method and device
CN111488286B (en) Method and device for independently developing Android modules
CN113760693A (en) Method and apparatus for local debugging of microservice systems
CN112783903B (en) Method and device for generating update log
CN114064803A (en) Data synchronization method and device
CN113742235A (en) Method and device for checking codes
CN113779122A (en) Method and apparatus for exporting data
CN113779018A (en) Data processing method and device
CN113760487A (en) Service processing method and device
CN113766437B (en) Short message sending method and device
CN112835609A (en) Method and device for modifying dependent package download address
CN110858240A (en) Front-end module loading method and device
CN113688152B (en) System function self-checking method and device
CN112783665B (en) Interface compensation method and device
CN117667289A (en) Loading rendering method and device of application component

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