Log printing method, device, electronic device and readable storage medium

By using message middleware and log proxy modules in log printing, the problems of low efficiency and difficulty in adjusting logs in the prior art are solved, and efficient and accurate log printing and storage space saving effects are achieved.

CN113934387BActive Publication Date: 2025-05-02CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111228981.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-21
Publication Date
2025-05-02
Estimated Expiration
2041-10-21

AI Technical Summary

Technical Problem

The lack of unified standards for log printing methods in the prior art, resulting in low printing efficiency, excessive duplicate logs, misleading investigation and analysis, and difficulty in adjusting logs, affecting efficiency.

Method used

By obtaining the registration information and log configuration information of each application, forming a registration message queue based on the message middleware, performing log printing configuration, using the log proxy module for security detection and dynamic enhancement, and generating standard log printing instructions.

Benefits of technology

Improves the efficiency and accuracy of log printing, reduces the generation of useless logs, saves storage space, and makes adjustments before log printing, avoiding the need for manual adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113934387B_ABST
    Figure CN113934387B_ABST
Patent Text Reader

Abstract

The present invention relates to artificial intelligence technology, and discloses a log printing method, including: obtaining registration information of each application, arranging the registration information according to a message middleware, obtaining a registration message queue, obtaining log configuration information of each application, performing log printing configuration on each application based on the registration message queue and the log configuration information, obtaining log printing configuration instructions of each application, performing security detection on the log printing configuration instructions, dynamically enhancing the log printing configuration instructions of the detected security using a preset log proxy module, obtaining a standard log printing instruction, executing the standard log printing instruction using a log proxy module, and obtaining a printed log. In addition, the present invention also relates to blockchain technology, and the registration information can be obtained from a node of a blockchain. The present invention also proposes a log printing method device, an electronic device, and a computer-readable storage medium. The present invention can solve the problem of low log printing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a log printing method, device, electronic device and computer-readable storage medium. Background Art

[0002] Logs in network devices, systems, and applications record descriptions of related operations such as date, time, user, and action. Therefore, during the development and operation and maintenance process, it is necessary to print different types of logs such as application logs, security logs, and system logs to help developers troubleshoot problems. However, since there is no unified standard for log printing methods, many developers will print logs of different applications at will, which has low printing efficiency and will generate a large number of duplicate logs, resulting in a waste of log storage space. When the system is abnormal, a large number of useless error logs may mislead the analysis direction of the troubleshooter. In addition, since there is no unified configuration requirement for log output, and the traditional method of using logs is to use them after printing, it will make log adjustment difficult. After each log printing, the staff needs to manually adjust the parameters, which seriously affects the efficiency of log printing. Summary of the invention

[0003] The present invention provides a log printing method, device, equipment and storage medium, the main purpose of which is to solve the problem of low log printing efficiency.

[0004] To achieve the above object, the present invention provides a log printing method, comprising:

[0005] Obtaining registration information of each application, arranging the registration information according to a preset message middleware, and obtaining a registration message queue;

[0006] Obtaining log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information, to obtain log printing configuration instructions for each application;

[0007] Performing security detection on the log printing configuration instruction, and dynamically enhancing the detected security log printing configuration instruction using a preset log proxy module to obtain a standard log printing instruction;

[0008] The log proxy module is used to execute the standard log printing instruction to obtain a print log.

[0009] Optionally, the acquiring log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information to obtain the log printing configuration instruction of each application includes:

[0010] Obtain log configuration information for each application, wherein the log configuration information includes log configuration name, log type information, log format information, and log expression information;

[0011] Matching the unique application name in the registration message queue and the log configuration name according to a preset corresponding relationship;

[0012] When the match is successful, the configuration information is extracted from the log type information, log format information and log expression information corresponding to the log configuration name, and the log printing configuration instruction is constructed according to the extracted configuration information.

[0013] Optionally, extracting configuration information from log type information, log format information, and log expression information corresponding to the log configuration name, and constructing the log printing configuration instruction according to the extracted configuration information includes:

