Log grabbing method, device and equipment and storage medium

CN122507576APending Publication Date: 2026-08-04SHENZHEN TCL DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN TCL DIGITAL TECH CO LTD
Filing Date
2026-04-01
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

[0003]本申请实施例提供一种日志抓取方法、装置、设备和存储介质,旨在解决现有技术中日志抓取效率低和日志抓取资源占用较大的技术问题

Benefits of technology

[0014] This application responds to a log capture request triggered by a target application process, obtains log capture information corresponding to the request, captures a compressed log file corresponding to the request based on the log capture information and the target capture interface corresponding to the target log library, and transmits the compressed log file to a log parsing terminal for parsing to obtain the target log file corresponding to the target application process. This achieves the goal of directly capturing the compressed log file corresponding to the request based on the log capture information and the pre-set target capture interface of the target log library when responding to a log capture request triggered by a target application process, and transmitting the compressed log file to the log parsing terminal for log parsing. This eliminates the need to transfer logs from a log printing tool to a log viewing tool, optimizing the log capture process, reducing CPU usage and system resource consumption during log capture, and improving log capture efficiency and system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122507576A_ABST
    Figure CN122507576A_ABST
Patent Text Reader

Abstract

This application provides a log capture method, apparatus, device, and storage medium. The log capture method includes: responding to a log capture request triggered by a target application process and obtaining log capture information corresponding to the log capture request; capturing a compressed log file corresponding to the log capture request based on the log capture information and a target capture interface corresponding to a target log library; and transmitting the compressed log file to a log parsing terminal, so that the log parsing terminal parses the compressed log file to obtain a target log file corresponding to the target application process. This eliminates the need to transfer logs from a log printing tool to a log viewing tool, thereby optimizing the log capture process, reducing CPU usage and system resource consumption during log capture, and improving log capture efficiency and system stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, specifically to a log capture method, apparatus, device, and storage medium. Background Technology

[0002] Currently, with the rapid development of smart terminals, such as mobile terminals, they are increasingly being widely used. The stability, performance, and user experience of smart terminals are crucial during application, thus requiring anomaly monitoring. Anomaly monitoring and testing of smart terminals rely on log capture mechanisms to collect system logs. However, existing log capture processes consume significant terminal system resources (such as CPU and socket resources) during runtime, easily leading to system performance degradation and log loss under high load, resulting in low log capture efficiency and accuracy. Summary of the Invention

[0003] This application provides a log capture method, apparatus, device, and storage medium, aiming to solve the technical problems of low log capture efficiency and high log capture resource consumption in the prior art.

[0004] On the one hand, embodiments of this application provide a log capture method, which includes the following steps: Respond to the log capture request triggered by the target application process and obtain the log capture information corresponding to the log capture request; Based on the log capture information and the target capture interface corresponding to the target log library, capture the compressed log file corresponding to the log capture request; The compressed log file is transmitted to a log parsing terminal, which then parses the compressed log file to obtain the target log file corresponding to the target application process.

[0005] In one possible implementation of this application, the step of retrieving the compressed log file corresponding to the log retrieval request based on the log retrieval information and the target retrieval interface corresponding to the target log library includes: Determine the target log library corresponding to the log capture request, wherein the target log library has a target capture interface; The target crawling interface is invoked to crawl the compressed log file corresponding to the log crawling request according to the log crawling information.

[0006] In one possible implementation of this application, the step of calling the target crawling interface to crawl the log compressed file corresponding to the log crawling request according to the log crawling information includes: A log capture command is sent to the log printing process based on the log capture information and the target capture interface; The log printing process is driven to copy the compressed log file corresponding to the log capture command.

[0007] In one possible implementation of this application, the step of driving the log printing process to copy the log compression file corresponding to the log capture command includes: Drive the log printing process to locate the log cache space corresponding to the log fetching command; Identify the target log block in the log cache space and locate the log compression space in the target log block; The log printing process is driven to capture compressed log files in the log compression space according to the log capture command.

