A log collection method, device, equipment and medium

Transmitting log files in sections through log collection equipment solves the problem of cumbersome log collection for third-party manufacturers' module problems, improves collection efficiency and convenience, and ensures security and cost reduction.

CN118540321BActive Publication Date: 2024-10-11ZHEJIANG DAHUA TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411000472.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-10-11
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

In the existing technology, when a problem occurs with a third-party manufacturer's module, the log collection process is cumbersome and inefficient, causing inconvenience to operation and maintenance personnel, and it is difficult to guarantee security.

Method used

Use the log collection device to instruct the target device to collect and store log files, and use existing compression tools to transmit log files in segments, including writing file header information in each file stream, including identification information, size before and after compression, and compression method. Ensure that the file size remains unchanged and implement segmented reading and transmission of log files.

Benefits of technology

It improves the efficiency and convenience of log collection, simplifies the operation process of operation and maintenance personnel, ensures the safe transmission and storage of log files, and reduces labor and hardware costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118540321B_ABST
    Figure CN118540321B_ABST
Patent Text Reader

Abstract

The present application relates to the field of computer technology, and in particular to a log collection method, device, equipment and medium, which are used to improve the efficiency and convenience of collecting logs of third-party manufacturers. The method includes: when the target device receives the start collection instruction of the target type log sent by the log collection device and determines that the log collection conditions are met, it starts to collect the target type log and stores at least one collected log file to the set storage component; when receiving the download instruction of the target type log sent by the log collection device, each collected log file is segmented and written into the memory, and the existing compression tool is used to write the file header information in the first file stream after each log file segmentation, and the file header information includes the identification information of the log file, the size before and after compression and the compression method, and the compression method indicates that the size of the log file is not changed; at least one file stream written into the memory each time is transmitted to the log collection device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a log collection method, device, equipment and medium. Background Art

[0002] With the development of wireless communication technology, some small terminal devices (such as cameras, etc.) can access wireless networks to achieve remote wireless communication, which places higher and higher requirements on the stability and security of small terminal devices. However, these devices may encounter various abnormalities during actual operation. Some of them are caused by problems with the modules of the equipment manufacturers, and some are caused by problems with the modules of third-party manufacturers (such as cellular modules). Therefore, it is necessary to collect the corresponding logs and send them to the corresponding manufacturers for troubleshooting.

[0003] Generally, when a module of a device manufacturer has a problem, the device manufacturer's own diagnostic tools can be used to conveniently obtain the logs of the above devices for analysis. However, when a module of a third-party manufacturer has a problem, the device operation and maintenance personnel need to use a computer to connect to the serial port of the device and collect the device logs through serial port commands. After reproducing the device problem, the collected logs are handed over to the third-party manufacturer for problem analysis. This log collection process is relatively cumbersome, with low collection efficiency and inconvenience for the operation and maintenance personnel. Summary of the invention

[0004] The present application provides a log collection method, apparatus, device and medium to improve the efficiency and convenience of collecting logs of third-party manufacturers.

[0005] The specific technical solutions provided by the embodiments of this application are as follows:

[0006] In a first aspect, an embodiment of the present application provides a log collection method, which is applied to a target device, comprising:

[0007] When receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, starting to collect the target type log, and storing at least one collected log file in a set storage component;

[0008] Upon receiving the download instruction of the target type log sent by the log collection device, each collected log file segment is written into the memory, and the existing compression tool is used to write the file header information in the first file stream after each log file segment, wherein the file header information includes the identification information of the log file, the size before and after compression, and the compression method, wherein the compression method indicates that the size of the log file is not changed;

[0009] The at least one file stream written into the memory each time is transmitted to the log collection device.

[0010] In a possible implementation, when receiving a start collection instruction for a target type log sent by a log collection device and determining that a log collection condition is met, starting to collect the target type log includes:

[0011] Upon receiving the start collection instruction of the target type log sent by the log collection device, determining whether there is a setting storage component;

[0012] If the setting storage component exists, when it is determined that the flag information does not exist in the setting storage component, the flag information is written into the setting storage component, and the target type log is started to be collected.

[0013] In a possible implementation, when receiving a start collection instruction for a target type log sent by a log collection device and determining that a log collection condition is met, starting to collect the target type log includes:

[0014] Upon receiving the start collection instruction of the target type log sent by the log collection device, determining whether there is a setting storage component;

[0015] If the setting storage component does not exist, when the setting storage component storing the flag information is installed, the target type log is started to be collected.

[0016] In a possible implementation manner, the file header information further includes verification information, and before writing each collected log file segment into the memory, the following is further included:

[0017] For each log file, the file content of the log file is read in segments, and the verification information is generated according to the file content of the log file.

[0018] In a possible implementation, the download instruction includes a single transfer file size, and writing each collected log file segment by segment into the memory includes:

[0019] According to the single transmission file size, each collected log file segment is written into the memory; wherein the size of at least one file stream written into the memory each time is not greater than the single transmission file size.

[0020] In a possible implementation, the method further includes:

[0021] During the process of collecting the target type logs, the size of the currently collected log files is sent to the log collection device.

[0022] In a second aspect, an embodiment of the present application provides a log collection method, which is applied to a log collection device, including:

[0023] In response to a start collection operation triggered for a target type log, sending a start collection instruction for the target type log to a target device;

[0024] In response to a download operation triggered for the target type log, a download instruction for the target type log is sent to the target device, so that the target device writes each collected log file segment into a memory, and uses an existing compression tool to write file header information in the first file stream after each log file segment, wherein the file header information includes identification information of the log file, the size before and after compression, and the compression method, wherein the compression method indicates that the size of the log file is not changed;

[0025] When receiving multiple file streams corresponding to at least one log file sent by the target device, the existing compression tool is used to obtain multiple file streams of the corresponding log file according to each file header information, and the multiple file streams of each log file are spliced ​​to obtain the at least one log file.

[0026] In a possible implementation, the method further includes:

[0027] receiving the size of the currently collected log files sent by the target device during the process of collecting the target type logs;

[0028] Displays the size of the currently collected log files in real time.

[0029] In a third aspect, an embodiment of the present application provides a log collection device, which is disposed in a target device and includes:

[0030] A collection module, configured to, upon receiving a start collection instruction for a target type log sent by a log collection device and determining that a log collection condition is met, start collecting the target type log, and store at least one collected log file in a set storage component;

[0031] A compression module, configured to, upon receiving a download instruction for the target type log sent by the log collection device, write each collected log file segment into a memory, and use an existing compression tool to write file header information into the first file stream after each log file segment, wherein the file header information includes identification information of the log file, the size before and after compression, and a compression method, wherein the compression method indicates that the size of the log file is not changed;

[0032] A transmission module is used to transmit the file stream written into at least one of the memories each time to the log collection device.

[0033] In a possible implementation manner, the collection module is specifically used to:

[0034] Upon receiving the start collection instruction of the target type log sent by the log collection device, determining whether there is a setting storage component;

[0035] If the setting storage component exists, when it is determined that the flag information does not exist in the setting storage component, the flag information is written into the setting storage component, and the target type log is started to be collected.

[0036] In a possible implementation manner, the collection module is specifically used to:

[0037] Upon receiving the start collection instruction of the target type log sent by the log collection device, determining whether there is a setting storage component;

[0038] If the setting storage component does not exist, when the setting storage component storing the flag information is installed, the target type log is started to be collected.

[0039] In a possible implementation manner, the file header information further includes verification information, and the device further includes:

[0040] The generating module is used to read the file content of each log file in sections and generate the verification information according to the file content of the log file.

[0041] In a possible implementation manner, the download instruction includes a single transmission file size, and the transmission module is specifically configured to:

[0042] According to the single transmission file size, each collected log file segment is written into the memory; wherein the size of at least one file stream written into the memory each time is not greater than the single transmission file size.

[0043] In a possible implementation, the device further includes:

[0044] The sending module is used to send the size of the currently collected log file to the log collection device during the process of collecting the target type log.

[0045] In a fourth aspect, an embodiment of the present application provides a log collection device, which is disposed in a log collection device, and includes:

[0046] A sending module, configured to send a start collection instruction of a target type log to a target device in response to a start collection operation triggered for the target type log;

[0047] A download module, configured to, in response to a download operation triggered for the target type log, send a download instruction for the target type log to the target device, so that the target device writes each collected log file segment into a memory, and uses an existing compression tool to write file header information in the first file stream after each log file segment, wherein the file header information includes identification information of the log file, the size before and after compression, and a compression method, wherein the compression method indicates that the size of the log file is not changed;

[0048] A decompression module is used to, when receiving multiple file streams corresponding to at least one log file sent by the target device, use the existing compression tool to obtain multiple file streams of the corresponding log file according to each file header information, and splice the multiple file streams of each log file to obtain the at least one log file.

[0049] In a possible implementation, the device further includes:

[0050] A receiving module, used for receiving the size of the currently collected log file sent by the target device during the process of collecting the target type log;

[0051] The display module is used to display the size of the currently collected log files in real time.

[0052] In a fifth aspect, an embodiment of the present application provides a computing device, comprising a processor and a memory, wherein the memory stores a program code, and when the program code is executed by the processor, the processor executes the steps of the method described in any one of the first aspect or any one of the second aspect.

[0053] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of the first aspect or any one of the second aspect is implemented.

[0054] In the seventh aspect, an embodiment of the present application provides a computer program product, including a computer program, wherein the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of the method described in any one of the first aspect or any one of the second aspect.

