Log information processing method and device, electronic equipment and medium

CN115630033BActive Publication Date: 2026-09-22CHINA CONSTRUCTION BANK +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211186402.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-27
Publication Date
2026-09-22
Estimated Expiration
2042-09-27

AI Technical Summary

Technical Problem

但是这种方式存在如下三个缺点:1.当读取缓存日志写入文件的速度远小于缓存日志增长的速度时,缓存空间会快速增长,导致应用占用大量内存;2.当存在业务高并发处理时,多个业务处理的日志在日志文件中交叉出现,日志显得杂乱不易查看;3.如果应用异常终止,缓存内容将会丢失导致已发生的业务缺失日志,面临运行风险

Benefits of technology

[0012]本公开的第五方面还提供了一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现上述日志信息的处理方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115630033B_ABST
    Figure CN115630033B_ABST
Patent Text Reader

Abstract

The present disclosure provides a log information processing method and device, equipment, storage medium and program product, relates to the technical field of task scheduling, and can be applied to the technical field of finance. The method comprises the following steps: in response to receiving an instruction to output log information, obtaining a plurality of log information output by a plurality of application threads respectively; sequentially distributing each of the plurality of log information to a corresponding message queue; obtaining the log information located at the head of the message queue via a log processing thread corresponding to the message queue; and storing the log information into a specified log file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of task scheduling technology, and can be applied to the field of financial technology. More specifically, it relates to a method, apparatus, device, medium, and program product for processing log information. Background Technology

[0002] Business systems often need to output a large number of log files during operation for problem handling or post-event analysis. Existing technologies typically employ two methods for outputting system logs: (1) Synchronous log output by the application. In this method, the application is in a state of waiting for system I / O when outputting logs. During peak business periods, when a large number of logs are output, the business response time will increase significantly, and the system performance will be affected. (2) Asynchronous log output using caching. This method involves allocating a cache space in memory, writing the logs to be written to the cache, and then the application continues business processing. A separate log processing thread then asynchronously reads the cached content and writes it to the log file. Since the application access speed to the cache is much faster than writing to the disk file, the business response time is not affected. However, this method has the following three disadvantages: 1. When the speed of reading cached logs and writing them to the file is much slower than the speed of cached log growth, the cache space will grow rapidly, causing the application to occupy a large amount of memory; 2. When there is high concurrency in business processing, the logs of multiple business processes appear interspersed in the log file, making the logs appear messy and difficult to view; 3. If the application terminates abnormally, the cached content will be lost, resulting in missing logs of the business that has already occurred, which poses a risk to operation. Summary of the Invention

[0003] In view of the above problems, this disclosure provides a method, apparatus, device, medium, and program product for processing log information. When dealing with log processing in high-concurrency business systems, a corresponding message queue can be set up for the log information output by each application thread. By sequentially allocating each log information among the multiple log information to the corresponding message queue, the recording order, data persistence, and accumulation capability of the logs can be optimized. By obtaining the log information located at the head of the message queue through the log processing thread corresponding to the message queue, and storing the log information in a specified log file, it is beneficial to generate independent log files for the execution logs of each thread in sequence, which can improve the readability of the log files.

[0004] According to a first aspect of this disclosure, a method for processing log information is provided, comprising: in response to receiving an instruction to output log information, acquiring multiple log information output by multiple application threads; sequentially allocating each of the multiple log information to a corresponding message queue; acquiring the log information located at the head of the message queue via a log processing thread corresponding to the message queue; and storing the log information in a specified log file.

[0005] According to an embodiment of this disclosure, the log information includes a log identifier; storing the log information to a specified log file includes: determining whether the message queue has a log header; if the message queue has a log header, storing the log header and the log information to a log file corresponding to the log identifier according to the log identifier.

[0006] According to an embodiment of this disclosure, when it is determined that the message queue has a log header, storing the log header and the log information into a log file corresponding to the log identifier according to the log identifier includes: obtaining the serial number in the log header; determining whether a specified log file corresponding to the serial number exists; if it is determined that no specified log file corresponding to the serial number exists, creating a log file corresponding to the serial number; and storing the log information into the log file corresponding to the serial number.