[0008] In one possible implementation of this application, driving the log printing process to capture the compressed log file in the target compressed space according to the log capture command includes: Retrieve the log capture identifier and log capture count from the log capture command; The log printing process is driven to identify candidate compressed logs in the target compressed space according to the log capture identifier; The log printing process is driven to capture log compression files from the candidate compressed logs according to the number of logs captured.

[0009] In one possible implementation of this application, the step of transmitting the compressed log file to the log parsing terminal includes: The target log storage partition is obtained by using the target log library and the target capture interface to write the compressed log file to a preset storage partition; In response to the log transmission request, the target log compressed file corresponding to the log transmission request in the target log storage partition is transmitted to the log parsing terminal.

[0010] On the other hand, this application embodiment also provides a log capture method, which includes the following steps: In response to a log receiving request, the system receives a compressed log file transmitted by a log capture terminal. The compressed log file is a compressed log file captured by the log capture terminal based on the log capture information and the target capture interface corresponding to the target log library. The compressed log file is parsed to obtain the target log file corresponding to the target application process.

[0011] On the other hand, this application provides a log capture device, the log capture device comprising: The information acquisition module is configured to respond to a log capture request triggered by the target application process and acquire the log capture information corresponding to the log capture request. The log capture module is configured to capture the compressed log file corresponding to the log capture request based on the log capture information and the target capture interface corresponding to the target log library; The log transmission module is configured to transmit the log compressed file to the log parsing terminal, so that the log parsing terminal can parse the log compressed file to obtain the target log file corresponding to the target application process.

[0012] On the other hand, this application also provides a log capture device, the log capture device comprising: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the log fetching method or log parsing method.

[0013] On the other hand, this application also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to perform the steps in the log capture method or log parsing method.

[0014] This application responds to a log capture request triggered by a target application process, obtains log capture information corresponding to the request, captures a compressed log file corresponding to the request based on the log capture information and the target capture interface corresponding to the target log library, and transmits the compressed log file to a log parsing terminal for parsing to obtain the target log file corresponding to the target application process. This achieves the goal of directly capturing the compressed log file corresponding to the request based on the log capture information and the pre-set target capture interface of the target log library when responding to a log capture request triggered by a target application process, and transmitting the compressed log file to the log parsing terminal for log parsing. This eliminates the need to transfer logs from a log printing tool to a log viewing tool, optimizing the log capture process, reducing CPU usage and system resource consumption during log capture, and improving log capture efficiency and system stability. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a schematic diagram illustrating a scenario of the log capture method according to an embodiment of this application; Figure 2 This is a flowchart illustrating one embodiment of the log capture method in this application. Figure 3 A flowchart illustrating an embodiment of the log capture method provided in this application for capturing compressed log files; Figure 4 A flowchart illustrating one embodiment of the log parsing method provided in this application; Figure 5 A schematic diagram of the structure of one embodiment of the log capture device provided in this application; Figure 6 This is a schematic diagram of the structure of one embodiment of the log capture device provided in this application. Detailed Implementation

[0017] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of the stated features. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0019] In this application, the term "exemplary" is used to mean "serving as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.

[0020] Currently, with the rapid development of smart terminals, such as mobile terminals, they are increasingly being widely used. The stability, performance, and user experience of smart terminals are crucial during application, thus requiring anomaly monitoring. Anomaly monitoring and testing of smart terminals rely on log capture mechanisms to collect system logs. However, existing log capture processes require calling the logcat process during runtime, and the logcat process only exits after receiving all the logs. However, logcat consumes significant terminal system resources (such as CPU and socket resources), potentially leading to resource contention with foreground applications, resulting in user-perceptible performance degradation or lag, and under high load, system performance deterioration and log loss, leading to low log capture efficiency and accuracy.

[0021] Based on this, this application proposes a log capture method, apparatus, device, and computer-readable storage medium to solve the technical problems of low log capture efficiency and high log capture resource consumption in the prior art.

[0022] The log capture method in this embodiment of the invention is applied to a log capture device, which is set in a log capture equipment. The log capture equipment is equipped with one or more processors, a memory, and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the log capture method. The log capture equipment can be a smart terminal, such as a mobile phone, tablet computer, network device, and smart computer. Optionally, the log capture equipment can also be a server or a service cluster composed of multiple servers.

