CN113934387A - Log printing method and device, electronic equipment and readable storage medium - Google Patents

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

Info

Publication number
CN113934387A
CN113934387A CN202111228981.1A CN202111228981A CN113934387A CN 113934387 A CN113934387 A CN 113934387A CN 202111228981 A CN202111228981 A CN 202111228981A CN 113934387 A CN113934387 A CN 113934387A
Authority
CN
China
Prior art keywords
log
configuration
printing
information
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111228981.1A
Other languages
Chinese (zh)
Inventor
姜卫宏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China 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 Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202111228981.1A priority Critical patent/CN113934387A/en
Publication of CN113934387A publication Critical patent/CN113934387A/en
Pending legal-status Critical Current

Links

Images

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
    • G06F3/1273Print job history, e.g. logging, accounting, tracking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1211Improving printing performance
    • G06F3/1215Improving printing performance achieving increased printing speed, i.e. reducing the time between printing start and printing end
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1202Dedicated interfaces to print systems specifically adapted to achieve a particular effect
    • G06F3/1222Increasing security of the print job
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/12Digital output to print unit, e.g. line printer, chain printer
    • G06F3/1201Dedicated interfaces to print systems
    • G06F3/1223Dedicated interfaces to print systems specifically adapted to use a particular technique
    • G06F3/1237Print job management
    • G06F3/1253Configuration of print job parameters, e.g. using UI at the client

Landscapes

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

Abstract

The invention relates to an artificial intelligence technology, and discloses a log printing method, which comprises the following steps: the method comprises the steps of obtaining registration information of each application, arranging the registration information according to message middleware to obtain a registration message queue, obtaining log configuration information of each application, carrying out log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application, carrying out security detection on the log printing configuration instruction, dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction, and executing the standard log printing instruction by using the log agent module to obtain a printing log. In addition, the invention also relates to a block chain technology, and the registration information can be obtained from the nodes of the block chain. The invention also provides a log printing method and device, electronic equipment and a computer readable storage medium. The invention can solve the problem of low log printing efficiency.

Description

