A log file compression method, device, equipment and storage medium

By comparing the log file with the configuration name, the integrity of the log file is determined, which solves the problem of log file loss or corruption caused by log file compression and realizes secure compression of log files.

CN117194351BActive Publication Date: 2025-12-09BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311152514.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-07
Publication Date
2025-12-09
Estimated Expiration
2043-09-07

AI Technical Summary

Technical Problem

Existing technologies may cause log files to be lost or corrupted when compressing them, and cannot guarantee the integrity of the log files.

Method used

The system compares the log files in the log storage path with all the configured file names to determine if the log files are complete. If they are incomplete, they are not compressed; otherwise, they are compressed.

Benefits of technology

This effectively reduces the risk of log file loss or corruption, ensuring the integrity of log files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117194351B_ABST
    Figure CN117194351B_ABST
Patent Text Reader

Abstract

The application discloses a log file compression method, device and equipment and a storage medium, which can be applied to the financial field or other fields. In the method, firstly, an application name and all file configuration names corresponding to the application name and a log storage path are acquired; then, log files stored in the log storage path are compared with the all file configuration names to obtain a comparison result; then, based on the comparison result, file configuration names not included in the log storage path are written into a missing file; and if the missing file is an empty set, log files corresponding to the application name in the log storage path are compressed. Thus, by comparing the log files stored in the log storage path with the all file configuration names, it is determined whether the log files are complete, and the log files are compressed in the case that the log files are complete, so that the risk of loss or damage of the log files caused by incomplete collection of the log files can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a log file compression method and device, equipment and storage medium. BACKGROUND

[0002] Log files record necessary and valuable information of related activities of resources such as servers, workstations, firewalls and application software, which is very important for system monitoring, query, report and security audit. However, over time, these log files will accumulate more and more, occupying valuable storage space, so it is necessary to clean up and compress the log files regularly.

[0003] At present, many systems use a method based on a compression command to compress log files. This method relies on periodically executing a compression command to compress log files. However, if log files are being written, executing the compression command can cause loss or damage of log files, in addition, even if there is no writing of log files at present, due to the limitations of the compression command itself, it is not possible to distinguish whether the compressed log files are complete, which can cause missing of the compressed log files.

[0004] Therefore, how to reduce the risk of loss or damage of log files due to incomplete collection of log files has become a problem to be solved. SUMMARY

[0005] Based on the above problems, the present application provides a log file compression method, device, equipment and storage medium, which can reduce the risk of loss or damage of log files due to incomplete collection of log files.

[0006] The embodiments of the present application disclose the following technical solutions:

[0007] In a first aspect, the embodiments of the present application provide a log file compression method, which comprises:

[0008] obtaining an application name and all file configuration names and log storage paths corresponding to the application name;

[0009] comparing log files stored in the log storage paths with all the file configuration names to obtain a comparison result; the log files and the file configuration names each include at least an application name, a server address and a log type;

[0010] based on the comparison result, writing file configuration names not included in the log storage paths into missing files;

[0011] If the comparison result is that the log files stored in the log storage path include all the file configuration names or the missing files are an empty set, then compress the log files corresponding to the application name in the log storage path.

[0012] Optionally, the obtaining all the file configuration names corresponding to the application name comprises:

[0013] obtaining a configuration file; the configuration file includes an application name and log types and server addresses corresponding to the application name;

[0014] splicing the application name, the log types and the server addresses based on a preset naming format to obtain all the file configuration names corresponding to the application name.

[0015] Optionally, the obtaining the log storage path corresponding to the application name comprises:

[0016] obtaining a configuration file; the configuration file includes an application name and a log storage path; the log storage path includes an application name field;

[0017] determining the log storage path corresponding to the application name based on the application name field in the log storage path.

[0018] Optionally, the log files further include backup dates; and the compressing the log files corresponding to the application name in the log storage path comprises:

[0019] compressing the log files with the same backup date and application name in the log storage path into one compressed file based on a preset regular expression.

[0020] Optionally, after the file configuration name not included in the log storage path is written into the missing files, the method further comprises:

[0021] if the comparison times are less than or equal to a preset retry times, then comparing again the log files stored in the log storage path with all the file configuration names; updating the comparison times and the missing files;