[0023] like Figure 1 As shown, Figure 1This is a schematic diagram illustrating a scenario of the log capture method according to an embodiment of this application. In this embodiment, the log capture scenario includes a log capture device 100 (which integrates a log capture unit) and a log parsing terminal 200. The log capture device 100 runs a computer-readable storage medium corresponding to the log capture method to execute the steps of the log capture method. The log parsing terminal 200 is a business terminal that interfaces with the log capture device 100 to obtain and parse the log compressed packages transmitted by the log capture device 100.

[0024] Understandable Figure 1 The log capture device in the log capture method scenario shown, or the device included in the log capture device, does not constitute a limitation on the embodiments of the present invention. That is, the number or type of log capture device in the log capture method scenario, or the number or type of device included in each device, does not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be considered as equivalent substitutions or derivatives of the technical solutions claimed in the embodiments of the present invention.

[0025] In this embodiment of the invention, the log capture device 100 is mainly used to: respond to a log capture request triggered by a target application process and obtain log capture information corresponding to the log capture request; Based on the log capture information and the target capture interface corresponding to the target log library, capture the compressed log file corresponding to the log capture request; The compressed log file is transmitted to a log parsing terminal, which then parses the compressed log file to obtain the target log file corresponding to the target application process.

[0026] The log capture device 100 in this embodiment of the invention can be an independent log capture device, such as a mobile phone, tablet computer, network device, server and smart computer, or a log capture network or log capture cluster composed of multiple log capture devices.

[0027] This application provides a log capture method, apparatus, device, and computer-readable storage medium, which will be described in detail below.

[0028] It will be understood by those skilled in the art that Figure 1 The application environment shown is only one application scenario related to the solution of this application and does not constitute a limitation on the application scenario of this application. Other application environments may include more than one application scenario. Figure 1 The number of more or fewer log capture devices shown, or the log capture network connectivity relationships, for example Figure 1Only one log capture device is shown in the diagram. It is understood that the scenario of this log capture method may also include one or more log capture devices, which is not limited here. The log capture device 100 may also include a storage device for storing log compressed files and other data.

[0029] It should be noted that, Figure 1 The schematic diagram of the log capture method shown is merely an example. The scenarios of the log capture method described in this embodiment are intended to more clearly illustrate the technical solutions of this embodiment and do not constitute a limitation on the technical solutions provided by this embodiment.

[0030] Based on the scenarios described above for log scraping methods, various embodiments of the log scraping method disclosed in this invention are proposed.

[0031] like Figure 2 As shown, Figure 2 This is a flowchart illustrating one embodiment of the log capture method in this application. The log capture method includes the following steps 201 to 203: 201. Respond to the log capture request triggered by the target application process and obtain the log capture information corresponding to the log capture request; The log capture method in this embodiment is applied to a log capture device. The type and number of log capture devices are not specifically limited. That is, the log capture device can be one or more smart terminals or servers capable of log capture. Specifically, the log capture device can be a log capture terminal such as a mobile phone, tablet computer, network device, or smart computer. In a specific embodiment, the log capture device can be a smartphone.

[0032] Optionally, the target application process is an active application process that requires log capture, in order to obtain log files from the target application process or other application processes under test for anomaly monitoring, problem diagnosis, and system optimization. Optionally, the target application process can also obtain log files from its own application or other application processes under test for stress testing to identify potential system risks.

[0033] Optionally, a log capture request is an operation event that drives the log capture terminal to directly capture the compressed log files required by the target application process using the target capture interface pre-set in the target log library. This eliminates the need to call the logcat process and perform cross-process log transfer during log capture, thereby reducing system resource consumption and the probability of missing files, and improving log capture efficiency and accuracy. The log capture request can be triggered by the target application process directly calling the target capture interface pre-set in the target log library within the process, achieving high-performance and high-efficiency log capture.

[0034] Optionally, the log capture information represents the limiting conditions for the target application process to capture logs, indicating the type and quantity of logs to be captured. Optionally, in one specific embodiment, the log capture information includes a log capture type and a log capture quantity. The log capture type represents the type of logs required by the target application process. The log capture quantity represents the number of logs required by the target application process. The log capture device uses this log capture information to locate the required compressed log file or target log file for subsequent log capture.

