CN110399107B - Log printing method, device, storage medium and equipment - Google Patents

Log printing method, device, storage medium and equipment Download PDF

Info

Publication number
CN110399107B
CN110399107B CN201910671531.6A CN201910671531A CN110399107B CN 110399107 B CN110399107 B CN 110399107B CN 201910671531 A CN201910671531 A CN 201910671531A CN 110399107 B CN110399107 B CN 110399107B
Authority
CN
China
Prior art keywords
log
preset
target
configuration
context object
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910671531.6A
Other languages
Chinese (zh)
Other versions
CN110399107A (en
Inventor
戴桥斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Mengtian Technology Co ltd
Original Assignee
Shenzhen Mengtian 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 Shenzhen Mengtian Technology Co ltd filed Critical Shenzhen Mengtian Technology Co ltd
Priority to CN201910671531.6A priority Critical patent/CN110399107B/en
Publication of CN110399107A publication Critical patent/CN110399107A/en
Application granted granted Critical
Publication of CN110399107B publication Critical patent/CN110399107B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • 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
    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application discloses a log printing method, a log printing device, a storage medium and log printing equipment. The method comprises the following steps: when a call request for a target application program is detected through a call entry component, a corresponding preset log configuration is obtained, a target log context object is created in a local thread according to the preset log configuration, wherein the target log context object contains log list attributes corresponding to the preset log configuration, the obtained log information corresponding to the call entry component and the obtained log information through a preset log interface are added to the target log context object according to the log list attributes, and when the completion of the call process for the target application program is detected, the log information contained in the target log context object is printed through the call entry component by using a preset log output interface so as to generate a log file. The embodiment of the application can more intuitively check the execution link of the application program and save the storage space.

Description

Log printing method, device, storage medium and equipment
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a log printing method, a log printing device, a storage medium and log printing equipment.
Background
The log of the application program can record the running track of the application program, so that key information can be conveniently searched, and the problem can be conveniently and rapidly positioned and solved. The role of the log includes as an important means for the developer or tester to locate problems when the test or production environment does not have Debug tools. The log is printed reasonably, so that the online problem can be quickly positioned and solved according to the track of the log, otherwise, the log is printed poorly, the problem cannot be positioned, and the performance of the system can be possibly influenced.
At present, a method commonly adopted in log printing depends on an application programming interface (Application Programming Interface, API) such as slf4j and the like to print the log, but the log printing in the log file is quite scattered, an execution link of an application program cannot be intuitively seen, and excessive redundant log information can cause excessive occupation of storage space, so that the current log printing scheme needs to be improved.
Disclosure of Invention
The embodiment of the application provides a log printing method, a device, a storage medium and equipment, which can optimize the existing log printing scheme.
In a first aspect, an embodiment of the present application provides a log printing method, including:
when a call request for a target application program is detected through a call entry component, acquiring a corresponding preset log configuration, wherein the call entry component comprises one of a plurality of preset log agents;
creating a target log context object in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration;
adding the acquired log information corresponding to the call entry component to the target log context object according to the log list attribute;
when the target application program is detected to call a preset log interface, adding the log information acquired through the preset log interface into the target log context object according to the log list attribute;
when the completion of the calling process for the target application program is detected, the log information contained in the target log context object is printed by using a preset log output interface through the calling entry component so as to generate a log file.
In a second aspect, an embodiment of the present application provides a log printing apparatus, including:
the system comprises a log configuration acquisition module, a target application program acquisition module and a log configuration processing module, wherein the log configuration acquisition module is used for acquiring corresponding preset log configuration when a call request for the target application program is detected through a call entry component, and the call entry component comprises one of a plurality of preset log agents;
the object creating module is used for creating a target log context object in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration;
the first log information adding module is used for adding the obtained log information corresponding to the calling entry component into the target log context object according to the log list attribute;
the second log information adding module is used for adding the log information acquired through the preset log interface into the target log context object according to the log list attribute when the target application program is detected to call the preset log interface;
and the log printing module is used for printing log information contained in the target log context object by using a preset log output interface through the call entry component when the call process for the target application program is detected to be finished, so as to generate a log file.
In a third aspect, an embodiment of the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a log printing method as provided by the embodiment of the present application.
In a fourth aspect, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored on the memory and capable of running on the processor, where the processor implements a log printing method as provided in the embodiment of the present application when the processor executes the computer program.
According to the log printing scheme provided by the embodiment of the application, when a call request for a target application program is detected through a call entry component, a corresponding preset log configuration is obtained, a target log context object is created in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration, the obtained log information corresponding to the call entry component is added to the target log context object according to the log list attribute, when the call entry component is detected to call a preset log interface, the log information obtained through the preset log interface is added to the target log context object according to the log list attribute, and when the call process for the target application program is detected to finish, the log information contained in the target log context object is printed through the call entry component by using a preset log output interface, so that a log file is generated. By adopting the technical scheme, log printing oriented to calling can be realized, targeted log information acquisition is carried out according to preset log configuration, and log information corresponding to the calling process is connected in series through a local thread, so that an execution link of an application program can be more intuitively checked, and the storage space is saved.
Drawings
Fig. 1 is a schematic flow chart of a log printing method according to a first embodiment of the present application;
fig. 2 is a flow chart of a log printing method according to a second embodiment of the present application;
fig. 3 is a schematic diagram of a log printing scheme according to a second embodiment of the present application;
fig. 4 is a block diagram of a log printing device according to a third embodiment of the present application;
fig. 5 is a block diagram of a computer device according to a fifth embodiment of the present application.
Detailed Description
The technical scheme of the application is further described below by the specific embodiments with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present application are shown in the drawings.
Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts steps as a sequential process, many of the steps may be implemented in parallel, concurrently, or with other steps. Furthermore, the order of the steps may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
Example 1
Fig. 1 is a flow chart of a log printing method according to an embodiment of the present application, which may be executed by a log printing device, wherein the device may be implemented by software and/or hardware, and may be generally integrated in a computer device. As shown in fig. 1, the method includes:
step 101, when a call request for a target application program is detected through a call entry component, a corresponding preset log configuration is obtained, wherein the call entry component comprises one of a plurality of preset log agents.
For example, first, a simple description will be made of an in-application log framework on which the log printing method provided by the embodiment of the present application depends. In the technical scheme of the embodiment of the application, the log framework comprises a plurality of preset log agents and a plurality of preset log interfaces.
Wherein the preset log agents may include Dubbo log agents (Dubbo log proxy), MQ log agents (MQ log proxy), mybatis log agents (Mybatis log proxy), and Redis log agents (Redis log proxy), the call entry component includes Dubbo log agents and/or MQ log agents. Dubbo is an open-source high-performance and lightweight Java remote procedure call (Remote Procedure Call, RPC) framework that provides the capabilities of interface-oriented remote method call, intelligent fault tolerance and load balancing, and service auto-registration and discovery. Message Queue (MQ) is also an RPC component. Mybatis is an excellent persistence layer framework that supports custom structured query language (Structured Query Language, SQL), stored procedures, and high-level mappings. Redis is an open-source support network, can be based on a memory or can be persistent log-type, key-Value (Key-Value) database, and provides multiple language APIs. Each of the above-described preset logging agents may be considered a logging component that interfaces with an application component. The four preset log agents are only illustrative, and may also include other types of log agents, which are not limited by the embodiments of the present application. The call entry component in embodiments of the present application may be a Dubbo log agent and/or an MQ log agent.
The preset log interface is a custom interface according to the embodiment of the present application, and may be denoted as logapi, or lapi for short. In the related art, log or log-info is a call standard log output interface, and in the embodiment of the present application, the place where the application program originally calls log or log-info can be replaced with the lapi in the embodiment of the present application. The lapi is realized like log4j, is a self-defined log api which realizes and expands the slf4j interface, and can expand functions which slf4j does not have, such as dynamically setting the maximum value of log call chain list, etc.
Illustratively, taking the call entry component as Dubbo log proxy as an example, a call request for a target application may be initiated by a Dubbo caller (e.g., dubbo client), and the Dubbo log proxy of the target application may intercept the call request in the form of a Dubbo interceptor, thereby detecting the call request for the target application. If the call entry component is an MQ log proxy, an interceptor can be set on the MQ message monitoring method, and the MQ message confirms the money of the message consumption method every time, and the method for executing the MQ proxy is firstly entered, so that the call request for the target application program is detected.
Exemplary, the preset log configuration includes at least one of the following: target calling equipment, target calling application, target calling class, target calling method, statement execution information, parameter entering, parameter exiting, time consuming and printing format. Thus, selective and targeted printing of the log can be realized through preset log configuration. The preset log configuration may be stored locally or in other devices. For example, the preset log configuration may be stored in a configuration center (configer center). Optionally, the obtaining the corresponding preset log configuration includes: and acquiring corresponding preset log configuration from a preset configuration center. This has the advantage that it can facilitate the management of the preset log configuration.
Further, the preset log agent and/or the preset log interface include preset configuration information, and corresponding preset log configuration is dynamically configured in the preset configuration center according to the preset configuration information. The method has the advantages that the preset log configuration can be set on line, the real-time effect is achieved, and the flexibility of log printing is improved. Optionally, the configuration center middleware can dynamically configure corresponding preset log configuration according to the preset configuration information, and take a zookeeper as an example, the configuration information can be configured on the zookeeper and synchronized to each application node through a distributed consistency protocol, so that real-time synchronization of online configuration is achieved.
Step 102, creating a target log context object in the local thread according to the preset log configuration, wherein the target log context object contains a log list attribute corresponding to the preset log configuration.
Illustratively, the local thread (local) is a local thread Cheng Fuben variable tool class, and can store objects in the local thread, such as a log context object (logContext), where the objects have properties of a log list, and when the objects are created, the list data structure of the log list is initialized, that is, a target log context object is created in the local thread according to a preset log configuration, and the target log context object includes the log list properties corresponding to the preset log configuration.
And step 103, adding the obtained log information corresponding to the call entry component to the target log context object according to the log list attribute.
By way of example, the log information herein may include application names, called class full paths, and calling method names, among others. The log list attribute corresponds to a preset log configuration, so that the obtained log information can be added to the target log context object according to the preset log configuration.
And 104, when the target application program is detected to call a preset log interface, adding the log information acquired through the preset log interface into the target log context object according to the log list attribute.
When the target program is detected to call the preset log interface to print the log, the acquired log information is added to the target log context object according to the log list attribute, so that the required log information is summarized in the local thread, and the subsequent unified output is facilitated.
And 105, when the completion of the calling process for the target application program is detected, printing log information contained in the target log context object by using a preset log output interface through the calling entry component to generate a log file.
For example, when the whole calling process for the target application program is finished, the calling thread returns to the calling entry component, and the relevant log information when the calling is finished can be added to the target log context object according to the log list attribute, so that the log information of the whole calling chain is contained in the wirelocal, and the calling entry component prints the log information contained in the target log context object by using the preset log output interface, so that the log file can be generated. The preset log output interface may be log4j of slf4j, so as to realize that the api outputs a log to the log system.
According to the log printing method provided by the embodiment of the application, when a call request for a target application program is detected through a call entry component, a corresponding preset log configuration is obtained, a target log context object is created in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration, the obtained log information corresponding to the call entry component is added to the target log context object according to the log list attribute, when the call entry component is detected to call a preset log interface, the log information obtained through the preset log interface is added to the target log context object according to the log list attribute, and when the call process for the target application program is detected to finish, the log information contained in the target log context object is printed through the call entry component by using a preset log output interface, so that a log file is generated. By adopting the technical scheme, log printing oriented to calling can be realized, targeted log information acquisition is carried out according to preset log configuration, and log information corresponding to the calling process is connected in series through a local thread, so that an execution link of an application program can be more intuitively checked, and the storage space is saved.
Example two
Fig. 2 is a schematic flow chart of a log printing method according to a second embodiment of the present application, where the log information processing related content when a target application program calls a preset log agent is added by optimizing the log printing method according to the embodiment of the present application.
Illustratively, after the creating the target log context object in the local thread according to the preset log configuration, the method further includes: when the target application program is detected to call a target log agent in the plurality of preset log agents, the log information acquired from the target log agent is added into the target log context object according to the log list attribute. The advantage of this arrangement is that log information can be obtained more comprehensively, and complete call chain log information is printed into the log file.
Further, the creating the target log context object in the local thread according to the preset log configuration includes: creating a log context object in a local thread, and initializing a list data structure of a log list in the created log context object according to a log output template contained in the preset log configuration to obtain a target log context object. The method has the advantages that personalized setting of the content of the log file can be realized more conveniently by setting the log output template, and configurable setting can be carried out on the log output template for business.
Specifically, as shown in fig. 2, the method may include the following steps:
step 201, when a call request for a target application program is detected through a call entry component, a corresponding preset log configuration is obtained from a preset configuration center.
Fig. 3 is a schematic diagram of a log printing scheme according to a second embodiment of the present application, as shown in fig. 3, core components in the scheme are various log proxy (log proxy) and a preset log interface (lapi), and call information (such as a parameter entering, parameter exiting, time consuming, custom log, etc.) of each proxy and lapi are connected in series by a local thread (local). The preset journal agents include a Dubbo journal agent, an MQ journal agent, a Mybatis journal agent, and a Redis journal agent, where the Dubbo journal agent and the MQ journal agent may act as call entry components. In fig. 3, 4 preset log interfaces (lapi) are shown. The configuration center (configer center) is used for storing preset log configuration and a log output template, and corresponding preset log configuration can be dynamically configured in the preset configuration center according to preset configuration information contained in a preset log agent or a preset log interface.
Illustratively, the preset log configuration includes at least one of the following: target calling equipment, target calling application, target calling class, target calling method, statement execution information, parameter entering, parameter exiting, time consuming and printing format. Illustratively, the Dubbo log agent and the MQ log agent may share one configuration, or may set a personalized configuration for the Dubbo and MQ sub-tables, e.g., the portal log configuration mylog.application.entry.model may share one configuration, e.g., whether message topic (topic) information of the MQ is to be output, whether information of the Dubbo caller is to be output, etc.
In addition, other personalized configurations are possible. It may include, but is not limited to, settings that may be configured to shut down all log printing, print only logs for a certain package or class, print info or debug logs, output complete sql statements, output log proxy entries or trips, etc. For example, to mask all other business logs, print only a certain machine, a certain class of application, a certain method log, the following settings can be made in the configuration: mylog.application.log switch=off, setting the applied traffic log output switch to off, and not configuring default to on; mylog.application.method.whistle=com.fashion.postlog.asset.mqConsum erImpl.Consumer, set up the journal print white list as the con method of the com.fenqile.postlog.asset.mqConsumerImpl implementation class of postlog.asset application, not configure default not to filter; mylog.application.log switch.ip.whistelist= 10.79.10.6, set the machine ip of the print log to 10.79.10.6, and not configure default unfiltered. The method name full path and the parameter entry of the called method can be obtained through a method in a preset log agent, the native ip address information can be obtained through the api of java, and the filtering of the information can be achieved according to configuration information in the preset log agent.
Step 202, creating a log context object in a local thread, and initializing a list data structure of a log list in the created log context object according to a log output template contained in a preset log configuration to obtain a target log context object.
And the target log context object comprises a log list attribute corresponding to the preset log configuration. For example, the list data structure of the log list corresponds to the log output template. The log output template may be specifically in the form of mylog.application.entry.model=% method name,% params: [% params% ], the first line of the identified log output method name, comma, params followed [ ] is a reference. Alternatively, the log output template may be configured in an attribute value with a key of mylog.app.model in the configuration center, and a value type standard such as a definition standard key=value of properties file.
And 203, adding the obtained log information corresponding to the call entry component to the target log context object according to the log list attribute.
For example, the obtained log information corresponding to the call entry component is assembled according to the attribute of the log list by using an add method of a call list (list), and the obtained log information is added to the target log context object. Specifically, the character String output by the entry log may be assembled according to the log list attribute and stored in a list of String type in the log context object of the threaded, and specifically, the add method of the list may be called.
And 204, when the target application program is detected to call a preset log interface, adding the log information acquired through the preset log interface into the target log context object according to the log list attribute.
When the target application program is detected to call a preset log interface, the log information acquired through the preset log interface is assembled according to the character strings corresponding to the log information through an add method of a call list (list) according to the attribute of the log list, and the character strings are added into the target log context object. Specifically, the log String may be saved in a list of String type in the log context object of the threaded, and specifically, the add method of the list may be called.
And 205, when the target application program is detected to call a target log agent in the plurality of preset log agents, adding the log information acquired from the target log agent into the target log context object according to the log list attribute.
When the target application program is detected to call a target log agent in the plurality of preset log agents, the log information acquired from the target log agent is assembled according to the character strings corresponding to the log information by an add method of a call list (list) according to the attribute of the log list, and the character strings are added into the target log context object. Taking the target log agent as a Redis as an example, if the target application program calls to the Redis, the corresponding log character String (such as a calling method, a parameter entering and a parameter exiting and the like) can be output through log configuration in the logContext through an interceptor in the Redis log proxy and stored in a list of String type in a log Context object of the wireless local, and specifically, an add method of the list can be called. Mybatis is similar to Redis and will not be described here again.
And 206, when the completion of the calling process for the target application program is detected, printing log information contained in the target log context object by using a preset log output interface through the calling entry component to generate a log file.
For example, after the final method is called, the calling thread returns to the Dubbo proxy, outputs a corresponding result log character String according to the log configuration in the logContext and stores the result log character String in a list of String type in the log context object of the threaded, and finally calls the log4j implementation api of the slf4j to output a log to the log system.
In the technical solution of the embodiment of the present application, the log output according to the custom application log includes the entry information, which specific call can be locked quickly, and all the information on the call link can be seen at a glance. For example, the method named full path of com.fenqile.postload.asset.mqConsumerImpl.Consumer contains much information, the application called is postload.asset, the implementation class is mqConsumerImpl, the method is Consumer, if the template is set with the ip to be printed, and which machine can be seen through log output. In addition, by filtering the incoming parameters, the order number or other attributes can be positioned, so that the filtering according to the service order can be supported, and only all or part of information of the order corresponding call link meeting the matching condition is printed without issuing or restarting the machine.
The log printing method provided by the embodiment of the application can realize call-oriented log printing, can customize log output in real time, can formulate a configurable log template for business, utilizes a local thread to connect call information of each preset log agent and preset log interface in series, reflects a complete link of a call process in a finally printed log, and solves the problems of too large log and poor readability in the log output process. Experiments prove that the technical scheme provided by the embodiment of the application can well support the production throughput (Transactions Per Second, TPS) to reach more than 1500 levels in an asset management system, and in the aspect of positioning problems, the problem positioning which needs to be completed in 1 to 2 hours in the past can be reduced to 2 to 5 minutes by adopting the technical scheme of the embodiment of the application. In addition, online configuration can be supported, real-time effectiveness is realized, and the flexibility of log printing is very high and the adaptability is strong.
Example III
Fig. 4 is a block diagram of a log printing device according to a third embodiment of the present application, where the device may be implemented by software and/or hardware, and may be generally integrated in a computer device, and may perform log printing by executing a log printing method. As shown in fig. 4, the apparatus includes:
a log configuration obtaining module 401, configured to obtain a corresponding preset log configuration when a call request for a target application program is detected through a call entry component, where the call entry component includes one of a plurality of preset log agents;
an object creating module 402, configured to create a target log context object in a local thread according to the preset log configuration, where the target log context object includes a log list attribute corresponding to the preset log configuration;
a first log information adding module 403, configured to add the obtained log information corresponding to the call entry component to the target log context object according to the log list attribute;
the second log information adding module 404 is configured to add, when it is detected that the target application program invokes a preset log interface, log information obtained through the preset log interface to the target log context object according to the log list attribute;
and the log printing module 405 is configured to print, by using a preset log output interface, log information included in the target log context object through the call entry component to generate a log file when it is detected that the call process for the target application is completed.
According to the log printing device provided by the embodiment of the application, when a call request for a target application program is detected through the call entry component, a corresponding preset log configuration is obtained, a target log context object is created in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration, the obtained log information corresponding to the call entry component is added to the target log context object according to the log list attribute, when the call entry component is detected to call the preset log interface, the log information obtained through the preset log interface is added to the target log context object according to the log list attribute, and when the call process for the target application program is detected to finish, the log information contained in the target log context object is printed through the call entry component by using the preset log output interface, so that a log file is generated. By adopting the technical scheme, log printing oriented to calling can be realized, targeted log information acquisition is carried out according to preset log configuration, and log information corresponding to the calling process is connected in series through a local thread, so that an execution link of an application program can be more intuitively checked, and the storage space is saved.
Optionally, the apparatus may further include:
and the third log information adding module is used for adding the log information acquired from the target log agent into the target log context object according to the log list attribute when the target application program is detected to call the target log agent in the plurality of preset log agents after the target log context object is created in the local log program according to the preset log configuration.
Optionally, the creating the target log context object in the local thread according to the preset log configuration includes:
creating a log context object in a local thread, and initializing a list data structure of a log list in the created log context object according to a log output template contained in the preset log configuration to obtain a target log context object.
Optionally, adding log information to the target log context object according to the log list attribute includes:
and assembling the character strings corresponding to the log information according to the log list attribute by calling an adding method of the list, and adding the character strings into the target log context object.
Optionally, the preset log configuration includes at least one of the following:
target calling equipment, target calling application, target calling class, target calling method, statement execution information, parameter entering, parameter exiting, time consuming and printing format.
Optionally, the obtaining the corresponding preset log configuration includes:
corresponding preset log configuration is obtained from a preset configuration center, wherein the preset log agent and/or the preset log interface contain preset configuration information, and corresponding preset log configuration is dynamically configured according to the preset configuration information in the preset configuration center.
Optionally, the preset log agent includes a Dubbo log agent, a message queue MQ log agent, a Mybatis log agent, and a Redis log agent, and the call entry component includes a Dubbo log agent or an MQ log agent.
Example IV
Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing a log printing method, the method comprising:
when a call request for a target application program is detected through a call entry component, acquiring a corresponding preset log configuration, wherein the call entry component comprises one of a plurality of preset log agents;
creating a target log context object in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration;
adding the acquired log information corresponding to the call entry component to the target log context object according to the log list attribute;
when the target application program is detected to call a preset log interface, adding the log information acquired through the preset log interface into the target log context object according to the log list attribute;
when the completion of the calling process for the target application program is detected, the log information contained in the target log context object is printed by using a preset log output interface through the calling entry component so as to generate a log file.
Storage media-any of various types of memory devices or storage devices. The term "storage medium" is intended to include: mounting media such as CD-ROM, floppy disk or tape devices; computer system memory or random access memory, such as DRAM, DDRRAM, SRAM, EDORAM, rambus (Rambus) RAM, etc.; nonvolatile memory such as flash memory, magnetic media (e.g., hard disk or optical storage); registers or other similar types of memory elements, etc. The storage medium may also include other types of memory or combinations thereof. In addition, the storage medium may be located in a first computer system in which the program is executed, or may be located in a second, different computer system connected to the first computer system through a network such as the internet. The second computer system may provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media that may reside in different locations (e.g., in different computer systems connected by a network). The storage medium may store program instructions (e.g., embodied as a computer program) executable by one or more processors.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present application is not limited to the log printing operation described above, and may also perform the related operations in the log printing method provided in any embodiment of the present application.
Example five
The embodiment of the application provides a computer device, and the log printing device provided by the embodiment of the application can be integrated in the computer device. Fig. 5 is a block diagram of a computer device according to a fifth embodiment of the present application. The computer device 500 may include: the system comprises a memory 501, a processor 502 and a computer program stored in the memory 501 and capable of being run by the processor, wherein the processor 502 realizes the log printing method according to the embodiment of the application when executing the computer program.
The computer equipment provided by the embodiment of the application can realize call-oriented log printing, and can obtain the targeted log information according to the preset log configuration, and the log information corresponding to the calling process is connected in series through the local thread, so that the execution link of the application program can be more intuitively checked, and the storage space is saved.
The log printing device, the storage medium and the computer equipment provided in the above embodiments can execute the log printing method provided in any embodiment of the present application, and have the corresponding functional modules and beneficial effects of executing the method. Technical details not described in detail in the above embodiments may be referred to the log printing method provided in any embodiment of the present application.
Note that the above is only a preferred embodiment of the present application and the technical principle applied. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the application, which is set forth in the following claims.

Claims (10)

1. A log printing method, comprising:
when a call request for a target application program is detected through a call entry component, acquiring a corresponding preset log configuration, wherein the call entry component comprises one of a plurality of preset log agents;
creating a target log context object in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration;
adding the acquired log information corresponding to the call entry component to the target log context object according to the log list attribute;
when the target application program is detected to call a preset log interface, adding the log information acquired through the preset log interface into the target log context object according to the log list attribute;
when the completion of the calling process for the target application program is detected, the log information contained in the target log context object is printed by using a preset log output interface through the calling entry component so as to generate a log file.
2. The method of claim 1, further comprising, after said creating a target log context object in a local thread according to said preset log configuration:
when the target application program is detected to call a target log agent in the plurality of preset log agents, the log information acquired from the target log agent is added into the target log context object according to the log list attribute.
3. The method of claim 1, wherein creating a target log context object in a local thread according to the preset log configuration comprises:
creating a log context object in a local thread, and initializing a list data structure of a log list in the created log context object according to a log output template contained in the preset log configuration to obtain a target log context object.
4. The method of claim 1, wherein adding log information to the target log context object according to the log list attribute comprises:
and assembling the obtained log information corresponding to the call entry component according to the attribute of the log list by using an adding method of a call list, and adding the character strings corresponding to the log information into the target log context object.
5. The method of claim 1, wherein the preset log configuration includes at least one of:
target calling equipment, target calling application, target calling class, target calling method, statement execution information, parameter entering, parameter exiting, time consuming and printing format.
6. The method of claim 1, wherein the obtaining the corresponding preset log configuration comprises:
corresponding preset log configuration is obtained from a preset configuration center, wherein the preset log agent and/or the preset log interface contain preset configuration information, and corresponding preset log configuration is dynamically configured according to the preset configuration information in the preset configuration center.
7. The method of any of claims 1-6, wherein the pre-set logging agent comprises a Dubbo logging agent, a message queue MQ logging agent, a Mybatis logging agent, and a Redis logging agent, and the call entry component comprises a Dubbo logging agent or an MQ logging agent.
8. A log printing apparatus, comprising:
the system comprises a log configuration acquisition module, a target application program acquisition module and a log configuration processing module, wherein the log configuration acquisition module is used for acquiring corresponding preset log configuration when a call request for the target application program is detected through a call entry component, and the call entry component comprises one of a plurality of preset log agents;
the object creating module is used for creating a target log context object in a local thread according to the preset log configuration, wherein the target log context object comprises a log list attribute corresponding to the preset log configuration;
the first log information adding module is used for adding the obtained log information corresponding to the calling entry component into the target log context object according to the log list attribute;
the second log information adding module is used for adding the log information acquired through the preset log interface into the target log context object according to the log list attribute when the target application program is detected to call the preset log interface;
and the log printing module is used for printing log information contained in the target log context object by using a preset log output interface through the call entry component when the call process for the target application program is detected to be finished, so as to generate a log file.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-7.
10. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any of claims 1-7 when the computer program is executed.
CN201910671531.6A 2019-07-24 2019-07-24 Log printing method, device, storage medium and equipment Active CN110399107B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910671531.6A CN110399107B (en) 2019-07-24 2019-07-24 Log printing method, device, storage medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910671531.6A CN110399107B (en) 2019-07-24 2019-07-24 Log printing method, device, storage medium and equipment

Publications (2)

Publication Number Publication Date
CN110399107A CN110399107A (en) 2019-11-01
CN110399107B true CN110399107B (en) 2023-08-29

Family

ID=68325025

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910671531.6A Active CN110399107B (en) 2019-07-24 2019-07-24 Log printing method, device, storage medium and equipment

Country Status (1)

Country Link
CN (1) CN110399107B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113268462B (en) * 2020-02-14 2024-05-10 西安诺瓦星云科技股份有限公司 Log management method, device and system based on embedded equipment
CN112148699B (en) * 2020-09-28 2023-09-05 深圳平安智汇企业信息管理有限公司 Log management method, device, equipment and medium
CN114398003A (en) * 2021-12-07 2022-04-26 广西北投信创科技投资集团有限公司 Information processing method and device and message server
CN114661256B (en) * 2022-05-20 2022-09-02 苏州万店掌网络科技有限公司 Data acquisition method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1785892A2 (en) * 2005-11-01 2007-05-16 Research In Motion Limited System and Method for Collecting and Presenting Records in a Journal on an Electronic Device
JP2012079230A (en) * 2010-10-05 2012-04-19 Hitachi Ltd Print management system and print management method
CN106250424A (en) * 2016-07-22 2016-12-21 杭州朗和科技有限公司 The searching method of a kind of daily record context, Apparatus and system
CN108804644A (en) * 2018-06-05 2018-11-13 中国平安人寿保险股份有限公司 Interface log storing method, device, computer equipment and storage medium
CN109376074A (en) * 2018-09-14 2019-02-22 浙江口碑网络技术有限公司 Obtain method and device, the storage medium, electronic device of log

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6179331B2 (en) * 2013-10-09 2017-08-16 富士通株式会社 Log output condition setting program, apparatus, and method
US11354301B2 (en) * 2017-11-13 2022-06-07 LendingClub Bank, National Association Multi-system operation audit log

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1785892A2 (en) * 2005-11-01 2007-05-16 Research In Motion Limited System and Method for Collecting and Presenting Records in a Journal on an Electronic Device
JP2012079230A (en) * 2010-10-05 2012-04-19 Hitachi Ltd Print management system and print management method
CN106250424A (en) * 2016-07-22 2016-12-21 杭州朗和科技有限公司 The searching method of a kind of daily record context, Apparatus and system
CN108804644A (en) * 2018-06-05 2018-11-13 中国平安人寿保险股份有限公司 Interface log storing method, device, computer equipment and storage medium
CN109376074A (en) * 2018-09-14 2019-02-22 浙江口碑网络技术有限公司 Obtain method and device, the storage medium, electronic device of log

Also Published As

Publication number Publication date
CN110399107A (en) 2019-11-01

Similar Documents

Publication Publication Date Title
CN110399107B (en) Log printing method, device, storage medium and equipment
CN111314141B (en) Route updating method and device
US11244233B2 (en) Intelligent adaptor service in unified automation platforms for robotic process automation
WO2020029375A1 (en) Interface testing method and system, and computer device and storage medium
US20240064058A1 (en) Implementation of compliance settings by a mobile device for compliance with a configuration scenario
US8271956B2 (en) System, method and program product for dynamically adjusting trace buffer capacity based on execution history
US10698745B2 (en) Adapter extension for inbound messages from robotic automation platforms to unified automation platform
WO2020024408A1 (en) Test device, test method and storage medium
WO2016184175A1 (en) Database processing method and apparatus
CN112965700B (en) Routing-based micro-service processing method and device, computer equipment and medium
CN112738060B (en) Method and device for processing micro-service data, micro-service processing platform and medium
CN108255708B (en) Method, device, storage medium and equipment for accessing production file in test environment
CN113434158B (en) Custom management method, device, equipment and medium for big data component
CN113726566B (en) Service gateway device
CN106331065A (en) Proxy application for host system with service container and system
US20210133086A1 (en) Intelligent test case management for system integration testing
US10873628B2 (en) System and method for non-intrusive context correlation across cloud services
CN107122203B (en) Configuration file setting method and device
CN113315750B (en) Kafka message issuing method, device and storage medium
CN113111036A (en) Small file processing method, device, medium and electronic equipment based on HDFS
CN112882793B (en) Method and system for sharing container resources
US11595493B2 (en) System and method for namespace masking in an integration flow
CN111399999B (en) Computer resource processing method, device, readable storage medium and computer equipment
CN112187509A (en) Multi-architecture cloud platform execution log management method, system, terminal and storage medium
CN112363707B (en) Control layer general scheduling method based on JAVA reflection technology

Legal Events

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