[0014] Extracting DSL package name information and DSL class name information from the log type information corresponding to the log configuration name;

[0015] Extracting DSL method information from the log format information corresponding to the log configuration name;

[0016] Extracting DSL expression information from the log expression information corresponding to the log configuration name;

[0017] The DSL package name information, the DSL class name information, the DSL format information and the DSL expression information are filled into a preset configuration instruction template to obtain the log printing configuration instruction.

[0018] Optionally, the performing security detection on the log printing configuration instruction includes:

[0019] Determine whether the format and syntax of the log printing configuration instructions are all correct;

[0020] If the format and syntax of the log printing configuration instruction are not all correct, it is determined that the log printing configuration instruction is incorrectly configured and detected as unsafe;

[0021] If the format and syntax of the log printing configuration instruction are all correct, it is determined that the log printing configuration instruction is correctly configured and detected as safe.

[0022] Optionally, the method of dynamically enhancing the log printing configuration instruction for detecting security by using a preset log proxy module to obtain a standard log printing instruction includes:

[0023] Traversing the historical log printing configuration instructions, and using the log proxy module to intercept the historical log printing configuration instructions appearing in the log configuration instructions;

[0024] The log configuration instructions that are not intercepted are subjected to loading class enhancement processing to obtain the standard log printing instructions.

[0025] Optionally, the using the log proxy module to execute the standard log printing instruction to obtain the print log includes:

[0026] Based on the log proxy module, determine whether the configuration information in the standard log printing instruction meets the preset configuration requirements;

[0027] If the configuration information in the standard log printing instruction does not meet the preset configuration requirements, the log printing will not be performed;

[0028] If the configuration information in the standard log printing instruction meets the preset configuration requirements, log printing is performed based on the configuration information to obtain the printed log.

[0029] Optionally, the arranging the registration information according to a preset message middleware to obtain a registration message queue includes:

[0030] Distributing the registration messages of the various applications to different clusters by using the message middleware, and pushing the registration messages of the various applications to different classification nodes in the cluster to obtain classification node information;

[0031] The classification node information of each classification node is arranged in order to obtain the registration message queue.

[0032] In order to solve the above problem, the present invention further provides a log printing device, the device comprising:

[0033] A registration information arrangement module is used to obtain the registration information of each application, arrange the registration information according to the preset message middleware, and obtain a registration message queue;

[0034] A log printing configuration module, used to obtain log configuration information of each application, and perform log printing configuration on each application based on the registered message queue and the log configuration information to obtain log printing configuration instructions for each application;

[0035] A log printing instruction construction module is used to perform security detection on the log printing configuration instruction, and dynamically enhance the detected security log printing configuration instruction using a preset log proxy module to obtain a standard log printing instruction;

[0036] The log printing module is used to use the log proxy module to execute the standard log printing instruction to obtain a print log.

[0037] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:

[0038] a memory storing at least one computer program; and

[0039] The processor executes the computer program stored in the memory to implement the log printing method described above.

[0040] In order to solve the above problem, the present invention further provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned log printing method.

[0041] The present invention performs log printing configuration for each application through the registration message queue and log configuration information formed by the message middleware, which can improve the accuracy of each application configuration. In addition, the log printing configuration instructions for detecting safety are dynamically enhanced through the log proxy module, which can unify the log configuration requirements of different applications, improve the log printing efficiency, and will not cause the printing of a large number of useless logs through the printing instructions of the unified configuration requirements, thereby saving storage space. At the same time, based on the log proxy module, log adjustment can be performed before log printing, and there is no need to manually adjust the log parameters after the log printing is completed, which improves the efficiency of log printing. Therefore, the log printing method, device, electronic device and computer-readable storage medium proposed by the present invention can solve the problem of low log printing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 A flow chart of a log printing method provided by an embodiment of the present invention;