[0035] Optionally, the log capture device pre-configures a target capture interface in the target log library that can be called by any active application process. The target application process can directly call the target capture interface within the process and input log capture information into the target capture interface to generate a log capture request. After the log capture device responds to the log capture request triggered by the target application process, it captures the log compressed file corresponding to the target log capture request in subsequent steps.

[0036] 202. Based on the log capture information and the target capture interface corresponding to the target log library, capture the compressed log file corresponding to the log capture request; Optionally, after responding to a log capture request, the log capture device captures the compressed log file corresponding to the log capture request based on the log capture information corresponding to the log capture request and the target capture interface corresponding to the target log library.

[0037] Optionally, the target log library is a database used for log printing, which provides an interactive interface for the target application process and the log printing process (such as the logd process) to print logs. The target log library is pre-configured with a target crawling interface that can be called by any active application process. The target application process can directly call the target crawling interface within the process to crawl logs and obtain the log compressed file corresponding to the log crawling request.

[0038] Optionally, the target crawling interface includes a pre-configured interface for the target log library, allowing the target application process and the log printing process to interact with each other during log crawling. The target application process can directly call this target crawling interface within the process to interact with the log printing process, sending a log crawling request containing log crawling information to the log printing process. Optionally, in a specific embodiment, the target crawling interface is a newly added logcatw interface in the target log library.

[0039] Optionally, the log compressed file is compressed log data associated with the log capture information in the log capture request. Specifically, this compressed log file contains the target log file but has not been decompressed or parsed. Alternatively, in one specific embodiment, the compressed log file is a log compressed package stored in a log cache space associated with the log capture information corresponding to the target application process or the application process to be detected. Using the compressed log file as the capture object reduces the decompression overhead of the log printing process, and copying the target compressed log file consumes relatively few system resources, significantly reducing system resource usage during the log capture process.

[0040] Optionally, after receiving a log capture request, the log capture device determines the target log library corresponding to the log capture request. The target log library is pre-configured with a target capture interface that enables interaction between the target application process and the log printing process.

[0041] Optionally, the target application process in the log capture device calls the target capture interface to capture the compressed log file corresponding to the log capture request according to the log capture information. That is, the target application process sends a log capture command to the log printing process according to the target capture interface and the log capture information, and drives the log printing process to copy the compressed log file corresponding to the log capture command.

[0042] Optionally, the target application process inputs log capture information into the target capture interface to generate a log capture command containing the log capture information, and sends the log capture command to the log printing process to drive the log printing process to locate and obtain the log compressed file corresponding to the log capture command in the log cache space.

[0043] Optionally, the log capture command is a control command that contains log capture information and is used to drive the log printing process to capture the corresponding compressed log file.

[0044] Optionally, the log printing process is the log printing tool process in the system corresponding to the log capture device, used to receive log information from the user space and write it to the corresponding log cache space. Optionally, the log printing process is also used to receive log capture commands and obtain the corresponding log compressed package from the corresponding log cache space as the log compressed file corresponding to the log capture command.

[0045] Optionally, the log capture device can drive the log printing process to identify the corresponding log compression space in the log cache space according to the log capture command, and capture several log compressed packages in the log compression space as log compressed files according to the log capture command. This achieves log capture and parsing without starting the logcat process across processes during the log capture process, thereby reducing system usage and the probability of missing files during the log capture process, as well as improving log capture efficiency and accuracy.

[0046] 203. The log compressed file is transmitted to the log parsing terminal so that the log parsing terminal can parse the log compressed file to obtain the target log file corresponding to the target application process.

[0047] Optionally, after obtaining the compressed log file, the log printing process in the log capture device will also transmit the compressed log file to the log parsing terminal, so that the log parsing terminal can parse the compressed log file to obtain the target log file corresponding to the target application process, and use the target log file for anomaly monitoring, problem diagnosis, stress testing and system optimization, so as to improve system stability.