Log printing method and device, electronic equipment and readable storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a log printing method and device, electronic equipment and a computer readable storage medium.
Background
In the network device, system and application program, the log records the description of the relevant operations such as date, time, user and action, so that different kinds of logs such as application program log, security log and system log need to be printed in the development and operation and maintenance process to help the developer to troubleshoot problems. However, at present, because the log printing method does not have a unified standard, many developers can print logs of different application programs at will, the printing efficiency is low, a large number of repeated logs can be generated, the waste of log storage space can be caused, and when a system is abnormal, a large number of useless error logs can mislead the analysis direction of inspectors. In addition, because the output of the log does not have a uniform configuration requirement, and the traditional log using method is used after printing, the log is difficult to adjust, and the parameters are required to be manually adjusted by workers after the log is printed every time, so that the log printing efficiency is seriously influenced.
Disclosure of Invention
The invention provides a log printing method, a log printing device, log printing equipment and a log printing storage medium, and mainly aims to solve the problem of low log printing efficiency.
In order to achieve the above object, the present invention provides a log printing method, including:
acquiring registration information of each application, and arranging the registration information according to a preset message middleware to obtain a registration message queue;
acquiring log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application;
carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction;
and executing the standard log printing instruction by using the log agent module to obtain a printing log.
Optionally, the obtaining log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application includes:
acquiring log configuration information of each application, wherein the log configuration information comprises a log configuration name, log type information, log format information and log expression information;
matching the application unique name and the log configuration name in the registration message queue according to a preset corresponding relation;
and when the matching is successful, 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.
Optionally, the 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:
extracting DSL package name information and DSL class name information from 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;
and filling the DSL package name information, the DSL class name information, the DSL format information and the DSL expression information into a preset configuration instruction template to obtain the log printing configuration instruction.
Optionally, the performing security detection on the log printing configuration instruction includes:
judging whether the format and grammar of the log printing configuration instruction are all correct or not;
if the format and syntax of the log printing configuration instruction are not completely correct, determining that the log printing configuration instruction is configured wrongly, and detecting that the log printing configuration instruction is unsafe;
and if the format and the grammar of the log printing configuration instruction are all correct, determining that the log printing configuration instruction is correctly configured and detecting the log printing configuration instruction as safe.
Optionally, the dynamically enhancing the log printing configuration instruction for detecting security by using the preset log agent module to obtain a standard log printing instruction includes:
traversing a historical log printing configuration instruction, and intercepting the historical log printing configuration instruction appearing in the log configuration instruction by using the log agent module;
and carrying out loading type enhancement processing on the log configuration instruction which is not intercepted to obtain the standard log printing instruction.
Optionally, the executing, by the log agent module, the standard log printing instruction to obtain a print log includes:
judging whether the configuration information in the standard log printing instruction meets the preset configuration requirement or not based on the log agent module;
if the configuration information in the standard log printing instruction does not meet the preset configuration requirement, log printing is not carried out;
and if the configuration information in the standard log printing instruction meets the preset configuration requirement, performing log printing based on the configuration information to obtain the printing log.
Optionally, the arranging the registration information according to a preset message middleware to obtain a registration message queue includes:
distributing the registration message of each application to different clusters by using the message middleware, and pushing the registration message of each application to different classification nodes in the clusters to obtain classification node information;
and arranging the classification node information of each classification node according to the sequence to obtain the registration message queue.
In order to solve the above problem, the present invention also provides a log printing apparatus, comprising:
the registration information arrangement module is used for acquiring the registration information of each application and arranging the registration information according to a preset message middleware to obtain a registration message queue;
the log printing configuration module is used for acquiring log configuration information of each application and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application;
the log printing instruction construction module is used for carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction;
and the log printing module is used for executing the standard log printing instruction by using the log agent module to obtain a printing log.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one computer program; and
and the processor executes the computer program stored in the memory to realize the log printing method.
In order to solve the above problem, the present invention also provides a computer-readable storage medium having at least one computer program stored therein, the at least one computer program being executed by a processor in an electronic device to implement the log printing method described above.
According to the invention, log printing configuration is carried out on each application through the registration message queue formed by the message middleware and the log configuration information, so that the accuracy of each application configuration can be improved. Moreover, the log printing configuration instruction for detecting safety is dynamically enhanced through the log agent module, log configuration requirements of different applications can be unified, log printing efficiency is improved, a large amount of useless logs can not be printed through the printing instruction with unified configuration requirements, and therefore storage space is saved. Meanwhile, based on the log agent module, log adjustment can be performed before log printing, log parameters do not need to be manually adjusted after log printing is completed, and log printing efficiency is improved. Therefore, the log printing method, the log printing device, the electronic equipment and the computer readable storage medium provided by the invention can solve the problem of low log printing efficiency.
Drawings
Fig. 1 is a schematic flowchart of a log printing method according to an embodiment of the present invention;
FIG. 2 is a functional block diagram of a journal printing apparatus according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an electronic device implementing the log printing method according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides a log printing method. The execution subject of the log printing method includes, but is not limited to, at least one of electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the log printing method may be performed by software or hardware installed in a terminal device or a server device, and the software may 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, and the like. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Fig. 1 is a schematic flow chart of a log printing method according to an embodiment of the present invention.
In this embodiment, the log printing method includes:
and S1, acquiring the registration information of each application, and arranging the registration information according to the preset message middleware to obtain a registration message queue.
In the embodiment of the invention, the registration information comprises information such as the unique name of the application, the type of the application and the like. The preset message middleware may be a Kafka processing platform, and the Kafka processing platform is a high-throughput distributed publish-subscribe message system and includes structures such as a class (Topic), a classification node (spoke), and a cluster (Kafka cluster).
Specifically, the arranging the registration information according to a preset message middleware to obtain a registration message queue includes:
distributing the registration message of each application to different clusters by using the message middleware, and pushing the registration message of each application to different classification nodes in the clusters to obtain classification node information;
and arranging the classification node information of each classification node according to the sequence to obtain the registration message queue.
In the embodiment of the invention, the registration information is distributed to different clusters (Kafka cluster) on a Kafka processing platform, and is classified at classification nodes (brokers) in the clusters (Kafka cluster) to obtain the classification node information, and the classification node information is stored in a category (Topic) form and is arranged according to the sequence to obtain the registration message queue. When the registration message comes from a plurality of servers, the Kafka processing platform can reduce the coupling among the servers. Meanwhile, the Kafka processing platform uses a registration message queue as a buffer, arranges the registration information into the registration message queue, and processes the registration message queue within a period of time to provide peak-period service processing capacity.
S2, obtaining log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application.
In the embodiment of the present invention, log printing configuration is performed on an application through a DSL (Domain Specific Language) to obtain a log printing configuration instruction, where the DSL is different from general programming languages such as Java, Python, and C languages, and has a limited expression capability, and only solves a Specific task in a Specific field.
Specifically, the obtaining log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application includes:
acquiring log configuration information of each application, wherein the log configuration information comprises a log configuration name, log type information, log format information and log expression information;
matching the application unique name and the log configuration name in the registration message queue according to a preset corresponding relation;
and when the matching is successful, 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.
In the embodiment of the invention, the log type information can be program logs, safety logs, system logs and the like; the log format information can be a table format, a document format and the like; the log expression information includes print expressions under different conditions, for example, printing is performed when a preset condition is satisfied. The preset corresponding relationship is used to represent a matching mapping relationship between the application unique name and the log configuration name, for example, the application unique name is "service application 1", and the corresponding log configuration name is "log configuration 1".
In detail, the 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:
extracting DSL package name information and DSL class name information from 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;
and filling the DSL package name information, the DSL class name information, the DSL format information and the DSL expression information into a preset configuration instruction template to obtain the log printing configuration instruction.
In an embodiment of the present invention, the preset configuration instruction template includes: the package name (namespace), the class name (classname), the name of the space method, the expression of the space condition (printing only if the condition is met) or the content (or abnormal information) of the space method access parameter. For example, if the DSL packet name information is com, the DSL class name information is pic, the DSL method information is btp, and the DSL expression information is ClassNameMethodName Condition, the log printing configuration instruction for processing the log entry and exit parameters is com.
In an optional embodiment of the invention, the log configuration information is matched by the registration message queue, so that the configuration speed is greatly improved, and the log printing instruction is configured by the self-created DSL, so that the uniform configuration of the log printing can be realized.
S3, carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction.
In the embodiment of the invention, because errors such as format, grammar and the like may occur in the log printing configuration instruction, repeated configuration instructions need to be detected to ensure the security of configuration.
Specifically, the performing security detection on the log printing configuration instruction includes:
judging whether the format and grammar of the log printing configuration instruction are all correct or not;
if the format and syntax of the log printing configuration instruction are not completely correct, determining that the log printing configuration instruction is configured wrongly, and detecting that the log printing configuration instruction is unsafe;
and if the format and the grammar of the log printing configuration instruction are all correct, determining that the log printing configuration instruction is correctly configured and detecting the log printing configuration instruction as safe.
In detail, the dynamically enhancing the log printing configuration instruction for detecting security by using the preset log agent module to obtain the standard log printing instruction includes:
traversing a historical log printing configuration instruction, and intercepting the historical log printing configuration instruction appearing in the log configuration instruction by using the log agent module;
and carrying out loading type enhancement processing on the log configuration instruction which is not intercepted to obtain the standard log printing instruction.
In the embodiment of the present invention, the Log Agent module may be a Log Agent, and the Log Agent is configured to dynamically enhance different Log loading classes, such as adding a Log4j Log object, dynamically intercepting all configured methods, and executing a Log printing message in an enhanced standard Log printing instruction. By using the log Agent mode, the method can be suitable for all java web applications, has no code intrusion to the applications, does not need any development to the applications, reduces the development cost and also improves the efficiency of log printing.
And S4, executing the standard log printing instruction by using the log agent module to obtain a printing log.
In this embodiment of the present invention, the executing the standard log printing instruction by using the log agent module to obtain the print log includes:
judging whether the configuration information in the standard log printing instruction meets the preset configuration requirement or not based on the log agent module;
if the configuration information in the standard log printing instruction does not meet the preset configuration requirement, log printing is not carried out;
and if the configuration information in the standard log printing instruction meets the preset configuration requirement, performing log printing based on the configuration information to obtain the printing log.
In the embodiment of the invention, a log Agent module (Agent) receives a standard log printing instruction (namely, a DSL statement) of the application, wherein the DSL statement comprises parameters, classes, methods, a log format, an output target, context information (for example, information is obtained from thread, and spring context information is obtained), safety encryption information and the like of a printing log, then the Agent can perform transform on all class information, judge whether preset configuration requirements (such as class methods in the DSL must be hit) are met, if not, the log printing is not performed, other DSL statements are continuously executed, and if so, the printing processing is performed according to the log format, the parameter requirements, the encryption requirements and the input target stream requirements in the DSL statement. Meanwhile, the application program loads the Agent for printing the log through the java Agent, so that the application program does not need a developer to print the log, and only the DSL statements required by uniform configuration are required to be modified, and the efficiency of log printing is greatly improved.
According to the invention, log printing configuration is carried out on each application through the registration message queue formed by the message middleware and the log configuration information, so that the accuracy of each application configuration can be improved. Moreover, the log printing configuration instruction for detecting safety is dynamically enhanced through the log agent module, log configuration requirements of different applications can be unified, log printing efficiency is improved, a large amount of useless logs can not be printed through the printing instruction with unified configuration requirements, and therefore storage space is saved. Meanwhile, based on the log agent module, log adjustment can be performed before log printing, log parameters do not need to be manually adjusted after log printing is completed, and log printing efficiency is improved. Therefore, the log printing method provided by the invention can solve the problem of low log printing efficiency.
Fig. 2 is a functional block diagram of a log printing apparatus according to an embodiment of the present invention.
The journal printing apparatus 100 according to the present invention may be installed in an electronic device. According to the implemented functions, the log printing apparatus 100 may include a registration information arrangement module 101, a log print configuration module 102, a log print instruction construction module 103, and a log print module 104. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the registration information arrangement module 101 is configured to acquire registration information of each application, and arrange the registration information according to a preset message middleware to obtain a registration message queue;
the log printing configuration module 102 is configured to obtain 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 a log printing configuration instruction of each application;
the log printing instruction constructing module 103 is configured to perform security detection on the log printing configuration instruction, and dynamically enhance the log printing configuration instruction for security detection by using a preset log agent module to obtain a standard log printing instruction;
the log printing module 104 is configured to execute the standard log printing instruction by using the log agent module to obtain a printing log.
In detail, the log printing apparatus 100 has the following specific embodiments of the modules:
step one, acquiring registration information of each application, and arranging the registration information according to a preset message middleware to obtain a registration message queue.
In the embodiment of the invention, the registration information comprises information such as the unique name of the application, the type of the application and the like. The preset message middleware may be a Kafka processing platform, and the Kafka processing platform is a high-throughput distributed publish-subscribe message system and includes structures such as a class (Topic), a classification node (spoke), and a cluster (Kafka cluster).
Specifically, the arranging the registration information according to a preset message middleware to obtain a registration message queue includes:
distributing the registration message of each application to different clusters by using the message middleware, and pushing the registration message of each application to different classification nodes in the clusters to obtain classification node information;
and arranging the classification node information of each classification node according to the sequence to obtain the registration message queue.
In the embodiment of the invention, the registration information is distributed to different clusters (Kafka cluster) on a Kafka processing platform, and is classified at classification nodes (brokers) in the clusters (Kafka cluster) to obtain the classification node information, and the classification node information is stored in a category (Topic) form and is arranged according to the sequence to obtain the registration message queue. When the registration message comes from a plurality of servers, the Kafka processing platform can reduce the coupling among the servers. Meanwhile, the Kafka processing platform uses a registration message queue as a buffer, arranges the registration information into the registration message queue, and processes the registration message queue within a period of time to provide peak-period service processing capacity.
And step two, acquiring log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application.
In the embodiment of the present invention, log printing configuration is performed on an application through a DSL (Domain Specific Language) to obtain a log printing configuration instruction, where the DSL is different from general programming languages such as Java, Python, and C languages, and has a limited expression capability, and only solves a Specific task in a Specific field.
Specifically, the obtaining log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application includes:
acquiring log configuration information of each application, wherein the log configuration information comprises a log configuration name, log type information, log format information and log expression information;
matching the application unique name and the log configuration name in the registration message queue according to a preset corresponding relation;
and when the matching is successful, 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.
In the embodiment of the invention, the log type information can be program logs, safety logs, system logs and the like; the log format information can be a table format, a document format and the like; the log expression information includes print expressions under different conditions, for example, printing is performed when a preset condition is satisfied. The preset corresponding relationship is used to represent a matching mapping relationship between the application unique name and the log configuration name, for example, the application unique name is "service application 1", and the corresponding log configuration name is "log configuration 1".
In detail, the 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:
extracting DSL package name information and DSL class name information from 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;
and filling the DSL package name information, the DSL class name information, the DSL format information and the DSL expression information into a preset configuration instruction template to obtain the log printing configuration instruction.
In an embodiment of the present invention, the preset configuration instruction template includes: the package name (namespace), the class name (classname), the name of the space method, the expression of the space condition (printing only if the condition is met) or the content (or abnormal information) of the space method access parameter. For example, if the DSL packet name information is com, the DSL class name information is pic, the DSL method information is btp, and the DSL expression information is ClassNameMethodName Condition, the log printing configuration instruction for processing the log entry and exit parameters is com.
In an optional embodiment of the invention, the log configuration information is matched by the registration message queue, so that the configuration speed is greatly improved, and the log printing instruction is configured by the self-created DSL, so that the uniform configuration of the log printing can be realized.
And thirdly, carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction.
In the embodiment of the invention, because errors such as format, grammar and the like may occur in the log printing configuration instruction, repeated configuration instructions need to be detected to ensure the security of configuration.
Specifically, the performing security detection on the log printing configuration instruction includes:
judging whether the format and grammar of the log printing configuration instruction are all correct or not;
if the format and syntax of the log printing configuration instruction are not completely correct, determining that the log printing configuration instruction is configured wrongly, and detecting that the log printing configuration instruction is unsafe;
and if the format and the grammar of the log printing configuration instruction are all correct, determining that the log printing configuration instruction is correctly configured and detecting the log printing configuration instruction as safe.
In detail, the dynamically enhancing the log printing configuration instruction for detecting security by using the preset log agent module to obtain the standard log printing instruction includes:
traversing a historical log printing configuration instruction, and intercepting the historical log printing configuration instruction appearing in the log configuration instruction by using the log agent module;
and carrying out loading type enhancement processing on the log configuration instruction which is not intercepted to obtain the standard log printing instruction.
In the embodiment of the present invention, the Log Agent module may be a Log Agent, and the Log Agent is configured to dynamically enhance different Log loading classes, such as adding a Log4j Log object, dynamically intercepting all configured methods, and executing a Log printing message in an enhanced standard Log printing instruction. By using the log Agent mode, the method can be suitable for all java web applications, has no code intrusion to the applications, does not need any development to the applications, reduces the development cost and also improves the efficiency of log printing.
And fourthly, executing the standard log printing instruction by using the log agent module to obtain a printing log.
In this embodiment of the present invention, the executing the standard log printing instruction by using the log agent module to obtain the print log includes:
judging whether the configuration information in the standard log printing instruction meets the preset configuration requirement or not based on the log agent module;
if the configuration information in the standard log printing instruction does not meet the preset configuration requirement, log printing is not carried out;
and if the configuration information in the standard log printing instruction meets the preset configuration requirement, performing log printing based on the configuration information to obtain the printing log.
In the embodiment of the invention, a log Agent module (Agent) receives a standard log printing instruction (namely, a DSL statement) of the application, wherein the DSL statement comprises parameters, classes, methods, a log format, an output target, context information (for example, information is obtained from thread, and spring context information is obtained), safety encryption information and the like of a printing log, then the Agent can perform transform on all class information, judge whether preset configuration requirements (such as class methods in the DSL must be hit) are met, if not, the log printing is not performed, other DSL statements are continuously executed, and if so, the printing processing is performed according to the log format, the parameter requirements, the encryption requirements and the input target stream requirements in the DSL statement. Meanwhile, the application program loads the Agent for printing the log through the java Agent, so that the application program does not need a developer to print the log, and only the DSL statements required by uniform configuration are required to be modified, and the efficiency of log printing is greatly improved.
According to the invention, log printing configuration is carried out on each application through the registration message queue formed by the message middleware and the log configuration information, so that the accuracy of each application configuration can be improved. Moreover, the log printing configuration instruction for detecting safety is dynamically enhanced through the log agent module, log configuration requirements of different applications can be unified, log printing efficiency is improved, a large amount of useless logs can not be printed through the printing instruction with unified configuration requirements, and therefore storage space is saved. Meanwhile, based on the log agent module, log adjustment can be performed before log printing, log parameters do not need to be manually adjusted after log printing is completed, and log printing efficiency is improved. Therefore, the log printing device provided by the invention can solve the problem of low log printing efficiency.
Fig. 3 is a schematic structural diagram of an electronic device implementing a log printing method according to an embodiment of the present invention.
The electronic device may comprise a processor 10, a memory 11, a communication interface 12 and a bus 13, and may further comprise a computer program, such as a journaling program, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only to store application software installed in the electronic device and various types of data, such as codes of a journaling program, etc., but also to temporarily store data that has been output or will be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged 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. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the whole electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device by running or executing programs or modules (e.g., a journal printing program, etc.) stored in the memory 11 and calling data stored in the memory 11.
The communication interface 12 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are typically 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 a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
The bus 13 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus 13 may be divided into an address bus, a data bus, a control bus, etc. The bus 13 is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 3 shows only an electronic device having components, and those skilled in the art will appreciate that the structure shown in fig. 3 does not constitute a limitation of the electronic device, and may include fewer or more components than those shown, or some components may be combined, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management and the like are realized through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device may further include a network interface, and 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 are generally used to establish a communication connection between the electronic device and other electronic devices.
Optionally, the electronic device may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The journal printing program stored in the memory 11 of the electronic device is a combination of a plurality of instructions, and when running in the processor 10, can realize:
acquiring registration information of each application, and arranging the registration information according to a preset message middleware to obtain a registration message queue;
acquiring log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application;
carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction;
and executing the standard log printing instruction by using the log agent module to obtain a printing log.
Specifically, the specific implementation method of the instruction by the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to the drawings, which is not described herein again.
Further, the electronic device integrated module/unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer readable storage medium. The computer readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
acquiring registration information of each application, and arranging the registration information according to a preset message middleware to obtain a registration message queue;
acquiring log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application;
carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction;
and executing the standard log printing instruction by using the log agent module to obtain a printing log.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method of printing a journal, the method comprising:
acquiring registration information of each application, and arranging the registration information according to a preset message middleware to obtain a registration message queue;
acquiring log configuration information of each application, and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application;
carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction;
and executing the standard log printing instruction by using the log agent module to obtain a printing log.
2. The method for printing logs according to claim 1, wherein the obtaining log configuration information of each application and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application comprises:
acquiring log configuration information of each application, wherein the log configuration information comprises a log configuration name, log type information, log format information and log expression information;
matching the application unique name and the log configuration name in the registration message queue according to a preset corresponding relation;
and when the matching is successful, 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.
3. The log printing method as claimed in claim 2, wherein said 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 command according to the extracted configuration information comprises:
extracting DSL package name information and DSL class name information from 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;
and filling the DSL package name information, the DSL class name information, the DSL format information and the DSL expression information into a preset configuration instruction template to obtain the log printing configuration instruction.
4. The method of claim 3, wherein the performing security checks on the journal print configuration instructions comprises:
judging whether the format and grammar of the log printing configuration instruction are all correct or not;
if the format and syntax of the log printing configuration instruction are not completely correct, determining that the log printing configuration instruction is configured wrongly, and detecting that the log printing configuration instruction is unsafe;
and if the format and the grammar of the log printing configuration instruction are all correct, determining that the log printing configuration instruction is correctly configured and detecting the log printing configuration instruction as safe.
5. The log printing method according to claim 1, wherein the dynamically enhancing the log printing configuration command for detecting security by using the preset log agent module to obtain a standard log printing command comprises:
traversing a historical log printing configuration instruction, and intercepting the historical log printing configuration instruction appearing in the log configuration instruction by using the log agent module;
and carrying out loading type enhancement processing on the log configuration instruction which is not intercepted to obtain the standard log printing instruction.
6. The method for printing logs according to claim 5, wherein the executing the standard log printing instruction by the log agent module to obtain a print log comprises:
judging whether the configuration information in the standard log printing instruction meets the preset configuration requirement or not based on the log agent module;
if the configuration information in the standard log printing instruction does not meet the preset configuration requirement, log printing is not carried out;
and if the configuration information in the standard log printing instruction meets the preset configuration requirement, performing log printing based on the configuration information to obtain the printing log.
7. The method for printing a log according to claim 1, wherein the arranging the registration information according to a preset message middleware to obtain a registration message queue comprises:
distributing the registration message of each application to different clusters by using the message middleware, and pushing the registration message of each application to different classification nodes in the clusters to obtain classification node information;
and arranging the classification node information of each classification node according to the sequence to obtain the registration message queue.
8. A log printing apparatus, characterized in that the apparatus comprises:
the registration information arrangement module is used for acquiring the registration information of each application and arranging the registration information according to a preset message middleware to obtain a registration message queue;
the log printing configuration module is used for acquiring log configuration information of each application and performing log printing configuration on each application based on the registration message queue and the log configuration information to obtain a log printing configuration instruction of each application;
the log printing instruction construction module is used for carrying out security detection on the log printing configuration instruction, and dynamically enhancing the log printing configuration instruction for detecting security by using a preset log agent module to obtain a standard log printing instruction;
and the log printing module is used for executing the standard log printing instruction by using the log agent module to obtain a printing log.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and the number of the first and second groups,
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the log printing method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the log printing method according to any one of claims 1 to 7.
CN202111228981.1A 2021-10-21 2021-10-21 Log printing method and device, electronic equipment and readable storage medium Pending CN113934387A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111228981.1A CN113934387A (en) 2021-10-21 2021-10-21 Log printing method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111228981.1A CN113934387A (en) 2021-10-21 2021-10-21 Log printing method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN113934387A true CN113934387A (en) 2022-01-14