[0007] According to an embodiment of this disclosure, the method for processing log information further includes: in response to determining that the log information has been stored in a designated log file, releasing the storage space of the log information in the message queue.

[0008] According to an embodiment of this disclosure, the method for processing log information further includes: generating a log header corresponding to the log processing thread while creating the log processing thread; and sending the log header to the message queue.

[0009] A second aspect of this disclosure provides a log information processing apparatus, comprising: a first acquisition module, configured to acquire multiple log information output by multiple application threads in response to receiving an instruction to output log information; an allocation module, configured to sequentially allocate each of the multiple log information to a corresponding message queue; a second acquisition module, configured to acquire the log information located at the head of the message queue via a log processing thread corresponding to the message queue; and a processing module, configured to store the log information in a specified log file.

[0010] A third aspect of this disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the aforementioned log information processing method.

[0011] A fourth aspect of this disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the aforementioned log information processing method.

[0012] The fifth aspect of this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for processing log information.

[0013] The log information processing method provided in this embodiment, when dealing with log processing in high-concurrency business systems, can set up corresponding message queues for the log information output by each application thread. By sequentially allocating each log information among the multiple log information to the corresponding message queue, the recording order, data persistence, and backlog capability of the logs can be optimized. By obtaining the log information located at the head of the message queue through the log processing thread corresponding to the message queue, and storing the log information in a specified log file, it is beneficial to generate independent log files for the execution logs of each thread in sequence, which can improve the readability of the log files. Attached Figure Description

[0014] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0015] Figure 1 The illustration schematically depicts application scenarios of log information processing methods, apparatuses, devices, media, and program products according to embodiments of the present disclosure;

[0016] Figure 2 A flowchart illustrating a method for processing log information according to an embodiment of the present disclosure is shown schematically.

[0017] Figure 3 A flowchart illustrating a method for processing log information according to another embodiment of this disclosure is shown schematically;

[0018] Figure 4 A flowchart illustrating a method for processing log information according to yet another embodiment of this disclosure is shown schematically;

[0019] Figure 5 A schematic block diagram of a log information processing apparatus according to embodiments of the present disclosure is shown; and

[0020] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a log information processing method according to an embodiment of the present disclosure. Detailed Implementation

[0021] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.

[0022] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0023] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0024] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).

[0025] The embodiments of this disclosure provide a method and apparatus for processing log information. In response to receiving an instruction to output log information, the method and apparatus acquire multiple log information output by multiple application threads; sequentially allocate each log information to a corresponding message queue; acquire the log information located at the head of the message queue via a log processing thread corresponding to the message queue; and store the log information in a specified log file.

[0026] Figure 1 The illustration shows an application scenario diagram of a log information processing method, apparatus, device, medium, and program product according to embodiments of the present disclosure.

[0027] like Figure 1As shown, application scenario 100 according to this embodiment may include terminal devices 101, 102, and 103, a network 104, and a server 105. Network 104 serves as a medium for providing a communication link between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0028] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0029] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0030] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using terminal devices 101, 102, and 103 (for example only). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0031] It should be noted that the log information processing method provided in this embodiment can generally be executed by server 105. Correspondingly, the log information processing apparatus provided in this embodiment can generally be located in server 105. The log information processing method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the log information processing apparatus provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105.

[0032] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0033] The following will be based on Figure 1 The described scene, through Figure 2 The method for processing log information according to the disclosed embodiments will be described in detail.

[0034] Figure 2 A flowchart illustrating a method for processing log information according to an embodiment of the present disclosure is shown.

[0035] like Figure 2 As shown, this embodiment includes operations S210 to S240, and the log information processing method can be executed by the server.

[0036] In the technical solution disclosed herein, the acquisition, collection, storage, use, processing, transmission, provision, disclosure, and application of data all comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and they do not violate public order and good morals.

[0037] In operation S210, in response to receiving the instruction to output log information, multiple log messages output by multiple application threads are obtained.

[0038] In operation S220, each log message from multiple log messages is sequentially assigned to its corresponding message queue.

[0039] In operation S230, log information located at the head of the message queue is obtained via the log processing thread corresponding to the message queue.