[0048] Optionally, after obtaining the compressed log file, the log capture device uses the target log library and the target capture interface to write the compressed log file to a preset storage partition, thus obtaining the target log storage partition. The target log storage partition is the storage partition used to store the compressed log file.

[0049] Optionally, the log capture device responds to the log transmission request by transmitting the target log compressed file corresponding to the log transmission request from the target log storage partition to the log parsing terminal. The log transmission request is an operation request that drives the log capture device to transmit all or part of the target log compressed file from the target log storage partition to the log parsing terminal. The target log compressed file is the log compressed file selected in the log transmission request to be transmitted.

[0050] The log capture device can transmit the compressed log file to the log parsing terminal for decompression and parsing, which can ensure the integrity of the target log file and reduce the log parsing overhead of the log capture device.

[0051] In this embodiment, the log capture device obtains log capture information corresponding to a log capture request triggered by a target application process; it then captures a compressed log file corresponding to the log capture request based on the log capture information and the target capture interface corresponding to the target log library; finally, it transmits the compressed log file to a log parsing terminal, which parses the compressed log file to obtain the target log file corresponding to the target application process. This achieves the following: when responding to a log capture request triggered by a target application process, the device directly captures the compressed log file corresponding to the log capture request based on the log capture information and the pre-set target capture interface of the target log library, and transmits the compressed log file to the log parsing terminal for log parsing. This eliminates the need to transfer logs from a log printing tool to a log viewing tool, optimizing the log capture process, reducing CPU usage and system resource consumption during log capture, and improving log capture efficiency and system stability.

[0052] like Figure 3 As shown, Figure 3 This is a flowchart illustrating an embodiment of the log capture method provided in this application for capturing compressed log files. Figure 3 In the illustrated embodiment, the log capture method further includes steps 301 to 303: 301. Drive the log printing process to locate the log cache space corresponding to the log fetching command; 302. Identify the target log block in the log cache space and locate the log compression space in the target log block; 303. Drive the log printing process to capture the compressed log file in the log compression space according to the log capture command.

[0053] Based on the above embodiments, in this embodiment, the log capture device drives the log printing process to identify the corresponding log compression space in the log cache space according to the log capture command, and captures several log compression packages in the log compression space as log compression files according to the log capture command. This achieves the goal of not needing to start the logcat process to perform log capture and parsing across processes during the log capture process, thereby reducing system usage and the probability of missing files during the log capture process, and improving log capture efficiency and accuracy.

[0054] Optionally, the log capture device drives the log printing process to locate the log cache space corresponding to the log capture command. That is, the log capture device drives the log printing process to parse the log capture command, obtain the log capture type corresponding to the command, and locate the log cache space corresponding to that type. This log cache space is a buffer associated with the target application process within the log printing process, used to receive and store log information. The log printing process contains at least one or more log cache spaces for storing different types of log cache information. Optionally, in one specific embodiment, the log cache space includes cache space areas such as the main buffer and the system buffer.

[0055] Optionally, after determining the log cache space, the log capture device identifies the target log block within the log cache space and locates the log compression space within the target log block. The target log block is the smallest storage unit in the log cache space that stores logs corresponding to the target application process. The log compression space is a compressed storage area within the target log block that stores compressed log files. In one specific embodiment, the target log block is a trunk that stores logs corresponding to the target application process. The log cache space may contain multiple log blocks. The target log block includes a first storage space and a second storage space. The first storage space is the uncompressed storage space used to store log files. The second storage space is the compressed storage space used to compress and store log files stored in the first storage space when the file size in the first storage space reaches a storage threshold.

[0056] The log capture device determines the log cache space corresponding to the target application process, locates the target log block to be captured in the log cache space, and uses the second storage space in the target log block as the target compression space.

[0057] Optionally, after determining the target compressed space, the log capture device drives the log printing process to capture compressed log files within that space according to the log capture command. Specifically, the log printing process obtains the log capture identifier and the number of logs to be captured from the log capture command, and then identifies candidate compressed logs in the target compressed space based on the log capture identifier. These candidate compressed logs are compressed log packets associated with the target application process and intended for log capture.