[0043] Figure 2 A functional module diagram of a log printing device provided by an embodiment of the present invention;

[0044] Figure 3 A schematic diagram of the structure of an electronic device for implementing the log printing method provided by an embodiment of the present invention.

[0045] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0046] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0047] The embodiment of the present application provides a log printing method. The execution subject of the log printing method includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the log printing method can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.

[0048] Reference Figure 1 FIG. 1 is a flow chart of a log printing method provided by an embodiment of the present invention.

[0049] In this embodiment, the log printing method includes:

[0050] S1. Acquire registration information of each application, and arrange the registration information according to a preset message middleware to obtain a registration message queue.

[0051] In an embodiment of the present invention, the registration information includes information such as the unique name of the application, the application type, etc. The preset message middleware may be a Kafka processing platform, which is a high-throughput distributed publish-subscribe message system including a category (Topic), a classification node (broker), a cluster (kafka cluster), and other structures.

[0052] Specifically, the registration information is arranged according to the preset message middleware to obtain a registration message queue, including:

[0053] Distributing the registration messages of the various applications to different clusters by using the message middleware, and pushing the registration messages of the various applications to different classification nodes in the cluster to obtain classification node information;

[0054] The classification node information of each classification node is arranged in order to obtain the registration message queue.

[0055] In an embodiment of the present invention, the registration information is distributed to different clusters (kafkacluster) in the Kafka processing platform, and is classified at the classification node (broker) in the cluster (kafka cluster) to obtain the classification node information, and the classification node information is stored in the form of categories (Topic) and arranged in order to obtain the registration message queue. When the registration message comes from multiple servers, the coupling between the servers can be reduced by using the Kafka processing platform. At the same time, the Kafka processing platform uses the registration message queue as a buffer, arranges the registration information into the registration message queue, processes it within a period of time, and provides peak business processing capabilities.

[0056] S2. Obtain log configuration information of each application, and perform log printing configuration for each application based on the registration message queue and the log configuration information to obtain log printing configuration instructions for each application.

[0057] In the embodiment of the present invention, the application is configured for log printing through DSL (Domain Specific Language) to obtain log printing configuration instructions. The DSL is different from general programming languages ​​such as Java, Python and C language, and has limited expression ability, and can only solve specific tasks in specific fields.

[0058] Specifically, the acquiring log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information to obtain the log printing configuration instruction of each application includes:

[0059] Obtain log configuration information for each application, wherein the log configuration information includes log configuration name, log type information, log format information, and log expression information;

[0060] Matching the unique application name in the registration message queue and the log configuration name according to a preset corresponding relationship;

[0061] When the match is successful, the configuration information is extracted from the log type information, log format information and log expression information corresponding to the log configuration name, and the log printing configuration instruction is constructed according to the extracted configuration information.

[0062] In an embodiment of the present invention, the log type information may be a program log, a security log, a system log, etc.; the log format information may be a table format, a document format, etc.; the log expression information includes printing expressions under different conditions, for example, printing is performed only when a preset condition is met. The preset corresponding relationship is used to represent the matching mapping relationship between the application unique name and the log configuration name, for example, the application unique name is "business application 1", and the corresponding log configuration name is "log configuration 1".

[0063] In detail, extracting configuration information from the log type information, log format information and log expression information corresponding to the log configuration name, and constructing the log printing configuration instruction according to the extracted configuration information, includes:

[0064] Extracting DSL package name information and DSL class name information from the log type information corresponding to the log configuration name;

[0065] Extracting DSL method information from the log format information corresponding to the log configuration name;

[0066] Extracting DSL expression information from the log expression information corresponding to the log configuration name;

[0067] The DSL package name information, the DSL class name information, the DSL format information and the DSL expression information are filled into a preset configuration instruction template to obtain the log printing configuration instruction.