[0040] In operation S240, log information is stored in the specified log file.

[0041] For example, in a high-concurrency business system, multiple application threads generate a large amount of log information during their operation. A corresponding message queue can be established for the log information output by each application thread.

[0042] Message queues are also commonly known as message middleware. Data (messages) to be transmitted are placed in a queue, using a "first-in, first-out" (FIFO) queue mechanism to achieve message passing between applications. Common message middleware includes ActiveMQ, ZeroMQ, RabbitMQ, RocketMQ, and Kafka. Message queues can also be used to receive cached logs.

[0043] A corresponding log processing thread can be allocated and established for each message queue. This thread continuously reads the corresponding message queue, specifically retrieving the log information located at the head of that queue. The read log information can then be written to the log file corresponding to the task, i.e., stored in the designated log file.

[0044] Figure 3 A flowchart illustrating a method for processing log information according to another embodiment of this disclosure is shown schematically. See also: Figure 3The business system contains multiple concurrent tasks, namely Task 1 to Task N, generating a large amount of log information. Log queues, corresponding to each task (Log Queues 1 to N), are used to cache multiple log messages output by various application threads. Log processing threads (1-N) read log information from each log queue through an API interface and assign the read log messages to log files (Log File 1 to Log File N). In this embodiment, for a multi-task system, multiple message queues (MQ) are used to cache log information separately, accelerating log processing speed; an independent message middleware is used to cache business logs, decoupling business processing and log processing, and improving system response time.

[0045] The log information processing method provided in this embodiment, when dealing with log processing in high-concurrency business systems, can set up corresponding message queues for the log information output by each application thread. By sequentially allocating each log information among the multiple log information to the corresponding message queue, the recording order, data persistence, and backlog capability of the logs can be optimized. By obtaining the log information located at the head of the message queue through the log processing thread corresponding to the message queue, and storing the log information in a specified log file, it is beneficial to generate independent log files for the execution logs of each thread in sequence, which can improve the readability of the log files.

[0046] The log information includes a log identifier; storing the log information to a specified log file includes: determining whether the message queue has a log header; if the message queue has a log header, storing the log header and log information to the log file corresponding to the log identifier.

[0047] Log information includes log identifiers, for example, F and D; it can be agreed that F indicates that the log information should be output to the global log file, and D indicates that the log information should be output to the thread log file.

[0048] It is understandable that, at the same time as creating the log processing thread, a log header corresponding to the log processing thread is generated, and then the log header is sent to the message queue.

[0049] For example, log processing thread i can continuously read message queue i. For each message read, it first checks if a log header exists. If no log header exists, the corresponding log content can be directly written to the log file name corresponding to task i. If a log header exists, both the log header and the log content can be written to the log file name corresponding to task i.

[0050] The method for processing log information provided in this embodiment, when it is determined that there is a log header in the message queue, stores the log header and the log information in a log file corresponding to the log identifier according to the log identifier, which is beneficial for safely, efficiently and orderly outputting a plurality of pieces of log information in a high-concurrency system.

[0051] When it is determined that there is a log header in the message queue, storing the log header and the log information in a log file corresponding to the log identifier according to the log identifier comprises: acquiring a serial number in the log header, and determining whether there is a designated log file corresponding to the serial number; creating a log file corresponding to the serial number when it is determined that there is no designated log file corresponding to the serial number; and storing the log information in the log file corresponding to the serial number.

[0052] For example, a log output format may be defined first. For example, the format of a log output to an MQ message queue is [log identifier-global serial number]<log content>. It should be noted that [log identifier-global serial number] is log header information, which may only be valid for multi-threaded concurrent tasks, and single-threaded tasks do not need a log header. According to the convention, when the log identifier is F, it indicates that the log is output to a global log file, and when the log identifier is D, it indicates that the log is output to a thread log file. The global serial number, that is, the serial number in the log header, may be generated when a thread is created and needs to be unique at any time.