[0058] Optionally, after acquiring candidate compressed logs, the log capture device drives the log printing process to capture compressed log files from the candidate compressed logs according to the number of logs captured.

[0059] In this embodiment, the log capture device drives the log printing process to locate the log cache space corresponding to the log capture command, identifies the target log block in the log cache space, locates the log compression space in the target log block, and drives the log printing process to capture the compressed log file in the compressed log space according to the log capture command. This enables direct copying of the compressed log package in the compressed space without using logcat for log decompression and parsing, thereby reducing performance overhead during log capture and improving log capture efficiency.

[0060] like Figure 4 As shown, Figure 4 This is a flowchart illustrating one embodiment of the log parsing method provided in this application. Figure 4 In the illustrated embodiment, the log parsing method includes steps 401 to 402: 401. Respond to the log receiving request and receive the compressed log file transmitted by the log capture terminal; 402. Parse the compressed log file to obtain the target log file corresponding to the target application process.

[0061] Based on the above embodiments, in this embodiment, the log parsing method is applied to a log parsing device. The type and number of log parsing devices are not specifically limited; that is, the log parsing device can be one or more log parsing terminals capable of receiving, decompressing, and parsing log compressed files transmitted by a log capture device. Optionally, in a specific embodiment, the log parsing device is a smart computer or a server, etc.

[0062] Optionally, during operation, the log parsing device receives a log receiving request triggered by a log capture terminal and receives a compressed log file transmitted by the log capture terminal. This log receiving request is an operation event that drives the log parsing device to receive and parse the compressed log file transmitted by the log capture terminal. The compressed log file is a compressed log file captured by the log capture terminal based on the log capture information and the target capture interface corresponding to the target log database.

[0063] Optionally, after obtaining the compressed log file, the log parsing device parses the compressed log file to obtain the target log file corresponding to the target application process. That is, after obtaining the compressed log file, the log parsing device decompresses the compressed log file to obtain a decompressed log file, and then parses the decompressed log file into a plaintext target log file.

[0064] Optionally, after obtaining the target log file, the log parsing device may also use the target log file for anomaly monitoring, problem diagnosis, stress testing, and system optimization to improve system stability.

[0065] In this embodiment, the log parsing device receives a compressed log file transmitted by the log capture terminal in response to a log receiving request. The compressed log file is a compressed log package captured by the log capture terminal based on the log capture information and the target capture interface corresponding to the target log library. The device then parses the compressed log file to obtain the target log file corresponding to the target application process. This allows the peer end to parse the compressed log file captured by the log capture terminal to generate the target log file, thereby ensuring log integrity and reducing the capture overhead of the log capture terminal.

[0066] To better implement the log capture method in the embodiments of this application, a log capture device is also provided in the embodiments of this application, such as... Figure 5 As shown, Figure 5This is a schematic diagram of one embodiment of the log capture device provided in this application. Specifically, the log capture device 500 includes: The information acquisition module 501 is configured to respond to a log capture request triggered by the target application process and acquire the log capture information corresponding to the log capture request. The log capture module 502 is configured to capture the log compressed file corresponding to the log capture request based on the log capture information and the target capture interface corresponding to the target log library; The log transmission module 503 is configured to transmit the log compressed file to the log parsing terminal, so that the log parsing terminal can parse the log compressed file to obtain the target log file corresponding to the target application process.

[0067] In one possible implementation of this embodiment, the log capture device captures the compressed log file corresponding to the log capture request based on the log capture information and the target capture interface corresponding to the target log library, including: Determine the target log library corresponding to the log capture request, wherein the target log library has a target capture interface; The target crawling interface is invoked to crawl the compressed log file corresponding to the log crawling request according to the log crawling information.

[0068] In one possible implementation of this embodiment, the log capture device calls the target capture interface to capture the compressed log file corresponding to the log capture request according to the log capture information, including: A log capture command is sent to the log printing process based on the log capture information and the target capture interface; The log printing process is driven to copy the compressed log file corresponding to the log capture command.

[0069] In one possible implementation of this embodiment, the log capture device drives the log printing process to copy the log compressed file corresponding to the log capture command, including: Drive the log printing process to locate the log cache space corresponding to the log fetching command; Identify the target log block in the log cache space and locate the log compression space in the target log block; The log printing process is driven to capture compressed log files in the log compression space according to the log capture command.