[0055] The embodiments of the present application have at least the following beneficial effects:

[0056] The embodiment of the present application provides a log collection method, device, equipment and medium, which can instruct the target device to collect and store the target type log through the log collection device, and download the collected log file from the target device. Specifically, when the target device has limited memory, each log file can be read into the memory in segments, and the file header information can be written into the first file stream of each log file through the existing compression tool. Since the file header information includes the size of the log file before and after compression, the size of the entire log file after compression is unknown when reading the first file stream. Therefore, the compression mode is set to no compression to determine the size of the log file after compression (i.e., equal to the size before compression); at least one file stream written into the memory each time is transmitted to the log collection device. In this way, when a problem occurs in the module of a third-party manufacturer in the target device, the operation and maintenance personnel of the target device can start log collection and download through the log collection device, thereby improving the efficiency and convenience of log collection. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0058] Figure 1 A flow chart of a log collection method provided in an embodiment of the present application;

[0059] Figure 2 A schematic diagram of a Zip format provided in an embodiment of the present application;

[0060] Figure 3 An overall logic diagram of a log collection method provided in an embodiment of the present application;

[0061] Figure 4 A flowchart of another log collection method provided in an embodiment of the present application;

[0062] Figure 5 A schematic diagram of the structure of a log collection device provided in an embodiment of the present application;

[0063] Figure 6 A schematic diagram of the composition structure of another log collection device provided in an embodiment of the present application;

[0064] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0065] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0066] In the description of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the feature. In the description of this application, unless otherwise specified, "plurality" means two or more.

[0067] In the related art, for miniaturized terminal devices, when a problem occurs with the device manufacturer's module in the device, the device manufacturer's own diagnostic tool can be used to conveniently obtain the log of the above device for analysis. However, when a problem occurs with a third-party manufacturer's module in the device, the device's operation and maintenance personnel need to use a computer to connect to the device's serial port and collect the device's logs through serial port commands. After reproducing the device's problem, the collected logs are handed over to the third-party manufacturer for problem analysis. This log collection process is relatively cumbersome, with low collection efficiency and inconvenience for the operation and maintenance personnel. In addition, when the device is placed in some high or sparsely populated areas, the safety of the operation and maintenance personnel cannot be guaranteed.

[0068] Although the logs of third-party manufacturers can also be collected through the diagnostic tools provided by the equipment manufacturer, the operation and maintenance personnel of the equipment cannot use the diagnostic tools provided by the equipment manufacturer, and can only collect logs through the equipment manufacturer, and then hand them over to the third-party manufacturer for problem location, which is undoubtedly a waste of manpower costs. In view of this, the embodiments of the present application provide a log collection method, device, equipment and medium, and the operation and maintenance personnel can instruct the target device to collect and store the target type logs through the log collection device, and download the collected log files from the target device. When downloading the log files, the segmented transmission of the log files is realized through the existing compression tools. In this way, when a problem occurs in the module of the third-party manufacturer in the target device, the operation and maintenance personnel of the target device can start log collection and downloading through the log collection device, thereby improving the efficiency and convenience of log collection.

[0069] In the embodiment of the present application, the target device may be a device of a device manufacturer, specifically a miniaturized terminal device, such as a camera, etc., which is equipped with a module of a third-party manufacturer, such as a cellular module, etc. The log collection device may be a terminal device used by a user of the target device (such as an operation and maintenance personnel), including but not limited to a mobile phone, a tablet computer, a laptop computer, a desktop computer, etc.

[0070] The log acquisition method of the present application is described in detail below with reference to the accompanying drawings and specific embodiments.

[0071] Figure 1 A log collection method provided by an embodiment of the present application is shown, and the method can be executed by a target device. Figure 1 As shown, a log collection method provided in an embodiment of the present application includes the following S101-S103:

[0072] S101. When receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, start collecting the target type log, and store at least one collected log file in a set storage component.

[0073] Among them, the log collection device can display a log collection page, which includes collection switches for various types of logs. The various types of logs include operation logs of various modules of the target device, including logs of modules of the device manufacturer and logs of modules of third-party manufacturers. When a problem occurs in a module in the target device, it is necessary to collect the log of the module for analysis. At this time, log collection can be enabled by triggering the collection switch of the module.

[0074] When the operation and maintenance personnel of the target device trigger (such as clicking) the collection switch of the target type log (i.e., the log of a certain module) on the log collection page of the log collection device, the log collection device can send a start collection instruction of the target type log to the target device. The target type log can be a log of a module of a third-party manufacturer or a log of a module of the device manufacturer. When the target device receives the start collection instruction of the target type log, it starts to collect the target type log and stores at least one collected log file to a set storage component; the set storage component can be a storage card inserted in the target device, such as an SD (Secure Digital) card, etc.