[0053] Specifically, first, an MQ message queue may be configured in advance according to the number of tasks of the service system to receive cached logs; then, the service system is started, for example, a plurality of tasks are started to perform system service processing; for a processing task i, it is first determined whether there is multi-threaded concurrent processing. If there is no multi-threaded concurrent processing, it is a single-threaded task, and the service log information may be directly output to the MQ message queue i in the format <log content>; if there is multi-threaded concurrent processing, it is a multi-threaded task. When the task i creates each processing thread j, a global serial number of the thread j needs to be generated, and a log "[F-global serial number]<New thread create>" is output to the MQ message queue i.

[0054] For example, when the thread j starts to process a specific service, it needs to output a log "[F-global serial number]<log content>" that records key service information (such as batch number, service serial number, etc.) to the MQ message queue i; the output format of other processing logs of thread j is "[D-global serial number]<log content>"; when the processing of thread j is completed and it exits, the output log format is "[F-global serial number]<Thread exit>".

[0055] After the log processing module starts, N log processing threads are created corresponding to the number of MQ message queues; each log processing thread i continuously reads MQ message queue i, and for each read message, it first checks whether a log header exists:

[0056] (1) If there is no log header, the log content is directly written to the log file name corresponding to task i;

[0057] (2) If a log header exists, and the log identifier is F, then both the log header and the log content are written to the log file name corresponding to task i; if the log identifier is D, then the global serial number in the log header is taken. If a file named with the global serial number already exists, then the log content is written directly to that file; otherwise, a new file needs to be created with the global serial number before writing the log content.

[0058] Figure 4 A flowchart illustrating a method for processing log information according to yet another embodiment of this disclosure is shown. See also: Figure 4 In a business system, a task contains multiple concurrent sub-tasks, i.e., task i contains M concurrent sub-tasks. Log queue i stores the output log information, and log processing thread i continuously reads the logs from the message queue. Log processing thread i uses a global log file (i.e., the global log of task i) to record key information about the creation and processing of each thread within task i. The specific execution logs of each thread can be output sequentially to independent log files (log 1-M), which greatly improves the readability of the log files.

[0059] The log information processing method provided in this embodiment defines a log output format. When multiple threads are running concurrently within a task, a global log file can be used to record the key information of each thread within the task. Furthermore, the log information of each thread can be output to an independent file in sequence, which is beneficial to improving the readability of the log file. This makes it extremely convenient to query and use the logs of high-concurrency tasks in the future, and solves the problem of intertwined and messy log information in traditional log files.

[0060] The log information processing method also includes: in response to determining that the log information has been stored in the specified log file, releasing the storage space of the log information in the message queue.

[0061] The log information processing method provided in this embodiment can release the storage space of the log information in the message queue in response to the completion of storing the log information in the specified log file; it can continuously provide cache space for the output log information, ensuring that the log information can be continuously cached in the message queue, which is beneficial to accelerating the log processing speed.

[0062] The log information processing method also includes: generating a log header corresponding to the log processing thread when creating the log processing thread; and sending the log header to the message queue.

[0063] The log information processing method provided in this embodiment can generate a log header corresponding to the log processing thread at the same time as creating the log processing thread; and send the log header to the message queue. This is beneficial for defining the log output format and makes it easy to achieve the goal of independent writing of multi-threaded concurrent logs through a simple log output format.

[0064] To better understand this disclosure, the following embodiments further illustrate the content of this disclosure, but this disclosure is not limited to the following embodiments.

[0065] The log message definition for the MQ message queue is as follows:

[0066]

[0067] It should be noted that (1) LogType: Log identifier, used to distinguish whether it is a log of the main task or a sub-thread task: assign F to the main task and S to the sub-thread task; (2) TaskID: Global task number, used to uniquely identify a main task or sub-thread; (3) Status: Task processing status, divided into 3 statuses: start status S, running status R, and end status E; (4) Contents: Fill in the specific business log content as needed.

[0068] Specifically, firstly: Business system log output:

[0069] S1. Configure an MQ message queue to receive cached logs based on the number of tasks involved in the business system. Each task corresponds to one MQ message queue.

[0070] S2. When each task starts, a global number is generated and the corresponding MQ message queue is connected via the MQ protocol. If the task involves multiple threads, the thread pool also needs to be initialized at startup, and a global number is generated for each thread.

