Log printing method and device, storage medium and program product
By configuring the channel parameters of log printing files, flexibly selecting local disk or message queue channels, solving the disk bottlenecks and invasive problems of code modification in log printing methods, achieving efficient and flexible log storage and management, and improving system reliability and operation and maintenance efficiency.
Patent Information
- Application Number
- CN202510520852.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-07-25
AI Technical Summary
The existing log printing methods have problems such as disk I/O performance bottlenecks and high invasive code modification, resulting in application service response delays and increased development and testing costs, and insufficient flexibility.
By configuring the channel parameters of the log printing file, clarify the printing requirements and channel mapping relationship, flexibly select the local disk or message queue channel, or use two channels at the same time, automatically select the target printing channel according to the needs, and store the log information in the corresponding area through the target channel.
It reduces development, testing and maintenance costs, improves the reliability, flexibility and operation and maintenance efficiency of log printing, avoids high intrusion into existing code, and realizes efficient storage and management of log information.
Smart Images

Figure CN120371567A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of log processing, and particularly to a log printing method, device, storage medium and program product. Background Art
[0002] In the prior art, log management mainly adopts two methods: log printing based on a local disk and asynchronous log printing based on a message queue. The local disk solution deploys logs and application services on the same server, but there is a bottleneck in disk I / O performance, which may cause response latency or anomalies in the application service. The message queue asynchronous solution decouples the log recording and the application processing flow, but it is necessary to modify the code in the existing log printing file to adapt to the queue communication mechanism. If the log printing requirements are modified, the code needs to be further modified, increasing the development, testing and maintenance costs, and there are problems of high invasiveness and insufficient flexibility.
[0003] It can be seen that the existing solutions have limitations in the log printing method. Therefore, there is an urgent need for a new log printing method to improve the reliability, flexibility and operation and maintenance efficiency of the log system. Summary of the Invention
[0004] The object of the present invention is to provide a log printing method, device, storage medium and program product, which do not need to frequently modify the code for different log printing requirements, reduce the development, testing and maintenance costs, avoid high invasiveness to the existing code, and at the same time can flexibly switch the log printing channels according to the actual situation, improving the reliability, flexibility and operation and maintenance efficiency of the log printing.
[0005] To solve the above technical problems, the present invention provides a log printing method, including: configuring channel parameters of a log printing file, where the log printing file includes a mapping relationship and control logic between a printing requirement and a printing channel, and the printing channel at least includes a channel for printing logs to a local disk and / or a channel for printing logs to a message queue; when receiving a target printing requirement, determining a target printing channel corresponding to the target printing requirement according to the log printing file; and printing log information generated by an application service to a corresponding storage area through the target printing channel, where the storage area is the local disk and / or the message queue.
[0006] To solve the above technical problems, the present invention further provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of the above-mentioned log printing method when executing the computer program.
[0007] To solve the above technical problems, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the log printing method as described above are implemented.
[0008] To solve the above technical problems, the present invention also provides a computer program product, including a computer program / instructions. When the computer program / instructions are executed by a processor, the steps of the log printing method as described above are implemented.
[0009] The present invention provides a log printing method, device, storage medium, and program product, which are applied to the field of log printing. This solution configures the channel parameters of the log printing file, clarifies the mapping relationship and control logic between the printing requirements and the printing channels, and can flexibly select the channel for printing the log to the local disk, the channel for printing the log to the message queue, or use both channels simultaneously according to different printing requirements. When receiving the target printing requirement, the target printing channel is determined based on the log printing file, and the log information is printed to the corresponding storage area through this channel. This application does not require frequent code modification for different log printing requirements, reduces the development, testing, and maintenance costs, avoids high invasiveness to the existing code, and can flexibly switch the log printing channel according to the actual situation, improving the reliability, flexibility, and operation and maintenance efficiency of the daily printing. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] To more clearly illustrate the embodiments of the present invention, the following will briefly introduce the drawings required for the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0011] Figure 1 It is a flowchart of a log printing method provided by the present invention;
[0012] Figure 2 It is a flowchart of a log processing provided by the present invention;
[0013] Figure 3 It is a schematic diagram of an electronic device provided by the present invention;
[0014] Figure 4 It is a schematic diagram of a computer-readable storage medium provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0015] The core of the present invention is to provide a log printing method, device, storage medium, and program product, which do not require frequent code modification for different log printing requirements, reduce development, testing, and maintenance costs, avoid high invasiveness to existing code, and can flexibly switch log printing channels according to actual situations, improving the reliability, flexibility, and operation and maintenance efficiency of daily printing.
[0016] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0017] To solve the above technical problems, the present invention provides a log printing method, including:
[0018] S11: Configure the channel parameters of the log printing file. The log printing file includes the mapping relationship and control logic between the printing requirements and the printing channels. The printing channels at least include the channel for printing the log to the local disk and / or the channel for printing the log to the message queue;
[0019] Specifically, configuring the channel parameters of the log printing file lies in building a flexible and customizable log printing framework. The log printing file, as the core configuration carrier of the entire log printing system, contains the mapping relationship and control logic between the printing requirements and the printing channels. The printing requirements are diverse, and different business scenarios, different system states, etc. will generate different log printing requirements. For example, when the device is running normally, only key operation information may need to be recorded, while when the device has an exception, detailed error stack information, etc. needs to be recorded. The printing channel is the way to realize log output, which at least includes the channel for printing the log to the local disk and / or the channel for printing the log to the message queue. These two channels have their own advantages. The local disk channel can ensure the local storage of log data, facilitating immediate viewing and analysis, while the message queue channel can realize the asynchronous processing and distributed storage of logs, improving the performance and scalability of the system. Among them, the log printing file can be a log4j log architecture component (such as in the form of a jar package).
[0020] The message queue adopts a storage mechanism that combines disk and memory. After the log information enters the message queue, it will first be cached in the memory area. By leveraging the high-speed read and write characteristics of the memory, the data processing latency is reduced, and the efficiency of message sending by the producer and message reading by the consumer is improved. At the same time, the messages will be asynchronously persisted to disk storage, and data persistence is achieved through forms such as log files or databases, ensuring that message data will not be lost in the event of server abnormal restart, power failure, or other failure scenarios. This combination of "fast memory processing + disk persistent storage" avoids the I / O performance bottleneck that may be caused by solely relying on disk storage and solves the reliability risk existing in solely relying on memory storage, providing double guarantees for the integrity and efficient processing of log data during asynchronous transmission.
[0021] By configuring the channel parameters, it is actually clarifying which printing channel should be adopted for different printing requirements and control logics such as under what conditions the channel is switched. In this way, the appropriate printing channel can be flexibly selected according to the actual printing requirements, avoiding the limitations of a single channel in the prior art and improving the flexibility and reliability of log printing.
[0022] S12: Upon receiving the target printing requirement, determine the target printing channel corresponding to the target printing requirement according to the log printing file;
[0023] Specifically, after receiving the target printing requirement, determine the target printing channel corresponding to the target printing requirement according to the log printing file. The principle is based on the prior pre-configuration of the log printing file, which has established the mapping relationship and control logic between the printing requirement and the printing channel. When the target printing requirement is received, it is compared with various printing requirements preset in the log printing file. Since the log printing file records the corresponding rules for different printing requirements and printing channels, logical judgment is made based on these rules, and the target printing channel that matches the target printing requirement is selected from multiple available printing channels (at least including the channel for printing the log to the local disk and the channel for printing the log to the message queue).
[0024] This step is an effective utilization of the configured information, enabling the system to automatically select the appropriate channel to process the log according to the specific log printing requirement, avoiding the cumbersome and inaccurate manual intervention, and also improving the efficiency and flexibility of log printing, enabling the system to dynamically adjust the log output path according to the actual requirement to meet the diverse requirements for log processing in different scenarios.
[0025] S13: Print the log information generated by the application service to the corresponding storage area through the target printing channel, and the storage area is the local disk and / or the message queue.
[0026] Specifically, the effective storage of logs is achieved based on the mapping relationship and channel selection result determined in the previous steps. In the previous steps, the corresponding relationship between the printing requirements and the printing channels has been clarified through the configuration of the log printing file, and the target printing channel has been determined according to the target printing requirements. During the operation of the application service, various log information will be continuously generated, and these log information represent important data such as the running status of the service in the device and operation records. After determining the target printing channel, the log information is encapsulated and transmitted according to the characteristics and rules of the channel.
[0027] If the target printing channel is a channel that prints logs to the local disk, according to the operation specifications of the local file system, the log information is written into the specified local disk storage area, which is convenient for subsequent viewing, analysis, and backup of the logs locally. If the target printing channel is a channel that prints logs to the message queue, the log information is sent to the message queue according to the communication protocol of the message queue. The message queue can buffer, distribute, and store these log information, which is convenient for subsequent centralized processing and analysis.
[0028] In this way, it can be ensured that the log information generated by the application service can be accurately and efficiently stored in the corresponding storage area to meet the requirements of log management and utilization in different scenarios.
[0029] In an exemplary embodiment, before configuring the channel parameters of the log printing file, it further includes: creating a message queue and a dead-letter queue; after printing the log information generated by the application service to the corresponding storage area through the target printing channel, it further includes: determining whether there is log information in the message queue that meets the migration condition for migrating to the dead-letter queue; if the migration condition is met, the log information that meets the migration condition is migrated from the message queue to the dead-letter queue.
[0030] Specifically, a message queue and a dead-letter queue are pre-created as the basis for asynchronous log processing to ensure the integrity and traceability of log data. The message queue, as an intermediate channel for log information to be transmitted from the application service to the storage area, can decouple log recording from application processing and improve system throughput; while the dead-letter queue serves as the "exception processor" of the message queue and is used to store log data that encounters exceptions during the processing process.
[0031] After the log information is output through the target printing channel, it is determined whether the logs in the message queue meet the preset migration conditions (such as multiple consumption failures, timeout without processing, etc.). The logs that meet the conditions are migrated to the dead-letter queue. Essentially, through this two-layer architecture of "main queue - dead-letter queue", abnormal logs are isolated and marked, avoiding the impact of local processing failures on the overall log process, and at the same time providing an independent data source for subsequent problem troubleshooting and compensation processing.
[0032] The method of this embodiment utilizes the asynchronous advantage of the message queue and also ensures the reliability of log data in abnormal scenarios through the dead-letter queue mechanism, forming a closed-loop management of the log processing flow, and improving the fault tolerance and operation and maintenance efficiency of the system in complex environments.
[0033] In an exemplary embodiment, determining whether there is log information in the message queue that meets the migration condition for migrating to the dead-letter queue includes: determining whether there is log information that has not been consumed within the timeout in the message queue, and the log information that has not been consumed within the timeout is the log information whose storage time in the message queue exceeds the threshold; if there is log information that has not been consumed within the timeout, it is determined that the log information that has not been consumed within the timeout meets the migration condition.
[0034] Specifically, an implementation method for determining whether there is log information that has not been consumed within the timeout in the message queue and migrating it to the dead-letter queue accordingly is: real-time monitoring of the log processing status in the message queue by setting a time threshold to actively identify abnormally retained log data and perform isolation processing.
[0035] Specifically, by detecting whether the storage time of the log information in the message queue exceeds the preset threshold, it is determined whether it belongs to "timeout consumption", that is, the log information has not been processed by the consumer for a long time, which may be caused by reasons such as consumer failure, network delay, or abnormal processing logic. If there is such log information that has not been consumed within the timeout, it is determined that it meets the migration condition and is migrated to the dead-letter queue. Essentially, through the abnormal detection mechanism in the time dimension, the logs that may have processing obstacles are separated from the normal processing flow, avoiding abnormal logs occupying queue resources for a long time and affecting the processing efficiency of subsequent logs. At the same time, it provides an independent data source for subsequent targeted troubleshooting of the timeout reasons (such as consumer performance bottleneck, communication link failure, etc.), ensuring the robustness of the log processing flow and data traceability in abnormal scenarios, thereby building a fault isolation and problem positioning mechanism based on the time threshold in the asynchronous log processing architecture.
[0036] In an exemplary embodiment, determining whether there is log information in the message queue that meets the migration condition for migrating to the dead-letter queue includes: determining whether there is log information with abnormal consumption in the message queue, and the log information with abnormal consumption is the log information whose number of abnormal reads exceeds the preset number; if there is log information with abnormal consumption, it is determined that the log information with abnormal consumption meets the migration condition.
[0037] Specifically, another way to determine whether there is log information with abnormal consumption in the message queue and migrate it to the dead-letter queue accordingly is: constructing a fault tolerance and isolation mechanism for log processing by setting a threshold for the number of consumption retries.
[0038] Specifically, when processing log data asynchronously, the number of abnormal reads of log information in the message queue that is abnormally read by consumers (such as parsing failure, processing timeout, data format mismatch, etc.) will be continuously recorded. When the number of abnormal reads of a log message exceeds the preset threshold, it indicates that the log message may not be consumed normally through the conventional retry mechanism due to data errors, consumer logic defects, or external dependency anomalies. At this time, judging that the log meets the migration conditions and migrating it to the dead letter queue is essentially to separate the "stubborn" logs that repeatedly fail to process from the normal consumption process through quantified abnormal number detection, so as to avoid invalid retries occupying queue resources and affecting the overall processing efficiency. At the same time, the abnormal log information is centrally stored in the dead letter queue, providing a clear target data source for subsequent manual investigation of abnormal causes (such as data cleaning, consumer logic repair, dependent service debugging, etc.), thereby establishing a fault classification processing mechanism based on the number of retries in the asynchronous log processing architecture, balancing the system's automated processing capabilities and the need for manual intervention in abnormal scenarios.
[0039] In an exemplary embodiment, after the log information generated by the application service is printed to the corresponding storage area through the target printing channel, it also includes: triggering the local log management tool to push the log information stored in the local disk to the log centralized management module; and / or, triggering the log centralized management module to read the corresponding log information from the message queue according to the log management requirements.
[0040] Specifically, for log information stored on local disks, the local log management tool is triggered to push it to the centralized log management module because the logs stored on local disks are relatively scattered, which is not conducive to unified analysis and management. Through the local log management tool, the log information scattered in various local disks can be collected and pushed to the centralized log management module, so that these logs can be uniformly stored, analyzed and processed, which is convenient for quickly discovering problems and trends in the system.
[0041] The triggering log centralized management module reads the corresponding log information from the message queue according to the log management requirements because the log data stored in the message queue is processed in an asynchronous manner. The log centralized management module can obtain the required log information from the message queue in a targeted manner according to different log management requirements. This not only avoids the waste of resources caused by reading a large number of useless logs at one time, but also ensures that the logs closely related to the management requirements are obtained, thereby improving the efficiency and accuracy of log management. In addition, after the log centralized management module reads the corresponding log information from the message queue according to the log management requirements, it also includes recording the message reading record.
[0042] The method in this embodiment can fully integrate the log information stored in the local disk and the message queue, providing strong support for the centralized management and in-depth analysis of logs, thereby better meeting the diverse requirements of the system for log management.
[0043] In an exemplary embodiment, it further includes: triggering the log centralized management module to perform deduplication and formatting processing on the log information in the obtained message queue and the log information in the local disk; after the deduplication and formatting processing, storing all the log information in a preset database, facilitating the extraction of corresponding log information from the preset database according to the log extraction requirements and the retrieval engine.
[0044] Specifically, it further includes triggering the log centralized management module to perform deduplication and formatting processing on the log information of the message queue and the local disk and storing it in a preset database, constructing a unified log data view through data cleaning and standardization processing to improve the effectiveness and usability of log management.
[0045] Specifically, since log information may be output through two channels of the local disk and the message queue (such as when both channels are enabled simultaneously), duplicate records may be generated. Deduplication processing can eliminate redundant data and ensure the uniqueness and accuracy of log information; while the log data formats of different channels may vary (such as the text format of local logs and the structured data format of the message queue), formatting processing can convert diverse log data into a unified standardized structure, facilitating subsequent analysis, statistics, and correlation queries. The cleaned log information is stored in a preset database, forming a centralized log storage center, which not only provides a standardized data source for the retrieval engine but also supports quickly locating and retrieving target logs according to different log extraction requirements (such as by time, business type, log level, etc.), thus establishing a complete link of "data integration - cleaning - storage - retrieval" in the log centralized management architecture, solving the consistency problem of multi-source logs, and improving the efficiency of system operation and maintenance and fault troubleshooting.
[0046] In an exemplary embodiment, configuring the channel parameters of the log printing file includes: configuring the storage path, file name, and log level of the channel corresponding to the local disk, and configuring the connection information, confirmation mechanism, retry policy, and topic name of the channel corresponding to the message queue. The connection information includes the device host address and port number. The confirmation mechanism includes defining whether to wait for confirmation after the producer sends log information. The retry policy includes the maximum number of times the producer retries to write log information to the message queue when the write fails. The topic name is used to classify log information.
[0047] Specifically, configuring the channel parameters of the log printing file is to enable the log printing system to operate flexibly and efficiently according to different requirements and scenarios. Among them, configure the storage path, file name, and log level of the channel corresponding to the local disk to perform refined management of the local disk storage logs. The storage path determines the storage location of the log file on the local disk, and reasonable settings can facilitate subsequent log searching, backup, and maintenance; the file name is the identifier of the log file, which can be named according to factors such as business and time to facilitate the distinction of different types or time periods of logs; the log level stipulates which levels of log information will be recorded on the local disk. By setting different log levels, the details and quantity of logs on the local disk can be controlled, avoiding the storage of excessive useless log information.
[0048] Configure the connection information, confirmation mechanism, retry policy, and topic name of the channel corresponding to the message queue to ensure that log information can be transmitted and processed reliably and orderly through the message queue. The device host address and port number in the connection information are the keys for the application program to establish communication with the message queue server. Accurate connection information can ensure the normal connection between the application program and the message queue; the confirmation mechanism defines whether the producer needs to wait for confirmation after sending the log information, which can balance between the message sending speed and reliability according to actual needs. For example, wait for confirmation in scenarios with high reliability requirements and do not wait for confirmation in scenarios with high speed requirements; the retry policy stipulates the maximum number of times to retry writing when the producer fails to write log information to the message queue, which can cope with some temporary network failures or message queue server problems and improve the success rate of log information writing; the topic name is used to classify log information, and different topics can correspond to different types of logs, facilitating consumers to subscribe to the log information of the corresponding topic according to their own needs and realizing the classified processing and management of logs.
[0049] In an alternative embodiment, after sending the log information, the producer does not need to wait for the confirmation response from the message broker (Broker). Instead, it asynchronously processes the sending result through a callback function mechanism, optimizing the message transmission process with an asynchronous non-blocking mode, thereby enhancing the system's concurrent processing ability and data throughput. Specifically, in the traditional synchronous confirmation mechanism, after sending the log information, the producer needs to wait for the confirmation signal from the message broker in a blocking manner. During this period, the thread or process resources of the producer will be continuously occupied, and it cannot process subsequent log information sending or business logic, easily forming a bottleneck in system performance. After adopting the callback function mechanism, the producer immediately releases resources after the log information sending operation is completed and can continue to process new log generation tasks or other business requests. Only when the message broker completes the message reception and processing (whether successful or failed), the subsequent processing logic of the sending result (such as recording the message sending status, performing exception compensation operations, etc.) is asynchronously triggered by a predefined callback function. This design decouples the "confirmation waiting process" of message sending from the "business processing process", enabling the producer to process more log information sending requests per unit time, avoiding the problem of resource idleness caused by synchronous blocking, and thus effectively enhancing the system's concurrency, that is, supporting the simultaneous processing of multiple independent message sending tasks, and enhancing the throughput, that is, the total number of messages successfully transmitted per unit time. It can handle the asynchronous processing of logs in high-load scenarios, ensuring the reliability of message sending while maximizing the utilization of system resources, reducing performance losses caused by input / output (I / O) waiting, and achieving a balanced optimization of log processing efficiency and system resource utilization.
[0050] In summary, by configuring these channel parameters, the log printing system can achieve the best performance and management effects in both local disk and message queue, the two different log storage and transmission methods.
[0051] Such as Figure 2, which shows the overall process of application service log processing: The requester submits a business application transaction through the channel end (process ①), triggering the application service to process the business and print logs. The application service integrates the customized log4j log architecture jar package of this application, and can flexibly configure the log printing method (process ②): It can either print the log data to the local disk according to the default configuration, or asynchronously print through the message queue according to the newly added configuration items (such as message queue connection information, acks, retries, Topic, etc.), and can also configure dual-channel high-availability two-way printing. When printing asynchronously based on the message queue, if the situation of abnormal consumption or timeout consumption occurs, the log will be re-recorded to the dead letter queue (process ③) for subsequent troubleshooting and separate processing. The log data on the local disk is incrementally pushed after the local management tool monitors the file changes in real time (process ④). Finally, the log centralized management system collects the log data collected from the message queue (including the dead letter queue) by subscribing and consuming, or receives the log data pushed in real time by the local log management tool through the interface (processes ⑤ and ⑥). After obtaining the dual-channel log data of the application service, all the logs are processed and deduplicated, and then sent to the retrieval engine for subsequent operation and maintenance management. This method collects log data in parallel through dual channels, ensuring the timeliness and reliability of log collection and processing, and solving problems such as the impact of single local disk I / O or abnormal local log push.
[0052] To solve the above technical problems, such as Figure 3 , the present invention also provides an electronic device, including:
[0053] A memory 31 for storing a computer program; a processor 32 for implementing the steps of the above log printing method when executing the computer program. For the introduction of the electronic device, please refer to the above embodiments, and the present application will not repeat it here.
[0054] To solve the above technical problems, such as Figure 4 , the present invention also provides a computer-readable storage medium 41, on which a computer program 42 is stored. When the computer program 42 is executed by a processor, it implements the steps of the above log printing method. For the introduction of the computer-readable storage medium 41, please refer to the above embodiments, and the present application will not repeat it here.
[0055] To solve the above technical problems, the present invention also provides a computer program product, including a computer program / instructions, which implement the steps of the above log printing method when executed by a processor.
[0056] For the introduction of the computer program product, please refer to the above embodiments, and the present application will not repeat it here.
[0057] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0058] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A log printing method, characterized in that, Including: Configuring channel parameters of a log printing file, where the log printing file includes a mapping relationship and control logic between printing requirements and printing channels, and the printing channels at least include a channel for printing logs to a local disk and / or a channel for printing logs to a message queue; Upon receiving a target printing requirement, determining a target printing channel corresponding to the target printing requirement according to the log printing file; Printing log information generated by an application service to a corresponding storage area through the target printing channel, where the storage area is the local disk and / or the message queue.
2. The log printing method according to claim 1, wherein Before configuring the channel parameters of the log printing file, further including: Creating the message queue and the dead letter queue; After printing log information generated by an application service to a corresponding storage area through the target printing channel, further including: Determining whether there is log information in the message queue that meets the migration condition for migrating to the dead letter queue; If the migration condition is met, migrating the log information that meets the migration condition from the message queue to the dead letter queue.
3. The log printing method according to claim 2, wherein Determining whether there is log information in the message queue that meets the migration condition for migrating to the dead letter queue includes: Determining whether there is log information that has not been consumed within the timeout in the message queue, where the log information that has not been consumed within the timeout is log information that has been stored in the message queue for a time exceeding a threshold; If there is log information that has not been consumed within the timeout, determining that the log information that has not been consumed within the timeout meets the migration condition.
4. The log printing method according to claim 2, wherein Determining whether there is log information in the message queue that meets the migration condition for migrating to the dead letter queue includes: Determining whether there is log information with abnormal consumption in the message queue, where the log information with abnormal consumption is log information whose number of abnormal reads exceeds a preset number; If there is log information with abnormal consumption, determining that the log information with abnormal consumption meets the migration condition.
5. The log printing method according to claim 1, wherein After printing log information generated by an application service to a corresponding storage area through the target printing channel, further including: Triggering a local log management tool to push the log information stored in the local disk to a log centralized management module; And / or, triggering the log centralized management module to read corresponding log information from the message queue according to log management requirements.
6. The log printing method according to claim 5, characterized in that Further including: Triggering the log centralized management module to perform deduplication and formatting processing on the log information in the obtained message queue and the log information in the local disk; After the deduplication and formatting processing, storing all the log information in a preset database, facilitating the extraction of corresponding log information from the preset database according to log extraction requirements and a retrieval engine.
7. The log printing method according to any one of claims 1-6, characterized in that, Configuring the channel parameters of the log printing file includes: Configure the storage path, file name, and log level of the channel corresponding to the local disk, and configure the connection information, confirmation mechanism, retry policy, and topic name of the channel corresponding to the message queue. The connection information includes the device host address and port number. The confirmation mechanism includes defining whether to wait for confirmation after the producer sends the log information. The retry policy includes the maximum number of times the producer retries writing when writing the log information to the message queue fails. The topic name is used to classify the log information.
8. An electronic device, characterized in that, It includes: A memory for storing computer programs; A processor for implementing the steps of the log printing method according to any one of claims 1-7 when executing the computer program.
9. A computer-readable storage medium, characterized in that, The computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps of the log printing method according to any one of claims 1-7 are implemented.
10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, the steps of the log printing method according to any one of claims 1-7 are implemented.