[0075] When the target device receives the target type log start collection instruction sent by the log collection device, it needs to determine whether the log collection conditions are met. The log collection conditions are explained below.

[0076] In one possible implementation, upon receiving an instruction to start collecting target type logs sent by a log collection device, the target device can determine whether a setting storage component exists; if a setting storage component exists, upon determining that no flag information exists in the setting storage component, the flag information is written into the setting storage component to start collecting the target type logs.

[0077] In addition, the user can also write the flag information into the setting storage component in advance when inserting the setting storage component into the target device. When the target device receives the instruction to start collecting the target type log sent by the log collection device and determines that the log collection conditions are met, if it is determined that the flag information exists in the setting storage component, it will start collecting the target type log.

[0078] Among them, the flag information can be a flag file or a flag folder, and the flag information is equivalent to the flag bit for starting log collection. When the log collection device is turned on, the collection switch is turned on by default. When there is a setting storage component in the target device, the user can instruct the target device to create flag information in the setting storage component by first turning off the collection switch of the target type log in the log collection device and then turning on the collection switch, thereby starting log collection. During the log collection process, the user can instruct the target device to stop log collection by turning off the collection switch, that is, to delete the flag information created in the setting storage component. After that, when the user turns on the collection switch again, the target device can be instructed to create flag information when the setting storage component exists.

[0079] In another possible implementation, when the target device receives an instruction to start collecting target type logs sent by the log collection device, it determines whether there is a setting storage component; if there is no setting storage component, then when installing the setting storage component that stores the flag information, it starts collecting the target type logs; or, when installing the setting storage component, if it is determined that the flag information does not exist in the setting storage component, it writes the flag information into the setting storage component and starts collecting the target type logs.

[0080] Among them, when the collection switch of the target type log in the log collection device is turned on, if the setting storage component does not exist in the target device, the log collection can be enabled by writing the flag information into the setting storage component in advance and then inserting the setting storage component into the target device.

[0081] In the embodiment of the present application, when the collection switch in the log collection device is triggered, the target device can start log collection when it is determined that there is a setting storage component and the flag information is stored therein. In this way, only the user who uses the log collection device can start log collection, ensuring the security of log collection, and at the same time, it can ensure that the collected logs are stored in the setting storage component.

[0082] It is understandable that in the embodiment of the present application, a dual switch mode is used to enable log collection, a main switch and a small switch, wherein the main switch is a collection switch that can be operated in the log collection device, and the small switch is identification information (such as a flag file or folder). The user can turn on and off the log collection function by operating the collection switch in the log collection device.

[0083] In some embodiments, in order to facilitate users to observe in real time whether log collection is turned on and the size of the collected log files, the target device can send the size of the currently collected log files to the log collection device during the process of collecting target type logs, so that the log collection device can display the size of the currently collected log files in real time.

[0084] Specifically, each log file can be named with the date plus the log type. Since the file paths and file formats of logs of different types (such as different manufacturers) are different, a specific folder can be used to store each type of log in the storage setting component, and all files in the folder are recursively searched during the search.

[0085] S102. When receiving a download instruction for a target type log sent by a log collection device, each collected log file segment is written into the memory, and an existing compression tool is used to write file header information into the first file stream after each log file segment. The file header information includes identification information of the log file, the size before and after compression, and the compression method. The compression method indicates that the size of the log file is not changed.

[0086] Among them, download controls for various types of logs can be displayed in the log collection page of the log collection device. When the user triggers the download control of the target type log, the log collection device can send a download instruction for the target type log to the target device. When the target device receives the download instruction, it can search for the target type log from a specific folder in the set storage component, specifically one or more log files.

[0087] Specifically, the user can select the log type and date to be downloaded. The download instruction sent by the log collection device can include the target log type and date. After the target device parses the download instruction, it determines the target log type and date to be downloaded, and then recursively searches all file paths under the folder corresponding to the target log type in the set storage component to obtain one or more log files to be downloaded.

[0088] Considering that the target device has limited memory and the log file is too large, it may not be possible to directly read a log file into the memory, and the file content of each log file can only be read in segments. In the related art, when collecting the logs of the equipment manufacturer, when the target device transmits multiple log files, the diagnostic tool of the equipment manufacturer can be used to add a header and a tail as well as verification information to each log file, so as to transmit each log file in segments to the log collection device of the operation and maintenance personnel. Since the diagnostic tool of the equipment manufacturer is internally controlled and cannot be used by the operation and maintenance personnel, the operation and maintenance personnel need to send the file streams of the received multiple log files to the equipment manufacturer, and the equipment manufacturer uses the diagnostic tool to process the file streams of the multiple log files. If the target device still uses the diagnostic tool of the equipment manufacturer to transmit multiple log files of a third-party manufacturer, the operation and maintenance personnel need to send the file streams of the received multiple log files to the equipment manufacturer, and the equipment manufacturer uses the diagnostic tool to process the file streams of the multiple log files and then send them to the third-party manufacturer, which is extremely inconvenient.