[0071] S3. For each started task, generate standardized log messages during runtime according to the following rules:

[0072] (1) LogType: If it is a log output by a child thread, assign it the value S; otherwise, assign it the value F.

[0073] (2) TaskID: Assigned a global number to the current task or thread;

[0074] (3)StatUs: The value is S when the first log is output after each task or thread starts, E when the last log is output after the task or thread finishes its current work, and R in other cases.

[0075] S4. Place each log message into the MQ message queue corresponding to the task for processing.

[0076] Second: MQ message queue processing:

[0077] S11. Configure all MQ message queues that the log processing module needs to read;

[0078] S21. Configure the task log file name for each MQ message queue, which is the global log name for each task;

[0079] S31. Start the log processing module and initialize log processing threads according to the number of MQ message queues. Each thread is connected to an MQ message queue through the MQ protocol.

[0080] S41. Each log processing thread reads log messages from the head of the connected MQ message queue, parses the LogType, TaskID, Status, and Contents fields in the message, and performs the following processing:

[0081] (1) If LogType = 'F', write TaskID + Status + Contents to the global log file of the corresponding task;

[0082] (2) If LogType = 'S' and Status = 'S', write TaskID + Status + Contents to the global log file of the corresponding task, and check if a file with "global log file name + TaskID" exists. If it does not exist, create it.

[0083] (3) If LogType = 'S' and Status = 'E', write TaskID + Status + Contents to the global log file of the corresponding task;

[0084] (4) If LogType = 'S' and Status = 'R', write TaskID + Status + Contents to the file "Global log file name + TaskID".

[0085] S51. Each log processing thread repeats step S41.

[0086] Based on the above-described log information processing method, this disclosure also provides a log information processing apparatus. The following will be combined with... Figure 5The device is described in detail.

[0087] Figure 5 A schematic block diagram of a log information processing apparatus according to an embodiment of the present disclosure is shown.

[0088] like Figure 5 As shown, the log information processing device 500 of this embodiment includes a first acquisition module 510, an allocation module 520, a second acquisition module 530, and a processing module 540.

[0089] The first acquisition module 510 is used to acquire multiple log messages output by multiple application threads in response to receiving an instruction to output log messages; the allocation module 520 is used to allocate each of the multiple log messages to a corresponding message queue in sequence; the second acquisition module 530 is used to acquire the log message located at the head of the message queue via a log processing thread corresponding to the message queue; and the processing module 540 is used to store the log messages in a specified log file.

[0090] In some embodiments, the log information includes a log identifier; the processing module is configured to: determine whether the message queue has a log header; if the message queue has a log header, store the log header and the log information in a log file corresponding to the log identifier according to the log identifier.

[0091] In some embodiments, the second determining module is configured to: determine whether the user has permission to access the target shared document based on whether there is a predetermined mapping relationship between the access identifier and the target shared document.

[0092] In some embodiments, when it is determined that the message queue has a log header, storing the log header and the log information into a log file corresponding to the log identifier according to the log identifier includes: obtaining the serial number in the log header; determining whether a specified log file corresponding to the serial number exists; if it is determined that no specified log file corresponding to the serial number exists, creating a log file corresponding to the serial number; and storing the log information into the log file corresponding to the serial number.

[0093] In some embodiments, the log information processing device further includes: a first change module, configured to, in response to receiving a change request for an executable operation type from a user, determine a new executable operation type corresponding to the change request; and update the operation permission identifier of the target user according to the new executable operation type.

[0094] In some embodiments, the log information processing apparatus further includes a release module, configured to release the storage space of the log information in the message queue in response to determining that the storage of the log information in the specified log file has been completed.

[0095] In some embodiments, the log information processing apparatus further includes: a generation module, configured to generate a log header corresponding to the log processing thread while creating the log processing thread; and a sending module, configured to send the log header to the message queue.

[0096] According to embodiments of this disclosure, any plurality of modules among the first acquisition module 510, allocation module 520, second acquisition module 530, and processing module 540 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the first acquisition module 510, allocation module 520, second acquisition module 530, and processing module 540 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of software, hardware, and firmware methods, or in a suitable combination of any of these methods. Alternatively, at least one of the first acquisition module 510, the allocation module 520, the second acquisition module 530, and the processing module 540 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.