[0068] In an embodiment of the present invention, the preset configuration instruction template includes: package name (namespace). class name (classname). space method name. space condition expression (printed only when the condition is met) or the content of the space method input and output parameters (or exception information). For example, the DSL package name information is com, the DSL class name information is paic, the DSL method information is btp, and the DSL expression information is ClassNameMethodName Condition, then the log printing configuration instruction for processing log input and output parameters is com.paic.btp.ClassNameMethodName Condition.

[0069] In an optional embodiment of the present invention, the configuration speed is greatly improved by matching the log configuration information with the registered message queue, and the log printing instructions are configured by the self-created DSL, so that the unified configuration of log printing can be achieved.

[0070] S3: Perform security detection on the log printing configuration instruction, and dynamically enhance the detected security log printing configuration instruction using a preset log proxy module to obtain a standard log printing instruction.

[0071] In the embodiment of the present invention, since the log printing configuration instruction may have format, syntax and other errors, thus causing, it is necessary to detect repeated configuration instructions to ensure the security of the configuration.

[0072] Specifically, the security detection of the log printing configuration instruction includes:

[0073] Determine whether the format and syntax of the log printing configuration instructions are all correct;

[0074] If the format and syntax of the log printing configuration instruction are not all correct, it is determined that the log printing configuration instruction is incorrectly configured and detected as unsafe;

[0075] If the format and syntax of the log printing configuration instruction are all correct, it is determined that the log printing configuration instruction is correctly configured and detected as safe.

[0076] In detail, the preset log proxy module is used to dynamically enhance the log printing configuration instructions for detecting security to obtain standard log printing instructions, including:

[0077] Traversing the historical log printing configuration instructions, and using the log proxy module to intercept the historical log printing configuration instructions appearing in the log configuration instructions;

[0078] The log configuration instructions that are not intercepted are subjected to loading class enhancement processing to obtain the standard log printing instructions.

[0079] In the embodiment of the present invention, the log proxy module can be a log agent, which is used to dynamically enhance different log loading classes, such as adding Log4j log objects, dynamically intercepting all configured methods, and executing the log printing message in the enhanced standard log printing instruction. By using the log agent, it can be applied to all java web applications, without code intrusion to the application, without any development of the application, reducing development costs and improving the efficiency of log printing.

[0080] S4. Utilize the log proxy module to execute the standard log printing instruction to obtain a print log.

[0081] In the embodiment of the present invention, the step of using the log proxy module to execute the standard log printing instruction to obtain the print log includes:

[0082] Based on the log proxy module, determine whether the configuration information in the standard log printing instruction meets the preset configuration requirements;

[0083] If the configuration information in the standard log printing instruction does not meet the preset configuration requirements, the log printing will not be performed;

[0084] If the configuration information in the standard log printing instruction meets the preset configuration requirements, log printing is performed based on the configuration information to obtain the printed log.

[0085] In the embodiment of the present invention, the log agent module (Agent) receives the standard log printing instruction (i.e., DSL statement) of the application, wherein the DSL statement contains the parameters, classes, methods, log format, output target, context information (such as: obtaining information from Threadlocal, obtaining bean information from spring context, etc.), security encryption information, etc. of the log printing, and then the Agent will transform all the class information to determine whether the preset configuration requirements are met (such as the class method in the DSL must be hit) for configuration. If not, the log printing will not be performed, and other DSL statements will continue to be executed. If it is satisfied, the log format, parameter requirements, encryption requirements, and input target stream requirements in the DSL statement will be printed. At the same time, the application loads the Agent for printing logs through javaagent, so that the application does not need the developer to print the log, and only needs to modify the DSL statement with unified configuration requirements, which greatly improves the efficiency of log printing.

[0086] The present invention performs log printing configuration for each application through the registration message queue and log configuration information formed by the message middleware, which can improve the accuracy of each application configuration. In addition, the log printing configuration instructions for detecting safety are dynamically enhanced through the log proxy module, which can unify the log configuration requirements of different applications, improve the log printing efficiency, and will not cause the printing of a large number of useless logs through the printing instructions of the unified configuration requirements, thereby saving storage space. At the same time, based on the log proxy module, log adjustment can be performed before log printing, and there is no need to manually adjust log parameters after log printing is completed, which improves the efficiency of log printing. Therefore, the log printing method proposed by the present invention can solve the problem of low log printing efficiency.