[0089] Based on this, the target device in the embodiment of the present application uses an existing compression tool to implement segmented processing of log files, so that the log collection device of the operation and maintenance personnel can use the existing compression tool to process multiple file streams of the received log files. The following is an example of a file compression tool in Zip format.

[0090] When the log file is transmitted using the Zip format, due to the need for CRC (Cyclic Redundancy Check) check and file compression, the entire log file needs to be read into the memory of the target device each time. In actual applications, the memory of the target device may not be able to meet this requirement. Therefore, the Zip format file in the embodiment of the present application is cropped so that it can meet the requirement of segmented transmission of the log file.

[0091] like Figure 2 As shown in FIG. 1 , the Zip format is mainly composed of a data area, a core directory record area, and a core directory record tail area, wherein the data area contains the local file header, file data, and file description of each file. For example, local file header 1 corresponds to a file, and the file content of the file is file data 1. Local file header 2 corresponds to another file, and the file content of the file is file data 2. The local file header contains the file identification header, file information, compression method, size before and after compression, and verification information. The core directory record area contains the core directory of each file, which contains the location of the local file header.

[0092] In the embodiment of the present application, since each log file needs to be transmitted in segments, it is necessary to write the file header information (i.e., the local file header) in the first file stream of each log file. However, since the local file header includes the size of the log file before and after compression, when reading the first file stream of the log file, the file size of the entire log file after compression is not known. In order to solve this problem, the compression mode is set to not perform file compression in the file header information, for example, the compression mode is set to a set value (such as 0), so that the size of the log file before and after compression can be kept consistent. The embodiment of the present application reduces the time consumption of file operations by reducing the operation of compressing the log file.

[0093] In one possible implementation, when an existing compression tool is used to segment log files, each log file needs to be CRC-checked before the file is decompressed. Therefore, the checksum information of each log file needs to be written into the file header information of each log file. This requires that before each log file is transmitted, the log file needs to be read once in segments, and the checksum information (such as CRC value) of the entire log file needs to be calculated and filled into the file header information.

[0094] Therefore, before writing each collected log file segment into the memory in the above S102, the file content of each log file is read segment by segment, and verification information is generated according to the file content of the log file.

[0095] In a possible implementation, the download instruction sent by the log collection device also includes the single transfer file size. When the target device writes each collected log file segment into the memory, it can write each collected log file segment into the memory according to the single transfer file size; wherein the size of at least one file stream written to the memory each time is not greater than the single transfer file size. Specifically, when multiple log files are collected, the target device can write the multiple log files segmented into the memory in sequence, and write the file header information in the first file stream of each log file.

[0096] In the embodiment of the present application, the target device can perform segmented transmission of the log file according to the single transmission file size of the log collection device to meet the transmission requirements of the log collection device.

[0097] S103: Transmit at least one file stream written into the memory each time to a log collection device.

[0098] When the target device receives the download instruction sent by the log collection device, it will return the download address, such as URL (Uniform Resource Locator), to the log collection device, so that the log collection device can send a log acquisition request to the target device according to the download address. The target device will transfer at least one file stream written to the memory each time to the log collection device according to the log acquisition request.

[0099] After the target device has transmitted at least one log file, the log collection device receives multiple file streams corresponding to the at least one log file, and decompresses the multiple file streams using an existing compression tool to obtain at least one log file.

[0100] In the embodiment of the present application, the target device can be instructed to collect and store the target type logs through the log collection device, and the collected log files can be downloaded from the target device. Specifically, when the target device has limited memory, each log file can be read into the memory in segments, and the file header information can be written into the first file stream of each log file through the existing compression tool. Since the file header information includes the size of the log file before and after compression, the size of the entire log file after compression is unknown when reading the first file stream. Therefore, the compression mode is set to no compression to determine the size of the log file after compression (i.e., equal to the size before compression); at least one file stream written into the memory each time is transmitted to the log collection device. In this way, when a problem occurs in the module of a third-party manufacturer in the target device, the operation and maintenance personnel of the target device can start log collection and downloading through the log collection device, thereby improving the efficiency and convenience of log collection.

[0101] Combine the following Figure 3 The overall logic of the log collection method of the embodiment of the present application is introduced.