[0022] if the comparison times are greater than the preset retry times, then storing the missing files into an error log and compressing the log files in the log storage path.

[0023] Optionally, the comparing again the log files stored in the log storage path with all the file configuration names comprises:

[0024] starting a timer when the comparison result is that the log files stored in the log storage path do not include all the file configuration names.

[0025] When the length of the timing is equal to the preset interval length, the log file stored in the log storage path is compared with all the file configuration names again.

[0026] In a second aspect, the embodiments of the present application provide a log file compression device, which comprises an obtaining module, a comparing module, a writing module and a compression module.

[0027] The obtaining module is configured to obtain an application name, all file configuration names corresponding to the application name and a log storage path.

[0028] The comparing module is configured to compare a log file stored in the log storage path with all the file configuration names to obtain a comparison result; the log file and the file configuration names both comprise at least an application name, a server address and a log type.

[0029] The writing module is configured to write, based on the comparison result, a file configuration name not included in the log storage path into a missing file.

[0030] The compression module is configured to compress, if the comparison result is that the log file stored in the log storage path includes all the file configuration names or the missing file is an empty set, the log file corresponding to the application name in the log storage path.

[0031] Optionally, the device further comprises a retry module.

[0032] The retry module is configured to, if the number of comparisons is less than or equal to a preset number of retries, compare the log file stored in the log storage path with all the file configuration names again; update the number of comparisons and the missing file; and if the number of comparisons is greater than the preset number of retries, store the missing file into an error log and compress the log file in the log storage path.

[0033] In a third aspect, the embodiments of the present application provide a log file compression device, which comprises a memory and a processor.

[0034] The memory is configured to store program code and transmit the program code to the processor.

[0035] The processor is configured to execute the steps of the log file compression method according to the program code.

[0036] In a fourth aspect, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and when the computer program runs on a log file compression device, the log file compression device executes the steps of the log file compression method according to the first aspect.

[0037] Compared with the prior art, the present application has the following beneficial effects:

[0038] The present application provides a log file compression method, wherein first, the application name and all file configuration names and log storage paths corresponding to the application name are obtained; then, the log files stored in the log storage paths are compared with all the file configuration names to obtain a comparison result; the log files and the file configuration names both at least include the application name, the server address and the log type; then, based on the comparison result, the file configuration names not included in the log storage paths are written into the missing files; if the missing files are empty sets, the log files corresponding to the application name in the log storage paths are compressed. Thus, by comparing the log files stored in the log storage paths with all the file configuration names, it can be known whether the log files stored in the log storage paths contain all the file configuration names; if not, it can be considered that the log files have not been collected completely, and the log files may be being written, so the log files are not compressed at this time to avoid risks such as loss or damage of the log files; if the missing files are empty sets, it can be considered that the log files have been collected completely, so the log files are compressed at this time, which can effectively reduce the risks such as loss or damage of the log files due to incomplete collection of the log files. BRIEF DESCRIPTION OF DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0040] Figure 1 A log file compression method flow chart is provided for the embodiments of the present application;

[0041] Figure 2 Another log file compression method flow chart is provided for the embodiments of the present application;

[0042] Figure 3 A log file compression device schematic diagram is provided for the embodiments of the present application;

[0043] Figure 4 A log file compression device structure diagram is provided for the embodiments of the present application. DETAILED DESCRIPTION

[0044] It should be noted that the log file compression method, device, equipment and storage medium provided by the present application can be used in the financial field or other fields, for example, can be used in the financial field to compress the log file generated by the application program and other application scenarios. Other fields are any field other than the financial field, for example, the field of data processing. The above are only examples and do not limit the application field of the log file compression method, device, equipment and storage medium provided by the present application.

[0045] The terms "first", "second", "third", "fourth" and the like in the specification and claims of the present application and the description of the drawings are used to distinguish different objects, not to limit a specific order.

[0046] In the embodiments of the present application, the words "as an example" or "for example" are used to represent an example, illustration or description. Any embodiment or design scheme described as "as an example" or "for example" in the embodiments of the present application should not be interpreted as more preferred or more advantageous than other embodiments or design schemes. Rather, the use of "as an example" or "for example" and the like is intended to present the relevant concept in a specific manner.

[0047] The terms used in the embodiment part of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0048] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0049] Referring to Figure 1 The figure is a log file compression method flow chart provided by the embodiments of the present application, the method comprises:

[0050] S101: obtaining the application name and the file configuration name corresponding to the application name and the log storage path.

[0051] Optionally, a configuration file can be provided in advance, and the configuration file can include, but is not limited to, the following contents: an application name, a log type corresponding to the application name, a server address corresponding to the application name, and a log storage path, etc.; based on a preset naming format, the application name, the log type, and the server address can be spliced to obtain all file configuration names corresponding to the application name; based on an application name field in the log storage path, a log storage path corresponding to the application name can be determined. The log file is a collected file; the log storage path can be obtained by splicing the application name, that is, the log storage path includes the application name field.

[0052] Specifically, the configuration file can include application names (apps) of multiple applications, and the values after apps in the configuration file can be read to separate the multiple application names by using a separator between the multiple application names, and multiple threads can process log files corresponding to the respective application names.

[0053] Optionally, the configuration file can include a corresponding relationship between the application name and the log type (type) and the server address (ip), for example, using type_${app}_regex and ip_${app}_regex configuration items to record the log type and the server corresponding to each application name. The application name, the log type, and the server address can have a one-to-many corresponding relationship, and the corresponding relationship can be read and separated into different log types and server addresses by using a separator therein, and the log types and the server addresses can be respectively placed in arrays types and ips; by setting loop nesting of the two arrays types and ips, the application name, the log type, and the server address can be spliced according to a preset naming format, for example, ${app}-${ip}-${type}.tar.gz, to obtain all file configuration names corresponding to the application name.

[0054] S102: Comparing the log file stored in the log storage path with all file configuration names to obtain a comparison result.

[0055] Exemplarily, the log file and the file configuration name both include at least an application name, a server address, and a log type; the log file stored in the log storage path can be traversed, so as to compare the log file stored in the log storage path with all the file configuration names. Optionally, the log file and the file configuration name can be consistent, or the log file includes all the contents of the file configuration name; for example, the log file is ${system_code:A1}-${app:B1}-${ip:C1}-${type:D1}-${archive_date:E1}.tar.gz, and the file configuration name is ${app:B1}-${ip:C1}-${type:D1}.tar.gz. The comparison result can be, for example, that the log file stored in the log storage path includes the file configuration name X, or that the log file stored in the log storage path does not include the file configuration name Y.

[0056] S103: It is judged whether the log file stored in the log storage path is complete, if not, the step of S104 is executed, and if yes, the step of S105 is executed.

[0057] Specifically, the log file stored in the log storage path is traversed, and if any of the file configuration names does not exist in the log storage path, it is judged that the log file stored in the log storage path is not complete. For example, if the log file is ${system_code:A1}-${app:B1}-${ip:C1}-${type:D1}-${archive_date:E1}.tar.gz, and the file configuration name is ${app:B1}-${ip:C1}-${type:D1}.tar.gz, it can be judged that the file configuration name exists in the log storage path; if the log file is ${system_code:A1}-${app:B1}-${ip:C1}-${type:D1}-${archive_date:E1}.tar.gz, and the file configuration name is ${app:B1}-${ip:C1}-${type:D2}.tar.gz, it can be judged that the file configuration name does not exist in the log storage path.

[0058] S104: Based on the comparison result, the file configuration name not included in the log storage path is written into the missing file.

[0059] Specifically, if there is a comparison result that the log file stored in the log storage path does not contain the file configuration name Y, that is, there is a file configuration name not included in the log storage path, it can be considered that the log file has not been collected completely, and the log file can be being written, at this time, the file configuration name Y (file_name) not contained in the log file stored in the log storage path can be written into the missing file missing_file.

[0060] S105: Compress the log file corresponding to the application name in the log storage path.

[0061] When the log file stored in the log storage path includes all file configuration names, that is, the missing file missing_file is an empty set, it can be considered that the log file has been collected completely, at this time, the log file can be classified and compressed according to the application name in the log file, and the log files with the same application name are compressed into one compressed file and placed in the specified path.