[0087] like Figure 2 FIG. 1 is a functional module diagram of a log printing device provided by an embodiment of the present invention.

[0088] The log printing device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the log printing device 100 can include a registration information arrangement module 101, a log printing configuration module 102, a log printing instruction construction module 103 and a log printing module 104. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.

[0089] In this embodiment, the functions of each module / unit are as follows:

[0090] The registration information arrangement module 101 is used to obtain the registration information of each application, arrange the registration information according to the preset message middleware, and obtain a registration message queue;

[0091] The log printing configuration module 102 is used to obtain the log configuration information of each application, and perform log printing configuration on each application based on the registration message queue and the log configuration information to obtain the log printing configuration instruction of each application;

[0092] The log printing instruction construction module 103 is used to perform security detection on the log printing configuration instruction, and dynamically enhance the detected security log printing configuration instruction using a preset log proxy module to obtain a standard log printing instruction;

[0093] The log printing module 104 is used to use the log proxy module to execute the standard log printing instruction to obtain a print log.

[0094] In detail, the specific implementation of each module of the log printing device 100 is as follows:

[0095] Step 1: Obtain registration information of each application, and arrange the registration information according to a preset message middleware to obtain a registration message queue.

[0096] In an embodiment of the present invention, the registration information includes information such as the unique name of the application, the application type, etc. The preset message middleware may be a Kafka processing platform, which is a high-throughput distributed publish-subscribe message system including a category (Topic), a classification node (broker), a cluster (kafka cluster), and other structures.

[0097] Specifically, the registration information is arranged according to the preset message middleware to obtain a registration message queue, including:

[0098] Distributing the registration messages of the various applications to different clusters by using the message middleware, and pushing the registration messages of the various applications to different classification nodes in the cluster to obtain classification node information;

[0099] The classification node information of each classification node is arranged in order to obtain the registration message queue.

[0100] In an embodiment of the present invention, the registration information is distributed to different clusters (kafkacluster) in the Kafka processing platform, and is classified at the classification node (broker) in the cluster (kafka cluster) to obtain the classification node information, and the classification node information is stored in the form of categories (Topic) and arranged in order to obtain the registration message queue. When the registration message comes from multiple servers, the coupling between the servers can be reduced by using the Kafka processing platform. At the same time, the Kafka processing platform uses the registration message queue as a buffer, arranges the registration information into the registration message queue, processes it within a period of time, and provides peak business processing capabilities.

[0101] Step 2: Obtain log configuration information of each application, and perform log printing configuration for each application based on the registered message queue and the log configuration information to obtain log printing configuration instructions for each application.

[0102] In the embodiment of the present invention, the application is configured for log printing through DSL (Domain Specific Language) to obtain log printing configuration instructions. The DSL is different from general programming languages ​​such as Java, Python and C language, and has limited expression ability, and can only solve specific tasks in specific fields.

[0103] Specifically, the acquiring log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information to obtain the log printing configuration instruction of each application includes:

[0104] Obtain log configuration information for each application, wherein the log configuration information includes log configuration name, log type information, log format information, and log expression information;

[0105] Matching the unique application name in the registration message queue and the log configuration name according to a preset corresponding relationship;

[0106] When the match is successful, the configuration information is extracted from the log type information, log format information and log expression information corresponding to the log configuration name, and the log printing configuration instruction is constructed according to the extracted configuration information.

[0107] In an embodiment of the present invention, the log type information may be a program log, a security log, a system log, etc.; the log format information may be a table format, a document format, etc.; the log expression information includes printing expressions under different conditions, for example, printing is performed only when a preset condition is met. The preset corresponding relationship is used to represent the matching mapping relationship between the application unique name and the log configuration name, for example, the application unique name is "business application 1", and the corresponding log configuration name is "log configuration 1".