[0102] like Figure 3As shown, the device side is the target device, the client side is the log collection device, and the client side has the functions of log switch, log display and log download. When the log switch function of the client side is turned on (i.e., the main switch is turned on), the device side can start log collection in two possible ways. One way is to determine whether there is an SD card (i.e., set the storage component). If so, create a flag file (i.e., flag information) in the SD card and start log collection; the other way is that when the SD card is inserted, if it is determined that the main switch of the client side is turned on, it is determined whether there is a flag file in the SD card. If there is a flag file, log collection is started. During the log collection process of the device side, the size of the currently collected log file can be sent to the client side, so that the client side determines that log collection has been turned on and displays the size of the collected log file. When the client side turns on the log download function, the device side pushes the log and transmits at least one collected log file to the client side in a streaming segmented manner.

[0103] Based on the same inventive concept, the present application embodiment provides a log collection method, which is applied to a log collection device, such as Figure 4 As shown, the method includes the following S401-S403:

[0104] S401: In response to a start collection operation triggered for a target type log, a start collection instruction for the target type log is sent to a target device.

[0105] Among them, the log collection device can display a log collection page, which includes collection switches for various types of logs. The various types of logs include operation logs of various modules of the target device, including logs of modules of the device manufacturer and logs of modules of third-party manufacturers. When a problem occurs in a module in the target device, it is necessary to collect the log of the module for analysis. At this time, log collection can be turned on by triggering the collection switch of the module. The log collection device responds to the trigger operation of the collection switch for the module and sends a collection start instruction for the target type log (i.e., the log of the module) to the target device.

[0106] S402. In response to a download operation triggered for a target type log, a download instruction for the target type log is sent to a target device, so that the target device writes each collected log file segment into a memory, and uses an existing compression tool to write file header information in the first file stream after each log file segment. The file header information includes identification information of the log file, the size before and after compression, and the compression method. The compression method indicates that the size of the log file will not be changed.

[0107] Among them, download controls for various types of logs can be displayed in the log collection page of the log collection device. When the user triggers the download control of the target type log, the log collection device can send a download instruction for the target type log to the target device. When the target device receives the download instruction, it can search for the target type log from a specific folder in the set storage component, specifically one or more log files, and then write each collected log file segment into the memory, and use existing compression tools to write file header information in the first file stream after each log file segment.

[0108] In a possible implementation, the download instruction sent by the log collection device to the target device also includes a single transfer file size. When the target device writes each collected log file segment into the memory, it can write each collected log file segment into the memory according to the single transfer file size; wherein the size of at least one file stream written to the memory each time is not greater than the single transfer file size.

[0109] S403. When receiving multiple file streams corresponding to at least one log file sent by the target device, use an existing compression tool to obtain multiple file streams of the corresponding log file according to each file header information, and splice the multiple file streams of each log file to obtain at least one log file.

[0110] Specifically, after sending a download instruction to the target device, the log collection device can receive the download address returned by the target device, and send a log acquisition request to the target device based on the download address. The target device sends at least one file stream written to the memory each time to the log collection device. After the download is completed, the log collection device obtains multiple file streams corresponding to at least one log file, that is, multiple file streams processed by an existing compression tool. Therefore, by decompressing the multiple file streams through the existing compression tool, at least one log file can be obtained. Specifically, according to the identification information in each file header information and the size before and after compression, multiple file streams of the corresponding log file can be split from all file streams, and then the multiple file streams of each log file are spliced ​​to obtain each log file.

[0111] In addition, each file header information also includes verification information. After obtaining each log file, the log collection device can also calculate the verification information corresponding to the file content of each log file, and compare the calculated verification information with the verification information in the file header information. If they are consistent, it is determined that the log file transmission is successful.

[0112] In a possible implementation, in order to facilitate users to observe in real time whether log collection is enabled and the size of the collected log files, the log collection device can also receive the size of the currently collected log files sent by the target device during the process of collecting the target type logs, and display the size of the currently collected log files in real time. Each log file can be named as a date plus a log type.

[0113] In the embodiment of the present application, the target device uses an existing compression tool (i.e., a public tool) as a carrier of the log file, thereby realizing streaming segmented transmission of multiple log files. After the log collection device receives multiple file streams corresponding to the multiple log files, the existing compression tool can be directly used to process the multiple file streams without the need for secondary processing by the device manufacturer, thereby reducing hardware and labor costs; secondly, users (such as operation and maintenance personnel) can conveniently collect logs through the collection switch in the log collection device, which can not only protect the user's privacy, but also facilitate the later maintenance of the target device.

[0114] Based on the same inventive concept, an embodiment of the present application also provides a log collection device, the principle of which is similar to the method on the target device side of the above embodiment. Therefore, the implementation of the device can refer to the implementation of the above method, and the repeated parts will not be repeated.

[0115] like Figure 5 As shown, a log collection device 500 provided in an embodiment of the present application is provided in a target device, including:

[0116] The collection module 501 is used to start collecting the target type logs when receiving the start collection instruction of the target type logs sent by the log collection device and determining that the log collection conditions are met, and store at least one collected log file in the set storage component;