[0062] In the embodiment of the application, first, the application name and all file configuration names corresponding to the application name and the log storage path are obtained; then, the log file stored in the log storage path is compared with all file configuration names to obtain a comparison result; the log file and the file configuration name both include at least the application name, the server address and the log type; then, based on the comparison result, the file configuration name not included in the log storage path is written into the missing file; if the missing file is an empty set, the log file corresponding to the application name in the log storage path is compressed. Therefore, by comparing the log file stored in the log storage path with all file configuration names, it can be known whether the log file stored in the log storage path contains all file configuration names, if not, it can be considered that the log file has not been collected completely, and the log file can be being written, at this time, the log file is not compressed to avoid risks such as loss or damage of the log file; if the missing file is an empty set, it can be considered that the log file has been collected completely, at this time, the log file is compressed, which can effectively reduce the risk of loss or damage of the log file due to incomplete collection of the log file.

[0063] Referring to Figure 2 , the figure is another log file compression method flowchart provided by the embodiment of the application, the method comprises:

[0064] S201: Obtain a configuration file; the configuration file includes an application name, a log storage path, and a log type and a server address corresponding to the application name.

[0065] Optionally, the configuration file can further include a retry number max_retry_count of the comparison between the log file and the file configuration name and an interval time wait_interval between two comparisons in case that the log file is not complete, i.e., the log file stored in the log storage path does not contain all the file configuration names.

[0066] The related information of the application requiring the log file backup and the retry number and the interval time of the comparison between the log file and the file configuration name can be set in the configuration file, and the log file backup range can be flexibly and conveniently adjusted when the log file backup requirement changes, for example, the backup of the log file corresponding to the application A can be cancelled by deleting the application name A.

[0067] S202: The application name, the log type and the server address are spliced based on the preset naming format to obtain all the file configuration names corresponding to the application name.

[0068] Optionally, the file configuration name can further include a system name system_code and a backup date archive_date, for example, the naming format of the file configuration name can be ${system_code}-${app}-${ip}-${type}-${archive_date}.tar.gz.

[0069] S203: The log storage path corresponding to the application name is determined based on the application name field in the log storage path.

[0070] Optionally, the log storage path can be obtained by splicing the application name, i.e., the application name field is included in the log storage path, and one log storage path stores the log file corresponding to one application. Thus, the application name corresponding to the log storage path can be determined by identifying the application name field in the log storage path.

[0071] S204: The log file stored in the log storage path is compared with all the file configuration names to obtain a comparison result.

[0072] S205: It is determined whether the log file stored in the log storage path is complete, if not, the steps of S206-S207 are performed, and if yes, the steps in S212 are performed.

[0073] Specifically, if all the file configuration names are not included in the log storage path, the log file stored in the log storage path is not complete, and if all the file configuration names are included in the log storage path, the log file stored in the log storage path is complete.

[0074] S206: Based on the comparison result, write the file configuration name not included in the log storage path into the missing file.

[0075] S207: Determine whether the comparison times is greater than the preset retry times, if not, execute steps as S208-S210; if yes, execute steps as S211-S212.

[0076] Specifically, one round of traversal comparison between the log file and all file configuration names can be recorded as once, and the retry times max_retry_count can be preset in the configuration file, for example, the retry times can be set as 3 times. Thus, the log file stored in the log storage path is compared with all file configuration names for multiple times, which can reduce the fault misjudgment caused by the incomplete collection of the log file due to the incomplete writing of the log file into the log storage path, and provide the writing time for the log file not yet written into the log storage path.

[0077] Alternatively, the retry times retry_count and the preset retry times max_retry_count can also be compared, and if the retry_count is equal to the max_retry_count, the log file stored in the log storage path is still not collected completely, the steps as S210-S211 are executed.

[0078] S208: Start timing.

[0079] S209: When the timing duration is equal to the preset interval duration, return to execute the step of S204.

[0080] Specifically, the interval duration wait_interval can be preset in the configuration file, for example, the interval duration can be set as 5 minutes. By setting the interval duration, the writing time can be provided for the log file not yet written into the log storage path; when the timing duration is equal to the interval duration, the log file stored in the log storage path is compared with all file configuration names again, so as to determine whether the log file is collected completely after the interval duration.

[0081] Specifically, if the file configuration name not included in the log storage path changes after the comparison again, the missing file can be added or deleted accordingly to update the missing file; the comparison times is increased by one after each round of traversal comparison between the log file and all file configuration names. If the updated missing file is empty, the step as S211 is executed.