[0108] In detail, extracting configuration information from the log type information, log format information and log expression information corresponding to the log configuration name, and constructing the log printing configuration instruction according to the extracted configuration information, includes:

[0109] Extracting DSL package name information and DSL class name information from the log type information corresponding to the log configuration name;

[0110] Extracting DSL method information from the log format information corresponding to the log configuration name;

[0111] Extracting DSL expression information from the log expression information corresponding to the log configuration name;

[0112] The DSL package name information, the DSL class name information, the DSL format information and the DSL expression information are filled into a preset configuration instruction template to obtain the log printing configuration instruction.

[0113] In an embodiment of the present invention, the preset configuration instruction template includes: package name (namespace). class name (classname). space method name. space condition expression (printed only when the condition is met) or the content of the space method input and output parameters (or exception information). For example, the DSL package name information is com, the DSL class name information is paic, the DSL method information is btp, and the DSL expression information is ClassNameMethodName Condition, then the log printing configuration instruction for processing log input and output parameters is com.paic.btp.ClassNameMethodName Condition.

[0114] In an optional embodiment of the present invention, the configuration speed is greatly improved by matching the log configuration information with the registered message queue, and the log printing instructions are configured by the self-created DSL, so that the unified configuration of log printing can be achieved.

[0115] Step 3: Perform security detection on the log printing configuration instructions, and dynamically enhance the detected security log printing configuration instructions using a preset log proxy module to obtain standard log printing instructions.

[0116] In the embodiment of the present invention, since the log printing configuration instruction may have format, syntax and other errors, thus causing, it is necessary to detect repeated configuration instructions to ensure the security of the configuration.

[0117] Specifically, the security detection of the log printing configuration instruction includes:

[0118] Determine whether the format and syntax of the log printing configuration instructions are all correct;

[0119] If the format and syntax of the log printing configuration instruction are not all correct, it is determined that the log printing configuration instruction is incorrectly configured and detected as unsafe;

[0120] If the format and syntax of the log printing configuration instruction are all correct, it is determined that the log printing configuration instruction is correctly configured and detected as safe.

[0121] In detail, the preset log proxy module is used to dynamically enhance the log printing configuration instructions for detecting security to obtain standard log printing instructions, including:

[0122] Traversing the historical log printing configuration instructions, and using the log proxy module to intercept the historical log printing configuration instructions appearing in the log configuration instructions;

[0123] The log configuration instructions that are not intercepted are subjected to loading class enhancement processing to obtain the standard log printing instructions.

[0124] In the embodiment of the present invention, the log proxy module can be a log agent, which is used to dynamically enhance different log loading classes, such as adding Log4j log objects, dynamically intercepting all configured methods, and executing the log printing message in the enhanced standard log printing instruction. By using the log agent, it can be applied to all java web applications, without code intrusion to the application, without any development of the application, reducing development costs and improving the efficiency of log printing.

[0125] Step 4: Utilize the log proxy module to execute the standard log printing instruction to obtain a print log.

[0126] In the embodiment of the present invention, the step of using the log proxy module to execute the standard log printing instruction to obtain the print log includes:

[0127] Based on the log proxy module, determine whether the configuration information in the standard log printing instruction meets the preset configuration requirements;

[0128] If the configuration information in the standard log printing instruction does not meet the preset configuration requirements, the log printing will not be performed;

[0129] If the configuration information in the standard log printing instruction meets the preset configuration requirements, log printing is performed based on the configuration information to obtain the printed log.