[0117] The compression module 502 is used to write each collected log file segment into the memory when receiving the download instruction of the target type log sent by the log collection device, and use the existing compression tool to write the file header information in the first file stream after each log file segment. The file header information includes the identification information of the log file, the size before and after compression, and the compression method. The compression method indicates that the size of the log file is not changed;

[0118] The transmission module 503 is used to transmit the file stream written into the memory each time to the log collection device.

[0119] In a possible implementation, the collection module 501 is specifically used for:

[0120] When receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, determining whether a setting storage component exists;

[0121] If the setting storage component exists, when it is determined that the flag information does not exist in the setting storage component, the flag information is written into the setting storage component, and the target type log is started to be collected.

[0122] In a possible implementation, the collection module 501 is specifically used for:

[0123] When receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, determining whether a setting storage component exists;

[0124] If the setting storage component does not exist, when the setting storage component storing the flag information is installed, the collection of the target type log starts.

[0125] In a possible implementation manner, the file header information further includes verification information, and the device further includes:

[0126] The generation module is used to read the file content of each log file in segments and generate verification information according to the file content of the log file.

[0127] In a possible implementation, the download instruction includes a single transmission file size, and the transmission module 503 is specifically configured to:

[0128] Each collected log file is segmented and written into the memory according to the single transmission file size; wherein the size of at least one file stream written into the memory each time is not greater than the single transmission file size.

[0129] In a possible implementation, the device further includes:

[0130] The sending module is used to send the size of the currently collected log file to the log collection device during the process of collecting the target type log.

[0131] Based on the same inventive concept, an embodiment of the present application also provides a log collection device, the principle of which is similar to the method on the log collection device side of the above embodiment. Therefore, the implementation of the device can refer to the implementation of the above method, and the repeated parts will not be repeated.

[0132] like Figure 6 As shown, a log collection device 600 provided in an embodiment of the present application is provided in a log collection device, including:

[0133] The sending module 601 is used to send a start collection instruction of the target type log to the target device in response to the start collection operation triggered for the target type log;

[0134] The download module 602 is used to respond to the download operation triggered for the target type log, send the download instruction of the target type log to the target device, so that the target device writes each collected log file segment into the memory, and uses the existing compression tool to write the file header information in the first file stream after each log file segment. The file header information includes the identification information of the log file, the size before and after compression, and the compression method. The compression method indicates that the size of the log file is not changed;

[0135] The decompression module 603 is used to use existing compression tools to obtain multiple file streams of the corresponding log file according to each file header information when receiving multiple file streams corresponding to at least one log file sent by the target device, and splice the multiple file streams of each log file to obtain at least one log file.

[0136] In a possible implementation, the device further includes:

[0137] The receiving module is used to receive the size of the currently collected log file sent by the target device during the process of collecting the target type log;

[0138] The display module is used to display the size of the currently collected log files in real time.

[0139] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, which can be a target device or a log collection device in the method embodiment of the present application. Since the principle of solving the problem by the electronic device is similar to the method in the embodiment of the present application, the implementation of the electronic device can refer to the embodiment of the method, and the repeated parts will not be repeated.

[0140] like Figure 7 As shown, the computing device includes a processor 700, a memory 701 and a communication interface 702, wherein the processor 700 communicates with the communication interface 702 and the memory 701 via a communication bus 703; the memory 701 is used to store programs executable by the processor 700, and the processor 700 is used to read the programs in the memory 701 and execute the steps of any log collection method in the above-mentioned embodiments.

[0141] The communication bus 703 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 702 is used for communication between the computing device and other devices. The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0142] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processing processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.

[0143] Based on the same inventive concept, an embodiment of the present application also provides a computer storage medium, in which a computer program executable by a processor is stored. When the program runs on the processor, the processor executes the steps of any log collection method in the above embodiments.

[0144] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CDs, DVDs, BDs, HVDs, etc. and semiconductor storage such as ROMs, EPROMs, EEPROMs, non-volatile memories (NAND FLASH), solid-state drives (SSDs), etc.

[0145] In another embodiment provided by the present application, a computer program product including instructions is also provided. When the computer program product is called and executed by an electronic device, the electronic device can execute the steps of any log collection method in the above embodiments.

[0146] The computer program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0147] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0148] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0149] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0151] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A log collection method, characterized in that: Applied to target devices, including: When receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, starting to collect the target type log, and storing at least one collected log file in a setting storage component; wherein the log collection condition includes: the setting storage component exists, and flag information exists in the setting storage component; Upon receiving the download instruction of the target type log sent by the log collection device, each collected log file segment is written into the memory, and the existing compression tool is used to write the file header information in the first file stream after each log file segment, wherein the file header information includes the identification information of the log file, the size before and after compression, and the compression method, wherein the compression method indicates that the size of the log file is not changed; The at least one file stream written into the memory each time is transmitted to the log collection device.

