Log file storage method and system, electronic device, and storage medium
By obtaining and optimizing the time information and log content marking information in the log file in real time, the problem of low efficiency in log file storage optimization in the existing technology is solved, and more efficient log storage space utilization and optimization effect is achieved, reducing R&D and operation costs.
Patent Information
- Application Number
- PCT/CN2024/112984
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-13
- Filing Date
- 2024-08-19
- Publication Date
- 2025-06-19
AI Technical Summary
In the prior art, log file storage optimization efficiency is low and optimization effect is poor, resulting in low utilization of log storage space, making it difficult to locate and solve problems, and increasing R&D and operation costs.
By obtaining log files in the log database in real time, extracting time information and log content marking information, and optimizing this information based on defined time optimization rules and log content marking optimization rules, shortening its manifestation form, thereby improving the utilization of log storage space.
It improves the utilization rate of log storage space, saves more effective logs, extends the log time, is conducive to system development and debugging and vehicle operation, and reduces R&D and operation costs.
Smart Images

Figure CN2024112984_19062025_PF_FP_ABST
Abstract
Description
Log file storage method, system, electronic device and storage medium Technical Field
[0001] The present invention relates to the field of storage technology, and in particular to a log file storage method, system, electronic device and storage medium. Background Art
[0002] The logging system is a critical foundational subsystem of the in-vehicle system. Unlike other system development methods, such as PC and web application development, which can be debugged online at any time, in-vehicle systems are primarily developed in the laboratory during the early stages of development. Subsequent development and operations are isolated from the development environment. For example, in scenarios like road testing and actual user driving, online debugging is impossible. This makes it difficult to locate or restore issues when they arise. In this case, system and application logs can provide critical information to assist in locating and restoring the problem. Without logs, development efficiency would be significantly reduced and even the entire development process would become difficult to carry out.
[0003] The logging system is a low-level module that end users don't directly use, and its use of system resources is relatively limited. As part of the entire vehicle computer system, the logging system consumes system resources such as CPU, memory, and storage space during operation. Furthermore, as a "non-functional module," the logging system isn't directly visible to users, but rather provides support for other system services or applications. This requires the logging module to minimize system resource usage or operate more efficiently within limited system resources.
[0004] In the prior art, a commonly used solution is to limit the number of log files and the upper limit of the size of a single file, that is, to limit the total size of the log files. When the log content exceeds the limit, the oldest log file will be overwritten, which is a circular overwriting strategy.
[0005] Patent document CN111538704A discloses a log optimization method, apparatus, device and storage medium. The log optimization method extracts the attribute features and attribute values of each log in the log file set, classifies them, obtains an attribute set, constructs a tree diagram, and then selects the target attribute features. The attribute values under the target attribute features are abstracted according to a preset abstract summary algorithm to obtain a key summary of the log file set, and the key summary is used to replace the log file set stored in the current system. Finally, the key summary is analyzed to improve the efficiency of abnormal diagnosis.
[0006] The above-mentioned prior art solutions have the problems of cumbersome optimization process and low optimization efficiency, which is not conducive to system development and also brings the following problems:
[0007] 1. Given log storage space, saving fewer logs for a shorter period of time is not conducive to locating and solving problems.
[0008] 2. Subsequent operations will require remote capture of vehicle logs, which will also involve network transmission, cloud storage, and automated content analysis. Inefficient log storage (redundant or invalid log content) will result in increased bandwidth usage, longer transmission times, increased error rates, larger cloud storage requirements, and lower automated analysis efficiency.
[0009] 3. Overall, the cost of R&D and operations will increase, and the cost will continue to increase over time.
[0010] 4. If the compression algorithm processes logs dynamically, it will not only occupy a lot of resources (CPU, memory, etc.), but also make it impossible to directly view the log content.
[0011] Therefore, how to provide a log file storage method to improve log optimization efficiency and optimization effect is a technical problem to be solved by those skilled in the art.
[0012] Summary of the Invention
[0013] In order to solve the technical problems of low log file storage optimization efficiency and poor optimization effect in the prior art, the present invention provides a log file storage method, system, electronic device and storage medium.
[0014] A log file storage method provided for achieving the purpose of the present invention includes:
[0015] Responding to a log storage optimization request, obtaining log files contained in a log database in real time;
[0016] Extracting time information and log content marking information contained in the log file;
[0017] Based on the defined time optimization rules and log content mark optimization rules, the time information and the log content mark information are optimized to shorten the presentation of the time information and the content mark information;
[0018] The optimized time information and log content marking information are updated and stored in the log file.
[0019] In some specific embodiments, the defined time optimization rules specifically include:
[0020] The time information is optimized based on the time difference between the time information.
[0021] In some specific embodiments, the defined log content marking optimization rules specifically include:
[0022] Establishing a mapping relationship value corresponding to the log content tag;
[0023] The log content tag is optimized based on the mapping relationship value.
[0024] In some specific embodiments, the time information is optimized based on defined time optimization rules to shorten the presentation of the time information, specifically including:
[0025] Determine whether the current log is the first record of the log file;
[0026] When the log is not the first record of the log file, calculating the difference between the time information of the current log and the time information of the previous log;
[0027] The time information of the current log is modified according to the difference in the time information to shorten the representation of the time information.
[0028] In some specific embodiments, when the log is the first record of the log file, the time information of the log is not optimized and the complete time information is retained;
[0029] Calculate the difference between the time information of the log and the time information of the next log;
[0030] The time information of the next piece is modified according to the difference in the time information to shorten the representation of the time information.
[0031] In some specific embodiments, based on the defined log content tag optimization rules, the log content tag information is optimized to shorten the presentation of the content tag information, specifically including:
[0032] Establishing a mapping relationship value corresponding to the log content tag;
[0033] Sequentially save the mapping relationship values corresponding to the log content tags in the log database;
[0034] According to the mapping relationship values, the log content tags corresponding to the mapping relationship values are modified to shorten the expression form of the log content tags.
[0035] In some specific embodiments, after modifying the log content tags corresponding to the mapping relationship values to shorten the representation of the log content tags based on the mapping relationship values, the method further includes:
[0036] When a new log is received, determining whether there is the mapping relationship value corresponding to the log content tag of the new log;
[0037] When the mapping relationship value exists, modifying the log content tag of the new log to shorten the expression form of the log content tag;
[0038] When the mapping relationship value does not exist, the mapping relationship value corresponding to the log content tag of the new log is established, and the log content tag of the new log is modified according to the established mapping relationship value to shorten the expression form of the log content tag.
[0039] Based on the same concept, the present invention also provides a log file storage system, comprising:
[0040] a log file acquisition module configured to acquire log files contained in the log database in real time in response to a log storage optimization request;
[0041] A log file extraction module is configured to extract time information and log content tag information contained in the log file;
[0042] a log file optimization module configured to optimize the time information and the log content tag information based on defined time optimization rules and log content tag optimization rules, so as to shorten the presentation of the time information and the content tag information;
[0043] The log file storage module is configured to update and store the optimized time information and log content marking information in the log file.
[0044] Based on the same concept, the present invention also provides an electronic device, comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the above-mentioned log file storage method.
[0045] Based on the same concept, the present invention also provides a computer-readable storage medium, characterized in that it stores a computer program that can be executed by an electronic device, and when the computer program runs on the electronic device, the electronic device executes the steps of the above-mentioned log file storage method.
[0046] Compared with the prior art, the present invention has the following beneficial effects:
[0047] The present invention discloses a log file storage method, system, electronic device and storage medium, which can improve the utilization rate of log storage space, store more valid logs in the same space, and increase the log storage time accordingly, which is beneficial to subsequent system development and debugging and subsequent vehicle operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] FIG1 is a flow chart of a log file storage method according to some specific embodiments of the present invention;
[0049] FIG2 is a flow chart of a log file storage method in some applications of the present invention;
[0050] FIG3 is a flow chart of a log file storage method of the present invention in other applications;
[0051] FIG4 is a schematic structural diagram of a log file storage system in some specific embodiments of the present invention;
[0052] FIG5 is a schematic structural diagram of an electronic device according to some specific embodiments of the present invention. DETAILED DESCRIPTION
[0053] To make the objectives, technical solutions, and advantages of this application more clear, this application will be further described in detail below with reference to the accompanying drawings. Obviously, the embodiments described are only some 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 making any creative efforts are within the scope of protection of this application.
[0054] The terms used in the examples of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a," "the," and "the" used in the examples of this application and the appended claims are also intended to include plural forms, and unless the context clearly indicates otherwise, "a plurality" generally includes at least two.
[0055] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0056] It should be understood that although the terms first, second, third, etc. may be used to describe in the embodiments of the present application, these descriptions should not be limited to these terms. These terms are only used to distinguish the descriptions. For example, without departing from the scope of the embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first.
[0057] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to the determination" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)," depending on the context.
[0058] It should also be noted that the terms "include," "comprises," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or device comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such product or device. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the product or device comprising the element.
[0059] It should be noted in particular that any symbols and / or numbers in the specification that are not marked in the accompanying drawings are not drawing marks.
[0060] Referring to FIG1 , a log file storage method includes:
[0061] S101, in response to a log storage optimization request, obtaining log files contained in a log database in real time;
[0062] Specifically, in this step, when a log storage optimization request is received, the log files contained in the log database are obtained in real time;
[0063] It is understandable that the log database contains multiple log files, and log files are also continuously entering the log database. In this step, when a log storage optimization request is received, each log file and the newly entered log file are obtained in real time. The log storage optimization request can also be changed to a normally open state, so that the log database will be optimized in real time.
[0064] S102, extracting time information and log content mark information contained in the log file;
[0065] Specifically, in the step, from each acquired log file, the time information and log content tag information contained in each log file are extracted;
[0066] It can be understood that the time information contained in the log file can be understood as the time string of each log record in the log file, and the log content marking information can be understood as the log tag of each log record in the log file. From the obtained log file, the time string and log tag contained therein are extracted.
[0067] S103, optimizing the time information and the log content tag information based on the defined time optimization rules and log content tag optimization rules to shorten the representation of the time information and the content tag information;
[0068] Specifically, in this step, first, a time optimization rule and a log content mark optimization rule are defined, and then, according to the defined time optimization rule and log content mark optimization rule, the time information and the log content mark information are optimized to shorten the representation of the time information and the content mark information;
[0069] It can be understood that the defined time optimization rules and log content tag optimization rules correspond to the optimization of the time information and content tag information contained in the log file. The purpose of the optimization is to shorten the expression of the time information and content tag information, which can be understood as shortening the time string and log tag.
[0070] In some of the applications, the defined time optimization rule specifically includes optimizing the time information based on a time difference between the time information;
[0071] It can be understood that, in this application, the time difference between each time information is defined as a time optimization rule, and the corresponding time character string can be replaced by the time difference.
[0072] Furthermore, in this application, based on the defined time optimization rules, the time information is optimized to shorten the representation of the time information, specifically including determining whether the current log is the first record of the log file; when the log is not the first record of the log file, calculating the difference between the time information of the current log and the time information of the previous log; and modifying the time information of the current log based on the difference in the time information to shorten the representation of the time information;
[0073] It can be understood that in this application, it is first determined whether the current log is the first record in the log file. When the log is not the first record in the log file, it means that there is at least one previous record of this record. The time information difference of the two records is calculated, that is, the time difference of the time string. The time information of this record is modified through the time difference of the time string, that is, the time string of this record is modified to the time difference, thereby shortening the representation of the time information and optimizing the storage space. Continuing this link can save a lot of storage space.
[0074] Furthermore, in this application, when the log is the first record of the log file, the time information of the log is not optimized and the complete time information is retained; the difference between the time information of the log and the time information of the next log is calculated; and based on the difference in the time information, the time information of the next log is modified to shorten the representation of the time information;
[0075] It can be understood that when a log is the first record in a log file, the time information of the log is used as the basis, the complete time string is retained, and the time information of the next log is calculated, that is, the time difference between the time string of the next log and the time string of the log, and the time string of the next log is modified based on the time difference to shorten the expression of the time information; continuing this step can save a lot of storage space.
[0076] In some other applications, the defined log content mark optimization rule specifically includes establishing a mapping relationship value corresponding to the log content mark; optimizing the log content mark based on the mapping relationship value;
[0077] It is understandable that, in this application, a mapping relationship value corresponding to the log content mark is established, and the corresponding log content mark can be replaced according to the mapping relationship value.
[0078] Furthermore, based on the defined log content tag optimization rules, the log content tag information is optimized to shorten the expression form of the content tag information, specifically including establishing mapping relationship values corresponding to the log content tags; sequentially storing the mapping relationship values corresponding to the log content tags in the log database; and modifying the log content tags corresponding to the mapping relationship values according to the mapping relationship values to shorten the expression form of the log content tags;
[0079] It is understandable that mapping relationship values corresponding to log content tags are established, each mapping relationship value is sequentially stored in the log database, and the corresponding log content tags are replaced by searching, thereby shortening the representation of the log content tags.
[0080] Furthermore, after modifying each of the log content tags corresponding to each of the mapping relationship values to shorten the expression form of the log content tags based on the mapping relationship values, the method also includes, when a new log is received, determining whether there is the mapping relationship value corresponding to the log content tag of the new log; when the mapping relationship value exists, modifying the log content tag of the new log to shorten the expression form of the log content tag; when the mapping relationship value does not exist, establishing the mapping relationship value corresponding to the log content tag of the new log, and modifying the log content tag of the new log based on the established mapping relationship value to shorten the expression form of the log content tag.
[0081] It is understandable that in order to avoid newly entered logs taking up too much storage space, when a new log is received, it is necessary to determine whether there is a mapping relationship value corresponding to the log content tag of the new log. If it exists, it is modified accordingly. If it does not exist, it is created accordingly. Through the above optimization steps, storage space can be saved to the maximum extent.
[0082] S104: Update and store the optimized time information and log content mark information in the log file.
[0083] It is understandable that the above steps can improve the utilization rate of log storage space. With the same space, more valid logs can be saved, and the log storage time is correspondingly increased, which is beneficial to subsequent system development and debugging and subsequent vehicle operation.
[0084] The following describes embodiments of the log file storage method of the present invention in some applications with reference to FIG2 and FIG3 :
[0085] To illustrate the problem, refer to the following log content:
[0086] (2023-07-04 05:07:44.877852 529 2829I ActivityManager:calcYSize:unsupported or RGB color format,RGBA8888_UBWC(-1040187392)
[0087] 2023-07-04 05:07:44.879030 3112 4878I ComAdapterService:queryBinder+code is 32binder is haaen@15334
[0088] 2023-07-04 05:07:44.880555 1020 2607D CompatibilityChangeReporter: Compat change id reported: 136219221; UID 1001000; state: DISABLED
[0089] 2023-07-04 05:09:11.979622 5788 10328I VehicleStateBinder:mAdapterManager.getLowBeamHeight
[0090] 2023-07-04 05:09:11.979694 5788 10328I Proxy_CarVehicleStateManager:getLowBeamHeight
[0091] 2023-07-04 05:09:11.980545 3112 8876I VehicleSDK_CarVehicleStateManagerProxy:getLowBeamHeight
[0092] The above log is in the standard Android log format. Each line is a record. Each record contains multiple fields separated by spaces. From left to right, they are: time, process ID, thread ID, log level, and log content (the log content starts with a colon before the log tag [also called a log tag]).
[0093] The first field is the time. For example, "2023-07-04 05:07:44.877852" means "July 4, 2023, 5:07:44:877852 hours." The actual interval between two consecutive log records is very short, typically in milliseconds or even microseconds. This field is fixed at 26 bytes.
[0094] The log tag is a name set by each log outputter, such as system service or application, to distinguish the log content output by different modules. You can see that the length of this field varies.
[0095] In the above log, you can intuitively see the time field and log tag field, which account for a considerable proportion of each log line.
[0096] In order to better understand the actual situation, we conducted a statistical analysis of the actual system logs. The following table shows the statistical results:
[0097] illustrate:
[0098] The logs are real daily development logs, totaling over 10 million lines. To a certain extent, they are generally representative.
[0099] We extracted the tags from each log line, calculated their length, and averaged them. The result was 12.2, meaning that the average tag length per line was at least 12 characters (bytes). The average tag percentage across all log files (total number of tags divided by total log size) was 0.098, approximately 10%. For a 1GB log file, tags occupy approximately 100MB.
[0100] The time stamp is of fixed length (26 bytes) and accounts for an average of 0.21 in the log file (total bytes of the time string divided by the total log size). This means that over 20% of the space is occupied by the time string. For a 1GB log file, over 200MB of space is occupied by the time string.
[0101] The average space ratio of tags and time strings (the sum of the two) is 0.308. In a 1GB log, nearly one-third of the space is occupied by these two.
[0102] The optimization scheme is described below:
[0103] As shown in Figure 2, the optimization of the time string:
[0104] The characteristics of the time string are that the time in each row is different (with a small amount of duplication) and the difference between adjacent time values is very small.
[0105] Each log record does not save the complete time string. Only the time difference between the current record and the previous record is saved. The time difference is stored as an integer. You can select an integer type with different digits, such as 2 bytes, 4 bytes, or 8 bytes, depending on your needs (different system log saving frequency).
[0106] In each log file, the first line of the record must contain the complete time record. The subsequent log times can be calculated based on this.
[0107] Each file will save its own log time (the first line) to ensure that each log file can be used independently and will not be affected even if other log files are deleted, lost, or damaged.
[0108] As shown in Figure 3, the log tag is optimized:
[0109] The characteristics of log tags are: the total number of tags is relatively limited (usually only a few thousand tags in a system), and a tag may appear multiple times.
[0110] Save a tag mapping file, which contains: tag name, tag id (an integer id), and last updated time.
[0111] During logging, the tag mapping file is read into the file for efficient reading and writing. Tags are retrieved and their IDs are obtained through hashing. The hashing algorithm has a time complexity of O(1), which has little impact on operational efficiency.
[0112] Log files don't store tag names, only tag IDs. Each new log entry retrieves the corresponding tag ID from the tag mapping file. A tag ID takes up two bytes, and the average tag name is over 12 bytes long. Therefore, the 12-byte name is replaced with a two-byte ID for storage.
[0113] When restoring log content, the tag name corresponding to the id is queried through the log mapping file.
[0114] When a tag exceeds a certain length of time (you can set a fixed length, or based on the earliest time of the currently saved log), delete the unused tags to ensure that the tag mapping file does not take up too much space and only save the tag information that is valid for the current log.
[0115] Optimization effect analysis:
[0116] Time string optimization:
[0117] Only the first record in each log file stores the complete time. The total number of log files is relatively small, typically no more than 100. Compared to the millions of log lines, the space occupied by the time string in the first line of each file is negligible. The time string is ultimately optimized to an integer (time difference) to store the difference between adjacent records. This means that 2 bytes (time difference) replace 26 bytes (full time string).
[0118] Log Tag Optimization:
[0119] The total number of tags in a system is typically in the thousands (or equivalent). Compared to the millions of logs, the size of the tag mapping file is negligible. Log tags are ultimately optimized to integer IDs. This ID can be used to retrieve the corresponding tag name in the tag mapping file and restore log content. This replaces 12 bytes (tag name) with 2 bytes (tag ID).
[0120] Performance and convenience
[0121] No complex compression algorithms are used, so when processing logs in real time, there is no burden on system performance. Due to the sophisticated processing of the algorithm, there is almost no performance burden.
[0122] While improving storage efficiency, the log module can easily process and output log content for real-time viewing.
[0123] The following table summarizes the effects of log storage space optimization: Note: Optimization ratio = (original length – new length) ÷ original length
[0124] Through the optimization algorithm, time field optimization saves 92% of space. In the above example, over 200MB of space is occupied by the time field in a 1GB log file, saving 184MB of space. Log tag field optimization saves 84% of space. In the above example, approximately 100MB of space is occupied by log tags, saving approximately 84MB of space. Overall, optimization can save a total of 268MB of space in a 1GB log file, a significant improvement.
[0125] For the method steps disclosed in the above embodiments, for the purpose of simple description, the method steps are expressed as a series of action combinations. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0126] As shown in FIG4 , the present invention further provides a log file storage system, comprising:
[0127] The log file acquisition module 201 is configured to obtain the log files contained in the log database in real time in response to the log storage optimization request;
[0128] The log file extraction module 202 is configured to extract the time information and log content tag information contained in the log file;
[0129] The log file optimization module 203 is configured to optimize the time information and the log content tag information based on the defined time optimization rules and log content tag optimization rules to shorten the presentation of the time information and the content tag information;
[0130] The log file storage module 204 is configured to update and store the optimized time information and log content mark information in the log file.
[0131] Specifically, the log file storage system provided in this embodiment includes a log file acquisition module 201 , a log file extraction module 202 , a log file optimization module 203 and a log file storage module 204 .
[0132] It is worth noting that although only some basic functional modules are disclosed in the embodiment of the present invention, it does not mean that the composition of the present system is limited to the above basic functional modules. On the contrary, what this embodiment wants to express is that on the basis of the above basic functional modules, those skilled in the art can arbitrarily add one or more functional modules in combination with the existing technology to form an infinite number of embodiments or technical solutions. In other words, this system is open rather than closed. Just because this embodiment only discloses individual basic functional modules, it cannot be considered that the scope of protection of the claims of the present invention is limited to the disclosed basic functional modules. At the same time, for the convenience of description, the above devices are described in terms of functions, which are divided into various units and modules. Of course, when implementing the present invention, the functions of each unit and module can be implemented in the same or one or more software and / or hardware.
[0133] As shown in Figure 5, the present invention also provides an electronic device, including: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the log file storage method.
[0134] Figure 5 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. As shown in Figure 5, the electronic device provided by the embodiment of the present invention includes: one or more processors 710 and a storage device 720. The electronic device may have one or more processors 710, and Figure 5 uses one processor 710 as an example. The storage device 720 is used to store one or more programs. The one or more programs are executed by the one or more processors 710, so that the one or more processors 710 implement the log file storage method described in any of the embodiments of the present invention.
[0135] The electronic device may further include an input device 730 and an output device 740 .
[0136] The processor 710 , storage device 720 , input device 730 and output device 740 in the electronic device may be connected via a bus or other means. FIG5 takes the bus connection as an example.
[0137] The storage device 720 in the electronic device serves as a computer-readable storage medium and can be used to store one or more programs, which may be software programs, computer executable programs, and modules, such as the program instructions / modules corresponding to the log file storage method provided in the embodiments of the present invention. The processor 710 executes the software programs, instructions, and modules stored in the storage device 720 to execute various functional applications and data processing of the electronic device, thereby implementing the log file storage method in the above-mentioned method embodiment.
[0138] The storage device 720 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the electronic device, etc. In addition, the storage device 720 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the storage device 720 may further include a memory remotely located relative to the processor 710, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0139] The input device 730 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 740 may include a display device such as a display screen.
[0140] The present invention also provides a computer-readable storage medium storing a computer program executable by an electronic device. When the computer program runs on the electronic device, the electronic device executes the steps of the log file storage method.
[0141] Specifically, the computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination of the above. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer 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 of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in combination with an instruction execution system, device or device.
[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A log file storage method, characterized in that: include: Responding to the log storage optimization request, obtaining log files contained in the log database in real time; Extracting time information and log content marking information contained in the log file; Based on the defined time optimization rules and log content mark optimization rules, the time information and the log content mark information are optimized to shorten the presentation forms of the time information and the content mark information; The optimized time information and log content marking information are updated and stored in the log file.
2. The log file storage method according to claim 1, characterized in that: The time optimization rules defined above specifically include: The time information is optimized based on the time difference between the time information.
3. The log file storage method according to claim 1, characterized in that: The log content marking optimization rules defined above specifically include: Establishing a mapping relationship value corresponding to the log content tag; Based on the mapping relationship value, the log content tag is optimized.
4. The log file storage method according to claim 2, characterized in that: Based on the defined time optimization rules, the time information is optimized to shorten the presentation form of the time information, specifically including: Determine whether the current log is the first record of the log file; When the log is not the first record of the log file, calculating the difference between the time information of the current log and the time information of the previous log; The time information of the current log is modified according to the difference of the time information to shorten the representation of the time information.
5. The log file storage method according to claim 4, characterized in that: When the log is the first record of the log file, the time information of the log is not optimized and the complete time information is retained; Calculate the difference between the time information of the log and the time information of the next log; The time information of the next piece is modified according to the difference of the time information to shorten the presentation form of the time information.
6. The log file storage method according to claim 3, characterized in that: Based on the defined log content tag optimization rules, the log content tag information is optimized to shorten the presentation form of the content tag information, specifically including: Establishing a mapping relationship value corresponding to the log content tag; Sequentially save the mapping relationship values corresponding to the log content tags in the log database; According to the mapping relationship values, the log content marks corresponding to the mapping relationship values are modified to shorten the expression form of the log content marks.
7. The log file storage method according to claim 6, characterized in that: After modifying the log content marks corresponding to the mapping relationship values according to the mapping relationship values to shorten the expression form of the log content marks, the method further includes: When a new log is received, determining whether there is the mapping relationship value corresponding to the log content tag of the new log; When the mapping relationship value exists, modifying the log content mark of the new log to shorten the expression form of the log content mark; When the mapping relationship value does not exist, the mapping relationship value corresponding to the log content mark of the new log is established, and the log content mark of the new log is modified according to the established mapping relationship value to shorten the expression form of the log content mark.
8. A log file storage system, characterized in that: include: A log file acquisition module, configured to acquire the log files contained in the log database in real time in response to the log storage optimization request; A log file extraction module, configured to extract time information and log content marking information contained in the log file; A log file optimization module, configured to optimize the time information and the log content tag information based on defined time optimization rules and log content tag optimization rules, so as to shorten the presentation form of the time information and the content tag information; The log file storage module is configured to update and store the optimized time information and log content marking information in the log file.
9. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; a computer program is stored in the memory, 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 7.
10. A computer-readable storage medium, characterized in that: It stores a computer program executable by an electronic device, and when the computer program runs on the electronic device, the electronic device executes the steps of the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Log recording method, device and equipment and storage medium
CN111881012A
Log data compression method based on storage structure
CN114860678A
Log file storage method and system, electronic equipment and storage medium
CN117909309A
Program Log Record Optimization
US20130111451A1