[0130] In the embodiment of the present invention, the log agent module (Agent) receives the standard log printing instruction (i.e., DSL statement) of the application, wherein the DSL statement contains the parameters, classes, methods, log format, output target, context information (such as: obtaining information from Threadlocal, obtaining bean information from spring context, etc.), security encryption information, etc. of the log printing, and then the Agent will transform all the class information to determine whether the preset configuration requirements are met (such as the class method in the DSL must be hit) for configuration. If not, the log printing will not be performed, and other DSL statements will continue to be executed. If it is satisfied, the log format, parameter requirements, encryption requirements, and input target stream requirements in the DSL statement will be printed. At the same time, the application loads the Agent for printing logs through javaagent, so that the application does not need the developer to print the log, and only needs to modify the DSL statement with unified configuration requirements, which greatly improves the efficiency of log printing.

[0131] The present invention performs log printing configuration for each application through the registration message queue and log configuration information formed by the message middleware, which can improve the accuracy of each application configuration. In addition, the log printing configuration instructions for detecting safety are dynamically enhanced through the log proxy module, which can unify the log configuration requirements of different applications, improve the log printing efficiency, and will not cause the printing of a large number of useless logs through the printing instructions of the unified configuration requirements, thereby saving storage space. At the same time, based on the log proxy module, log adjustment can be performed before log printing, and there is no need to manually adjust log parameters after log printing is completed, which improves the efficiency of log printing. Therefore, the log printing device proposed by the present invention can solve the problem of low log printing efficiency.

[0132] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing a log printing method provided by an embodiment of the present invention.

[0133] The electronic device may include a processor 10 , a memory 11 , a communication interface 12 , and a bus 13 , and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a log printing program.

[0134] Wherein, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The memory 11 may be an internal storage unit of an electronic device in some embodiments, such as a mobile hard disk of the electronic device. The memory 11 may also be an external storage device of an electronic device in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device, such as the code of the log printing program, etc., but also be used to temporarily store data that has been output or is to be output.

[0135] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing programs or modules (such as log printing programs, etc.) stored in the memory 11, and calling data stored in the memory 11.

[0136] The communication interface 12 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.

[0137] The bus 13 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus 13 may be divided into an address bus, a data bus, a control bus, etc. The bus 13 is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.

[0138] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.

[0139] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

[0140] Furthermore, the electronic device may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices.

[0141] Optionally, the electronic device may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.

[0142] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.

[0143] The log printing program stored in the memory 11 in the electronic device is a combination of multiple instructions. When running in the processor 10, it can achieve:

[0144] Obtaining registration information of each application, arranging the registration information according to a preset message middleware, and obtaining a registration message queue;

[0145] Obtaining log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information, to obtain log printing configuration instructions for each application;

[0146] Performing security detection on the log printing configuration instruction, and dynamically enhancing the detected security log printing configuration instruction using a preset log proxy module to obtain a standard log printing instruction;

[0147] The log proxy module is used to execute the standard log printing instruction to obtain a print log.

[0148] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.

[0149] Furthermore, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).

[0150] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:

[0151] Obtaining registration information of each application, arranging the registration information according to a preset message middleware, and obtaining a registration message queue;

[0152] Obtaining log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information, to obtain log printing configuration instructions for each application;

[0153] Performing security detection on the log printing configuration instruction, and dynamically enhancing the detected security log printing configuration instruction using a preset log proxy module to obtain a standard log printing instruction;

[0154] The log proxy module is used to execute the standard log printing instruction to obtain a print log.

[0155] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

[0156] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0157] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0158] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.

[0159] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.

[0160] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0161] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0162] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0163] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.

[0164] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A log printing method, characterized in that: The method comprises: Obtaining registration information of each application, arranging the registration information according to a preset message middleware, and obtaining a registration message queue; Obtaining log configuration information of each application, and performing log printing configuration for each application based on the registered message queue and the log configuration information, and obtaining log printing configuration instructions for each application, including: obtaining log configuration information of each application, the log configuration information including log configuration name, log type information, log format information, and log expression information, matching the application unique name in the registered message queue and the log configuration name according to a preset corresponding relationship, and when the match is successful, extracting configuration information from the log type information, log format information, and log expression information corresponding to the log configuration name, and constructing the log printing configuration instruction according to the extracted configuration information; Performing security detection on the log printing configuration instructions, screening out unintercepted log configuration instructions from the log configuration instructions after security detection according to historical log printing configuration instructions, performing loading class enhancement processing on the unintercepted log configuration instructions, and obtaining standard log printing instructions; The log proxy module is used to execute the standard log printing instruction to obtain a print log.