2. The method according to claim 1, characterized in that: The step of receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, starting to collect the target type log includes: Upon receiving the start collection instruction of the target type log sent by the log collection device, determining whether the setting storage component exists; If the setting storage component exists, when it is determined that the flag information does not exist in the setting storage component, the flag information is written into the setting storage component, and the target type log is started to be collected.

3. The method according to claim 1, characterized in that The step of receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, starting to collect the target type log includes: Upon receiving the start collection instruction of the target type log sent by the log collection device, determining whether the setting storage component exists; If the setting storage component does not exist, when the setting storage component storing the flag information is installed, the target type log is started to be collected.

4. The method according to any one of claims 1 to 3, characterized in that The file header information also includes verification information. Before writing each collected log file segment into the memory, the following is also included: For each log file, the file content of the log file is read in segments, and the verification information is generated according to the file content of the log file.

5. The method according to any one of claims 1 to 3, characterized in that: The download instruction includes the size of the file to be transferred at a time, and the step of writing each collected log file into the memory in segments includes: According to the single transmission file size, each collected log file segment is written into the memory; wherein the size of at least one file stream written into the memory each time is not greater than the single transmission file size.

6. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: During the process of collecting the target type logs, the size of the currently collected log files is sent to the log collection device.

7. A log collection method, characterized in that: Applicable to log collection devices, including: In response to the start collection operation triggered for the target type log, sending the start collection instruction of the target type log to the target device, so that the target device starts to collect the target type log when it is determined that the log collection condition is met, and stores at least one collected log file in the setting storage component; wherein the log collection condition includes: the setting storage component exists, and the setting storage component has flag information; In response to a download operation triggered for the target type log, a download instruction for the target type log is sent to the target device, so that the target device writes each collected log file segment into a memory, and uses an existing compression tool to write file header information in the first file stream after each log file segment, wherein the file header information includes identification information of the log file, the size before and after compression, and the compression method, wherein the compression method indicates that the size of the log file is not changed; When receiving multiple file streams corresponding to at least one log file sent by the target device, the existing compression tool is used to obtain multiple file streams of the corresponding log file according to each file header information, and the multiple file streams of each log file are spliced ​​to obtain the at least one log file.

8. The method according to claim 7, characterized in that The method further comprises: receiving the size of the currently collected log files sent by the target device during the process of collecting the target type logs; Displays the size of the currently collected log files in real time.

9. A log collection device, characterized in that: Set in the target device, including: A collection module, configured to, upon receiving a start collection instruction of a target type log sent by a log collection device and determining that a log collection condition is met, start collecting the target type log, and store at least one collected log file in a setting storage component; wherein the log collection condition includes: the setting storage component exists, and flag information exists in the setting storage component; A compression module, configured to, upon receiving a download instruction for the target type log sent by the log collection device, write each collected log file segment into a memory, and use an existing compression tool to write file header information into the first file stream after each log file segment, wherein the file header information includes identification information of the log file, the size before and after compression, and a compression method, wherein the compression method indicates that the size of the log file is not changed; A transmission module is used to transmit the file stream written into at least one of the memories each time to the log collection device.

10. A log collection device, characterized in that: Set in the log collection device, including: A sending module, configured to send a start-collection instruction of the target type log to a target device in response to a start-collection operation triggered for the target type log, so that the target device starts to collect the target type log when determining that a log collection condition is met, and stores at least one collected log file in a setting storage component; wherein the log collection condition includes: the setting storage component exists, and flag information exists in the setting storage component; A download module, configured to, in response to a download operation triggered for the target type log, send a download instruction for the target type log to the target device, so that the target device writes each collected log file segment into a memory, and uses an existing compression tool to write file header information in the first file stream after each log file segment, wherein the file header information includes identification information of the log file; A decompression module is used to, when receiving multiple file streams corresponding to at least one log file sent by the target device, use the existing compression tool to distinguish different log files according to the identification information in each file header information, and splice the multiple file streams of each log file to obtain the at least one log file.

11. An electronic device, characterized in that: It includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the method described in any one of claims 1 to 6 or any one of 7 to 8.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 6 or any one of claims 7 to 8 are implemented.

13. A computer program product, characterized in that The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of the method described in any one of claims 1 to 6 or any one of 7 to 8.

Citation Information

Patent Citations

  • System and method for remotely collecting, retrieving and displaying application system logs

    CN103914485A

  • Packaged downloading method based on Zip compression mode

    CN105306531A

  • Optimization method for compressed uploading of self-service terminal log

    CN108011966A

  • Log compression storage method and electronic device

    CN112965934A

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

    CN112988247A