[0070] In one possible implementation of this embodiment, the log capture device drives the log printing process to capture compressed log files in the target compressed space according to the log capture command, including: Retrieve the log capture identifier and log capture count from the log capture command; The log printing process is driven to identify candidate compressed logs in the target compressed space according to the log capture identifier; The log printing process is driven to capture log compression files from the candidate compressed logs according to the number of logs captured.

[0071] In one possible implementation of this embodiment, the log capture device transmits the compressed log file to the log parsing terminal, including: The target log storage partition is obtained by using the target log library and the target capture interface to write the compressed log file to a preset storage partition; In response to the log transmission request, the target log compressed file corresponding to the log transmission request in the target log storage partition is transmitted to the log parsing terminal.

[0072] In one possible implementation of this embodiment, the log parsing method in the log capture device includes: In response to a log receiving request, the system receives a compressed log file transmitted by a log capture terminal. The compressed log file is a compressed log file captured by the log capture terminal based on the log capture information and the target capture interface corresponding to the target log library. The compressed log file is parsed to obtain the target log file corresponding to the target application process.

[0073] In this embodiment, the log capture device obtains log capture information corresponding to a log capture request triggered by a target application process; it captures a compressed log file corresponding to the log capture request based on the log capture information and the target capture interface corresponding to the target log library; and it transmits the compressed log file to a log parsing terminal so that the log parsing terminal can parse the compressed log file to obtain the target log file corresponding to the target application process. This achieves the following: when responding to a log capture request triggered by a target application process, the device directly captures the compressed log file corresponding to the log capture request based on the log capture information corresponding to the log capture request and the pre-set target capture interface of the target log library, and transmits the compressed log file to the log parsing terminal for log parsing. This eliminates the need to transfer logs from a log printing tool to a log viewing tool, thus optimizing the log capture process, reducing CPU usage and system resource consumption during log capture, and improving log capture efficiency and system stability.

[0074] This invention also provides a log capture device, such as... Figure 6 As shown, Figure 6 This is a schematic diagram of an embodiment of the log capture device provided in this application.

[0075] The log capture device integrates any of the log capture apparatuses provided in the embodiments of the present invention, and the log capture device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor in the steps of the log capture method described in any of the embodiments of the log capture method described above.

[0076] Specifically, a log capture device may include components such as a processor 601 with one or more processing cores, a memory 602 with one or more computer-readable storage media, a power supply 603, and an input unit 604. Those skilled in the art will understand that... Figure 6 The log capture device structure shown does not constitute a limitation on the log capture device. It may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 601 is the control center of the log capture device. It connects various parts of the log capture device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 602, and by calling data stored in the memory 602, it performs various functions and processes data, thereby providing overall monitoring of the log capture device. Optionally, the processor 601 may include one or more processing cores; preferably, the processor 601 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 601.

[0077] The memory 602 can be used to store software programs and modules. The processor 601 executes various functional applications and log capture by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created based on the use of the log capture device, etc. In addition, the memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 602 may also include a memory controller to provide the processor 601 with access to the memory 602.

[0078] The log capture device also includes a power supply 603 that supplies power to the various components. Preferably, the power supply 603 can be logically connected to the processor 601 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 603 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0079] The log capture device may also include an input unit 604, which can be used to receive input numeric or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0080] Although not shown, the log capture device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 601 in the log capture device loads the executable files corresponding to the processes of one or more applications into the memory 602 according to the following instructions, and the processor 601 runs the applications stored in the memory 602 to realize various functions, as follows: Respond to the log capture request triggered by the target application process and obtain the log capture information corresponding to the log capture request; Based on the log capture information and the target capture interface corresponding to the target log library, capture the compressed log file corresponding to the log capture request; The compressed log file is transmitted to a log parsing terminal, which then parses the compressed log file to obtain the target log file corresponding to the target application process.