[0082] S210: Store the missing file into the error log.

[0083] Specifically, if the log files stored in the log storage path are not complete and the comparison times are greater than the retry times, it can be considered that the log files are not not complete due to not being written, and there may be other failures that cause the corresponding log files not to be generated or the log files to be damaged, and the like. At this time, the missing files missing_files are stored in the error log, and the missing log files are recorded abnormally.

[0084] S211: Compress the log files with the same backup day and application name in the log storage path into one compressed file based on a preset regular expression.

[0085] For example, a regular expression such as ${system_code}-${app}-*-${archive_date}.tar.gz can be preset, so that the log files of the same application are compressed into one compressed file according to the backup day. Alternatively, the backup day can be the natural day before the log file compression process is performed, for example, it can be the previous natural day of performing the log file compression process.

[0086] Alternatively, the process log of the log file compression method provided in the embodiment of the application can be stored, for example, in backup.log, so as to facilitate backtracking when an exception occurs.

[0087] Referring to Figure 3 The figure is a schematic diagram of a log file compression device provided in the embodiment of the application, which includes an acquisition module 301, a comparison module 302, a writing module 303, and a compression module 304.

[0088] The acquisition module 301 is configured to acquire an application name and all file configuration names corresponding to the application name and a log storage path.

[0089] The comparison module 302 is configured to compare the log files stored in the log storage path with all the file configuration names to obtain a comparison result; the log files and the file configuration names each include at least an application name, a server address, and a log type.

[0090] The writing module 303 is configured to write, based on the comparison result, the file configuration names not included in the log storage path into missing files.

[0091] The compression module 304 is configured to compress the log files corresponding to the application name in the log storage path if the comparison result is that the log files stored in the log storage path include all the file configuration names or the missing files are an empty set.

[0092] Thus, by comparing the log file stored in the log storage path with the full file configuration name, it can be known whether the log file stored in the log storage path contains the full file configuration name. If not, it can be considered that the log file is not complete, and the log file can be being written. At this time, the log file is not compressed, so as to avoid risks such as loss or damage of the log file. If the missing file is an empty set, it can be considered that the log file is complete. At this time, the log file is compressed, which can effectively reduce the risk of loss or damage of the log file due to incomplete collection of the log file.

[0093] Optionally, the obtaining module 301 comprises an obtaining unit, a splicing unit and a determining unit.

[0094] The obtaining unit is configured to obtain a configuration file. The configuration file comprises an application name, a log storage path, and a log type and a server address corresponding to the application name.

[0095] The splicing unit is configured to splice the application name, the log type and the server address based on a preset naming format, to obtain a full file configuration name corresponding to the application name.

[0096] The determining unit is configured to determine the log storage path corresponding to the application name based on an application name field in the log storage path.

[0097] Optionally, the log file further comprises a backup date. The compression module 304 is specifically configured to compress the log files with the same application name and backup date in the log storage path into one compressed file based on a preset regular expression.

[0098] Optionally, the log file compression apparatus further comprises a retry module. The retry module comprises a retry unit and a storage unit.

[0099] The retry unit is configured to, in a case where the comparison times are less than or equal to a preset retry times, compare again the log file stored in the log storage path with the full file configuration name; update the comparison times and the missing file.

[0100] The storage unit is configured to, in a case where the comparison times are greater than the preset retry times, store the missing file into an error log, and compress the log file in the log storage path.

[0101] Optionally, the retry unit is specifically configured to, in a case where the comparison times are less than or equal to the preset retry times, start timing when the comparison result is that the log file stored in the log storage path does not include the full file configuration name; compare again the log file stored in the log storage path with the full file configuration name when the timing duration is equal to a preset interval duration; and update the comparison times and the missing file.

[0102] Referring toFigure 4 Fig. 16 is a structural diagram of a log file compression device according to an embodiment of the present application, which comprises a memory 401 and a processor 402.

[0103] The memory 401 is configured to store program codes and transmit the program codes to the processor.

[0104] The processor 402 is configured to execute the steps of the log file compression method according to the instructions in the program codes.

[0105] In addition, the present application further provides a computer readable storage medium, which stores computer instructions, and when the computer instructions are run on a log file compression device, the log file compression device executes the steps of the log file compression method.