[0097] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a log information processing method according to an embodiment of the present disclosure.

[0098] like Figure 6 As shown, an electronic device 600 according to an embodiment of this disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage portion 608 into a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this disclosure.

[0099] RAM 603 stores various programs and data required for the operation of electronic device 600. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 602 and / or RAM 603. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.

[0100] According to embodiments of this disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.

[0101] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.

[0102] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 602 and / or RAM 603 and / or one or more memories other than ROM 602 and RAM 603 described above.

[0103] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code enables the computer system to implement the log information processing method provided in the embodiments of this disclosure.

[0104] When the computer program is executed by the processor 601, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0105] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and / or installed from the removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0106] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0107] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0108] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0109] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.

[0110] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.

Claims

1. A method for processing log information, comprising: In response to receiving an instruction to output log information, the system acquires multiple log information output by multiple application threads, wherein the log information is log information from a high-concurrency business system. Each of the multiple log messages is sequentially assigned to its corresponding message queue; Log information located at the head of the message queue is obtained via the log processing thread corresponding to the message queue; as well as Store the log information in a specified log file; The step of storing the log information to a specified log file includes: Determine whether the message queue has a log header, wherein the log header includes a log identifier and a sequence number, wherein the log identifier is used to indicate whether the log is output to a global log file or a thread log file, and the log header includes a log identifier and the sequence number of the thread; If it is determined that the message queue has a log header, the log header and the log information are stored in the log file corresponding to the log identifier according to the log identifier; the step of storing the log header and the log information in the log file corresponding to the log identifier according to the log identifier includes: For multi-threaded tasks, if the log identifier indicates that the log is output to the global log file, then the log information is written to the log file corresponding to the task. If the log identifier indicates that the log is output to a thread log file, obtain the sequence number in the log header and determine whether a specified log file corresponding to the sequence number exists. If it is determined that a specified log file corresponding to the specified serial number does not exist, a log file corresponding to the specified serial number is created; and The log information is stored in the log file corresponding to the serial number.

2. The method according to claim 1, further comprising: Upon determining that the log information has been stored in the specified log file, the storage space of the log information in the message queue is released.

3. The method according to claim 1, further comprising: While creating the log processing thread, a log header corresponding to the log processing thread is generated; as well as The log header is sent to the message queue.

4. A log information processing apparatus, comprising: The first acquisition module is used to acquire multiple log information output by multiple application threads in response to receiving an instruction to output log information, wherein the log information is log information in a high-concurrency business system; The allocation module is used to sequentially allocate each log message among the plurality of log messages to the corresponding message queue; The second acquisition module is used to acquire log information located at the head of the message queue via a log processing thread corresponding to the message queue. as well as The processing module is used to store the log information into a specified log file; The processing module is used for: Determine whether the message queue has a log header, wherein the log header includes a log identifier and a sequence number, wherein the log identifier is used to indicate whether the log is output to a global log file or a thread log file, and the log header includes a log identifier and the sequence number of the thread; If it is determined that the message queue has a log header, the log header and the log information are stored in the log file corresponding to the log identifier according to the log identifier; The step of storing the log header and the log information to the log file corresponding to the log identifier, based on the log identifier, when it is determined that the message queue has a log header, includes: For tasks that involve multi-threaded concurrent processing, if the log identifier indicates that the log is output to a global log file, then the log information is written to the log file corresponding to the task. If the log identifier indicates that the log is output to a thread log file, obtain the sequence number in the log header and determine whether a specified log file corresponding to the sequence number exists. If it is determined that a specified log file corresponding to the specified serial number does not exist, a log file corresponding to the specified serial number is created; and The log information is stored in the log file corresponding to the serial number.

5. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method according to any one of claims 1 to 3.

6. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 3.

7. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Log information output method and device

    CN104252405A

  • Multi-thread log output method and device

    CN108205476A

  • Log processing method and device, electronic equipment and computer readable storage medium

    CN111045782A

  • Method for writing transaction logs in database in parallel to improve processing efficiency

    CN114116665A