[0081] Therefore, embodiments of the present invention provide a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a disk, or an optical disk, etc. A computer program is stored thereon, which is loaded by a processor to execute the steps in any of the log capture methods provided in the embodiments of the present invention. For example, the computer program loaded by the processor can execute the following steps: Respond to the log capture request triggered by the target application process and obtain the log capture information corresponding to the log capture request; Based on the log capture information and the target capture interface corresponding to the target log library, capture the compressed log file corresponding to the log capture request; The compressed log file is transmitted to a log parsing terminal, which then parses the compressed log file to obtain the target log file corresponding to the target application process.

[0082] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed descriptions of other embodiments above, which will not be repeated here.

[0083] In practice, each of the above units or structures can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units or structures, please refer to the previous method embodiments, which will not be repeated here.

[0084] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0085] The log capture method provided by the embodiments of this application has been described in detail above. Specific embodiments have been used to illustrate the principle and implementation of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core idea of ​​the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation and application scope based on the idea of ​​the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A log capture method, characterized in that, The log capture method includes: Respond to the log capture request triggered by the target application process and obtain the log capture information corresponding to the log capture request; Based on the log capture information and the target capture interface corresponding to the target log library, capture the compressed log file corresponding to the log capture request; The compressed log file is transmitted to a log parsing terminal, which then parses the compressed log file to obtain the target log file corresponding to the target application process.

2. The log capture method according to claim 1, characterized in that, The step of retrieving the compressed log file corresponding to the log retrieval request based on the log retrieval information and the target retrieval interface corresponding to the target log library includes: Determine the target log library corresponding to the log capture request, wherein the target log library has a target capture interface; The target crawling interface is invoked to crawl the compressed log file corresponding to the log crawling request according to the log crawling information.

3. The log capture method according to claim 2, characterized in that, The step of calling the target crawling interface to crawl the log compressed file corresponding to the log crawling request according to the log crawling information includes: A log capture command is sent to the log printing process based on the log capture information and the target capture interface; The log printing process is driven to copy the compressed log file corresponding to the log capture command.

4. The log capture method according to claim 3, characterized in that, The process that drives the log printing process to copy the compressed log file corresponding to the log capture command includes: Drive the log printing process to locate the log cache space corresponding to the log fetching command; Identify the target log block in the log cache space and locate the log compression space in the target log block; The log printing process is driven to capture compressed log files in the log compression space according to the log capture command.

5. The log capture method according to claim 4, characterized in that, The process of driving the log printing process to capture compressed log files in the target compressed space according to the log capture command includes: Retrieve the log capture identifier and log capture count from the log capture command; The log printing process is driven to identify candidate compressed logs in the target compressed space according to the log capture identifier; The log printing process is driven to capture log compression files from the candidate compressed logs according to the number of logs captured.

6. The log capture method according to claim 1, characterized in that, The step of transmitting the compressed log file to the log parsing terminal includes: The target log storage partition is obtained by using the target log library and the target capture interface to write the compressed log file to a preset storage partition; In response to the log transmission request, the target log compressed file corresponding to the log transmission request in the target log storage partition is transmitted to the log parsing terminal.

7. A log parsing method, characterized in that, The log parsing method, applied to a log parsing terminal, includes: In response to a log receiving request, the system receives a compressed log file transmitted by a log capture terminal. The compressed log file is a compressed log package captured by the log capture terminal based on the log capture information and the target capture interface corresponding to the target log library. The compressed log file is parsed to obtain the target log file corresponding to the target application process.

8. A log capture device, characterized in that, The log capture device includes: The information acquisition module is configured to respond to a log capture request triggered by the target application process and acquire the log capture information corresponding to the log capture request. The log capture module is configured to capture the compressed log file corresponding to the log capture request based on the log capture information and the target capture interface corresponding to the target log library; The log transmission module is configured to transmit the log compressed file to the log parsing terminal, so that the log parsing terminal can parse the log compressed file to obtain the target log file corresponding to the target application process.

9. A log capture device, characterized in that, The log capture device includes: One or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the log capture method of any one of claims 1 to 6 or the steps of the log parsing method of claim 7.

10. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to execute the steps of the log capture method according to any one of claims 1 to 6 or the steps of the log parsing method according to claim 7.