[0106] It should be noted that each embodiment in the present specification is described in a progressive manner, and the same or similar parts between each embodiment can be referred to each other, and each embodiment mainly describes the difference from other embodiments. Especially, the device and storage medium embodiments are described more simply because they are basically similar to the method embodiments, and the relevant parts can be referred to the part of the description of the method embodiments. The above described device and storage medium embodiments are only illustrative, and the units described as separate components can be or can not be physically separated, and the components indicated as units can be or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. According to the actual needs, some or all of the modules can be selected to achieve the purpose of the present embodiment. Those skilled in the art can understand and implement it without creative labor.

[0107] The above describes only one specific embodiment of the present application, but the protection scope of the present application is not limited to this. Any skilled person in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A log file compression method, characterized in that, The method includes: Obtain the application name and all file configuration names and log storage paths corresponding to the application name; Compare the log files stored in the log storage path with all the file configuration names to obtain the comparison result; both the log files and the file configuration names include at least the application name, server address, and log type. Based on the comparison results, the file configuration names not included in the log storage path will be written into the missing file; If the comparison result indicates that the log files stored in the log storage path include all the file configuration names or the missing files are an empty set, then compress the log files corresponding to the application name in the log storage path. The step of obtaining all file configuration names corresponding to the application name includes: Obtain the configuration file; the configuration file includes the application name, the log type corresponding to the application name, and the server address; By concatenating the application name, the log type, and the server address based on a preset naming format, all file configuration names corresponding to the application name are obtained.

2. The method according to claim 1, characterized in that, The step of obtaining the log storage path corresponding to the application name includes: Obtain the configuration file; the configuration file includes the application name and the log storage path; the log storage path includes the application name field; Based on the application name field in the log storage path, determine the log storage path corresponding to the application name.

3. The method according to claim 1, characterized in that, The log file also includes the backup date; compressing the log file corresponding to the application name in the log storage path includes: Log files with the same backup date and application name in the log storage path are compressed into a single compressed file based on a preset regular expression.

4. The method according to claim 1, characterized in that, After writing the file configuration name not included in the log storage path into the missing file, the method further includes: If the number of comparisons is less than or equal to the preset number of retries, then compare the log files stored in the log storage path with all the file configuration names again; update the number of comparisons and the missing files; If the number of comparisons exceeds the preset number of retries, the missing file is stored in the error log, and the log file in the log storage path is compressed.

5. The method according to claim 4, characterized in that, The re-comparison of the log files stored in the log storage path with all the file configuration names includes: The timer starts when the comparison result indicates that the log file stored in the log storage path does not include all the file configuration names. When the duration of the timing is equal to the preset interval duration, the log files stored in the log storage path are compared again with all the file configuration names.

6. A log file compression device, characterized in that, The device includes: an acquisition module, a comparison module, a writing module, and a compression module; The acquisition module is used to acquire the application name and all file configuration names and log storage paths corresponding to the application name; The comparison module compares the log files stored in the log storage path with all the file configuration names to obtain a comparison result; both the log files and the file configuration names include at least the application name, server address, and log type. The writing module is used to write the file configuration name not included in the log storage path into the missing file based on the comparison result; The compression module is used to compress the log file corresponding to the application name in the log storage path if the comparison result is that the log file stored in the log storage path includes all the file configuration names or the missing file is an empty set. The acquisition module includes an acquisition unit and a splicing unit; The acquisition unit is used to acquire a configuration file; the configuration file includes the application name and the log type and server address corresponding to the application name; The splicing unit is used to splice the application name, the log type, and the server address based on a preset naming format to obtain all file configuration names corresponding to the application name.

7. The apparatus according to claim 6, characterized in that, The device further includes: a retry module; The retry module is used to compare the log files stored in the log storage path with all the file configuration names again if the number of comparisons is less than or equal to the preset number of retries; update the number of comparisons and the missing files; if the number of comparisons is greater than the preset number of retries, store the missing files in the error log and compress the log files in the log storage path.

8. A log file compression device, characterized in that, The device includes: a memory and a processor; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of the log file compression method according to any one of claims 1-5, based on the program code.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when run on a log file compression device, performs the steps of the log file compression method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Method for recording logs with file by flexibly planning catalog

    CN101561807A

  • Log compression method and device

    CN111984618A