Family

ID=79281022

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111228981.1A Pending CN113934387A (en) 2021-10-21 2021-10-21 Log printing method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN113934387A (en)

Similar Documents

Publication Publication Date Title
CN112085217A (en) Method, device, equipment and computer medium for deploying artificial intelligence service
CN113238929B (en) Code testing method and device based on Mock data, electronic equipment and storage medium
CN112506779A (en) Software interface testing method and device, electronic equipment and storage medium
CN112528307A (en) Service request checking method and device, electronic equipment and storage medium
CN114881616A (en) Business process execution method and device, electronic equipment and storage medium
CN115048111B (en) Code generation method, device, equipment and medium based on metadata
CN112579098A (en) Software release method and device, electronic equipment and readable storage medium
CN112732567A (en) Mock data testing method and device based on ip, electronic equipment and storage medium
CN113806434A (en) Big data processing method, device, equipment and medium
CN114116400A (en) Application exception handling method, device, equipment and medium based on log printing
CN112631903A (en) Task testing method and device, electronic equipment and storage medium
CN112104662A (en) Far-end data read-write method, device, equipment and computer readable storage medium
CN115033489A (en) Code resource detection method and device, electronic equipment and storage medium
CN115544566A (en) Log desensitization method, device, equipment and storage medium
CN113934387A (en) Log printing method and device, electronic equipment and readable storage medium
CN114816371A (en) Message processing method, device, equipment and medium
CN115145870A (en) Method and device for positioning reason of failed task, electronic equipment and storage medium
CN113051171A (en) Interface test method, device, equipment and storage medium
CN112667244A (en) Data verification method and device, electronic equipment and computer readable storage medium
CN112527443A (en) Prompt box display method and device, electronic equipment and computer readable storage medium
CN115964307B (en) Automatic test method, device, equipment and medium for transaction data
CN114139509A (en) Report processing method, device, equipment and medium
CN114818656B (en) Binary file analysis method, device, equipment and medium based on gray scale upgrading
CN115328583A (en) Log printing method, device, equipment and medium based on preset C + + log library
CN114942855A (en) Interface calling method and device, electronic equipment and storage medium

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