2. The log printing method as claimed in claim 1, characterized in that: The extracting configuration information from the log type information, log format information and log expression information corresponding to the log configuration name, and constructing the log printing configuration instruction according to the extracted configuration information, includes: Extracting DSL package name information and DSL class name information from the log type information corresponding to the log configuration name; Extracting DSL method information from the log format information corresponding to the log configuration name; Extracting DSL expression information from the log expression information corresponding to the log configuration name; The DSL package name information, the DSL class name information, the DSL method information and the DSL expression information are filled into a preset configuration instruction template to obtain the log printing configuration instruction.

3. The log printing method according to claim 2, characterized in that: The performing security detection on the log printing configuration instruction includes: Determine whether the format and syntax of the log printing configuration instructions are all correct; If the format and syntax of the log printing configuration instruction are not all correct, it is determined that the log printing configuration instruction is incorrectly configured and detected as unsafe; If the format and syntax of the log printing configuration instruction are all correct, it is determined that the log printing configuration instruction is correctly configured and detected as safe.

4. The log printing method according to claim 1, characterized in that: The printing configuration instructions according to the historical logs and screening the unintercepted log configuration instructions from the log configuration instructions after the security check include: The historical log printing configuration instructions are traversed, and the historical log printing configuration instructions appearing in the log configuration instructions are intercepted by using the log proxy module to obtain the log configuration instructions that are not intercepted.

5. The log printing method according to claim 4, characterized in that: The step of using the log proxy module to execute the standard log printing instruction to obtain a print log includes: Based on the log proxy module, determine whether the configuration information in the standard log printing instruction meets the preset configuration requirements; If the configuration information in the standard log printing instruction does not meet the preset configuration requirements, the log printing will not be performed; If the configuration information in the standard log printing instruction meets the preset configuration requirements, log printing is performed based on the configuration information to obtain the printed log.

6. The log printing method according to claim 1, characterized in that: The step of arranging the registration information according to the preset message middleware to obtain a registration message queue includes: Distributing the registration messages of the various applications to different clusters by using the message middleware, and pushing the registration messages of the various applications to different classification nodes in the cluster to obtain classification node information; The classification node information of each classification node is arranged in order to obtain the registration message queue.

7. A log printing device, characterized in that: The device comprises: A registration information arrangement module is used to obtain the registration information of each application, arrange the registration information according to the preset message middleware, and obtain a registration message queue; A log printing configuration module, used to obtain log configuration information of each application, and perform log printing configuration on each application based on the registered message queue and the log configuration information to obtain log printing configuration instructions for each application, including: obtaining log configuration information of each application, the log configuration information including log configuration name, log type information, log format information, and log expression information, matching the application unique name in the registered message queue and the log configuration name according to a preset corresponding relationship, and when the match is successful, extracting configuration information from the log type information, log format information, and log expression information corresponding to the log configuration name, and constructing the log printing configuration instruction according to the extracted configuration information; A log printing instruction construction module is used to perform security detection on the log printing configuration instruction, filter out the log configuration instructions that have not been intercepted from the log configuration instructions after the security detection according to the historical log printing configuration instructions, perform loading class enhancement processing on the log configuration instructions that have not been intercepted, and obtain standard log printing instructions; The log printing module is used to execute the standard log printing instruction using the log proxy module to obtain a print log.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the log printing method according to any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the log printing method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Adjustment method and device for log data

    CN104281515A

  • Log management method and device, computer equipment and storage medium

    CN111400128A

  • Application startup configuration item loading method and device, computer equipment and storage medium

    CN111708586A