Log file storage method and device and vehicle
By identifying and storing exception log files and their adjacent log files, the problem of abnormal log files being accidentally deleted is solved, ensuring the reliability of system failure analysis.
Patent Information
- Application Number
- CN202310620126.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2024-11-29
AI Technical Summary
In the prior art, exception log files are stored together with normal log files, resulting in error deletion of exception log files when logs are scrolled, affecting failure analysis.
By identifying the exception log file from the buffer and storing the log file adjacent to the generation order to a special exception log file storage space, it is different from normal log files to avoid accidentally deletion caused by log scrolling.
It realizes special storage of exception log files, avoids the problem of accidentally deleting due to normal log files scrolling, and ensures the reliability of system exception analysis.
Smart Images

Figure CN119045722A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of log storage, and in particular to a method, device, electronic device, storage medium and vehicle for storing log files. Background Art
[0002] At present, the storage of log files is crucial for the normal operation of hardware and software, especially the abnormal log files that carry abnormal information. Root cause analysis can be performed based on the abnormal log files to solve the faults in a timely manner. However, in the related art, most of the abnormal log files are stored together with the normal log files, and there is no special storage for the abnormal log files. In the case of a large amount of log rolling, the system often needs to delete the originally stored log files to free up the log file storage space, resulting in a short storage time of the abnormal log files, which is inconvenient for subsequent analysis of the cause of the system abnormality. Summary of the invention
[0003] The present disclosure aims to solve one of the technical problems in the above-mentioned technologies at least to some extent.
[0004] To this end, the first objective of the present disclosure is to propose a method for storing log files.
[0005] A second objective of the present disclosure is to provide a storage device for log files.
[0006] A third objective of the present disclosure is to provide an electronic device.
[0007] A fourth objective of the present disclosure is to provide a computer-readable storage medium.
[0008] A fifth object of the present disclosure is to provide a vehicle.
[0009] The first aspect of the present disclosure provides a log file storage method, comprising: taking out a candidate log file from a first buffer, wherein the first buffer is used to store the candidate log file; identifying whether the candidate log file includes a set abnormal keyword, and if the candidate log file includes the set abnormal keyword, determining that the candidate log file is a first log file, wherein the first log file is an abnormal log file; determining a second log file from multiple log files, wherein the generation order of the first log file and the second log file is adjacent; and storing the first log file and the second log file in a storage space of the abnormal log file.
[0010] In addition, the log file storage method proposed in the above embodiment of the present disclosure may also have the following additional technical features:
[0011] In one embodiment of the present disclosure, the identifying whether the candidate log file includes the set abnormal keyword also includes: if the candidate log file does not include the set abnormal keyword, determining that the candidate log file is a third log file, wherein the third log file is a non-abnormal log file; and storing the third log file in a second buffer different from the first buffer.
[0012] In one embodiment of the present disclosure, the second log file includes a fourth log file, and the generation order of the fourth log file is earlier than that of the first log file; determining the second log file from the plurality of log files includes: identifying whether the generation order of a third log file in the second buffer is earlier than that of the first log file, and if the generation order of the third log file is earlier than that of the first log file, determining the third log file as the fourth log file; and taking out the fourth log file from the second buffer.
[0013] In one embodiment of the present disclosure, the plurality of fourth log files in the second buffer are sorted from earliest to latest in the order of generation; the taking out the fourth log files from the second buffer comprises: obtaining a target number S of the fourth log files, where S is a positive integer; if the number of the fourth log files in the second buffer is less than or equal to S, taking out all the fourth log files from the second buffer; or, if the number of the fourth log files in the second buffer is greater than S, taking out the sorted S fourth log files from the second buffer.
[0014] In one embodiment of the present disclosure, the second log file includes a fifth log file, and the generation order of the fifth log file is later than that of the first log file; determining the second log file from the plurality of log files includes: identifying whether the generation order of a candidate log file in the first buffer is later than that of the first log file, and if the generation order of the candidate log file is later than that of the first log file, determining the candidate log file as the fifth log file; and taking out the fifth log file from the first buffer.
[0015] In one embodiment of the present disclosure, multiple fifth log files in the first buffer are sorted from early to late according to the order of generation; the taking out the fifth log file from the first buffer includes: obtaining a target number T of the fifth log files, where T is a positive integer; if the number of fifth log files in the first buffer is less than or equal to T, taking out all the fifth log files from the first buffer; or, if the number of fifth log files in the first buffer is greater than T, taking out the first T fifth log files from the first buffer.
[0016] In one embodiment of the present disclosure, after storing the first log file and the second log file in the storage space of the abnormal log file, it also includes: identifying that the storage space of the abnormal log file reaches the set rolling condition; taking out the first N log file identifiers from the target identifier queue, wherein the target identifier queue is used to store the log file identifier of the first log file and the log file identifier of the second log file, the log file identifier is used to characterize the log file identity information, and the log file identifiers in the target identifier queue are sorted from early to late according to the generation order of the log files, and N is a positive integer; determining a sixth log file corresponding one-to-one to the log file identifier from the storage space of the abnormal log file; and deleting N of the sixth log files from the storage space of the abnormal log file.
[0017] In one embodiment of the present disclosure, before taking out the top N log file identifiers from the target identifier queue, it also includes: obtaining the generation order of the first log file and the second log file; storing the log file identifier of the first log file and the log file identifier of the second log file in sequence from early to late according to the generation order to the tail of the target identifier queue.
[0018] The second aspect of the present disclosure proposes a storage device for log files, including: a processing module, used to take out a candidate log file from a first buffer, wherein the first buffer is used to store the candidate log file; an identification module, used to identify whether the candidate log file includes a set abnormal keyword, if the candidate log file includes the set abnormal keyword, determine that the candidate log file is a first log file, wherein the first log file is an abnormal log file; a determination module, used to determine a second log file from multiple log files, wherein the generation order of the first log file and the second log file is adjacent; a storage module, used to store the first log file and the second log file in the storage space of the abnormal log file.
[0019] The third aspect embodiment of the present disclosure proposes an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the log file storage method as described in the first aspect embodiment of the present disclosure is implemented.
[0020] The fourth aspect embodiment of the present application proposes a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the log file storage method described in the first aspect embodiment of the present disclosure is implemented.
[0021] The fifth aspect embodiment of the present application proposes a vehicle, comprising a storage device for log files as described in the second aspect embodiment of the present disclosure; or an electronic device as described in the third aspect embodiment of the present disclosure; or a computer-readable storage medium as described in the fourth aspect embodiment of the present disclosure.
[0022] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: when the first log file is an abnormal log file, a second log file whose generation order is adjacent to the generation order of the first log file can be determined from multiple log files, and both the first log file and the second log file can be stored in the storage space of the abnormal log file. The abnormal log file and the log files before and after the abnormal log file can be stored specifically. Compared with the related art that mostly stores the abnormal log file and the normal log file together, the present invention distinguishes the abnormal log file from the normal log file, and stores the abnormal log file and the log files before and after the abnormal log file separately, thereby avoiding the abnormal log file from being accidentally deleted due to the rolling of the normal log file, which is beneficial to the subsequent system abnormality analysis.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The above and / or additional aspects and advantages of the present disclosure will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0025] Figure 1 A flow chart of a method for storing log files according to an embodiment of the present disclosure;
[0026] Figure 2 A schematic diagram of a process of storing a third log file in a log file storage method according to an embodiment of the present disclosure;
[0027] Figure 3 A schematic diagram of a process for determining a second log file in a log file storage method according to an embodiment of the present disclosure;
[0028] Figure 4 A schematic diagram of a process for determining a second log file in a log file storage method according to another embodiment of the present disclosure;
[0029] Figure 5 A flowchart of a method for storing a log file according to another embodiment of the present disclosure;
[0030] Figure 6 A schematic diagram of the structure of a storage device for log files according to an embodiment of the present disclosure;
[0031] Figure 7The figure is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION
[0032] Embodiments of the present disclosure are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0033] The following describes the log file storage method, device, vehicle, electronic device and storage medium of the embodiments of the present disclosure in conjunction with the accompanying drawings.
[0034] Figure 1 The figure is a flowchart of a method for storing log files according to an embodiment of the present disclosure.
[0035] like Figure 1 As shown, the log file storage method of the embodiment of the present disclosure includes:
[0036] S101, taking out a candidate log file from a first buffer, where the first buffer is used to store the candidate log file.
[0037] It should be noted that the execution subject of the log file storage method of the embodiment of the present disclosure is an electronic device, and the electronic device includes a mobile phone, a notebook, a desktop computer, a vehicle terminal, a smart home appliance, etc. The log file storage method of the embodiment of the present disclosure can be executed by the log file storage device of the embodiment of the present disclosure, and the log file storage device of the embodiment of the present disclosure can be configured in any electronic device to execute the log file storage method of the embodiment of the present disclosure.
[0038] It should be noted that the first buffer is a storage space for log files, and there is no excessive limitation on the first buffer, for example, it may include the physical memory of the computer. The first buffer is used to store candidate log files, that is, the first buffer is used to store log files to be identified as abnormal. It is understandable that the number of candidate log files in the first buffer is at least one.
[0039] It should be noted that after the candidate log file is taken out from the first buffer, the number of candidate log files in the first buffer is reduced by 1. For example, after the candidate log file x is taken out from the first buffer, the candidate log file x no longer exists in the first buffer.
[0040] In one implementation, retrieving the candidate log file from the first buffer includes retrieving the candidate log file with the earliest generation order from the first buffer.
[0041] S102, identifying whether the candidate log file includes the setting abnormality keyword, if the candidate log file includes the setting abnormality keyword, determining that the candidate log file is a first log file, wherein the first log file is an abnormal log file.
[0042] It should be noted that there are not too many restrictions on setting abnormal keywords.
[0043] It should be noted that step S102 is an implementation method of detecting that the candidate log file is an abnormal log file, and can also be implemented by using any abnormal log file detection method in the related art.
[0044] S103: Determine a second log file from a plurality of log files, wherein the first log file and the second log file are generated in an adjacent order.
[0045] It should be noted that the generation order of the second log files may be earlier or later than the generation order of the first log files, and the number of the second log files is at least one, which is not limited here.
[0046] In one implementation, determining the second log file from the plurality of log files includes screening out the second log file whose generation order is adjacent to the generation order of the first log file from the plurality of log files.
[0047] For example, the multiple log files include log files 1 to 10, and the generation order of log files 1 to 10 is log files 1 to 10 from early to late. If log file 5 is the first log file, the second log file may include log files 1 to 4 and log files 6 to 10.
[0048] In some examples, selecting a second log file whose generation order is adjacent to the generation order of the first log file from the plurality of log files includes selecting a second log file whose generation order is before S of the generation order of the first log file from the plurality of log files, and / or selecting a second log file whose generation order is after T of the generation order of the first log file from the plurality of log files. Wherein, S and T are both positive integers.
[0049] For example, taking S=T=3 as an example, multiple log files include log files 1 to 10, and the generation order of log files 1 to 10 is log files 1 to 10 from early to late. If log file 5 is the first log file, then log files 2 to 4 whose generation order is the first 3 log files can be filtered out from log files 1 to 10, and log files 6 to 8 whose generation order is the last 3 log files of the generation order of the first log file can be filtered out from log files 1 to 10. Then the second log file may include log files 2 to 4 and log files 6 to 8.
[0050] S104: Store the first log file and the second log file in a storage space for abnormal log files.
[0051] It should be noted that the storage space of the abnormal log file is used to store the abnormal log file and the log files whose generation order is adjacent to the generation order of the abnormal log file. There are no excessive restrictions on the storage space of the abnormal log file, for example, it can include the hard disk of the computer.
[0052] It should be noted that there is no excessive limitation on the specific manner of storing the first log file and the second log file in the storage space of the abnormal log file. For example, the log files in the storage space of the abnormal log file do not need to be sorted.
[0053] In summary, according to the storage method of log files of the embodiment of the present disclosure, a candidate log file is taken out from the first buffer, and it is identified whether the candidate log file includes the set abnormal keyword. If the candidate log file includes the set abnormal keyword, the candidate log file is determined to be the first log file, the first log file is the abnormal log file, and the second log file is determined from multiple log files. The generation order of the first log file and the second log file is adjacent, and the first log file and the second log file are stored in the storage space of the abnormal log file. Thus, the second log file whose generation order is adjacent to the generation order of the first log file can be determined from multiple log files, and the first log file and the second log file are both stored in the storage space of the abnormal log file. The abnormal log file and the log files before and after the abnormal log file can be stored specifically. Compared with the related art that mostly stores the abnormal log file and the normal log file together, the present invention distinguishes the abnormal log file from the normal log file, and stores the abnormal log file and the log files before and after the abnormal log file separately, avoiding the abnormal log file from being accidentally deleted due to the rolling of the normal log file, which is beneficial to the subsequent system abnormality analysis.
[0054] Based on any of the above embodiments, Figure 2 As shown, in step S102, identifying whether the candidate log file includes the set abnormal keyword also includes:
[0055] S201: If the candidate log file does not include the set abnormal keyword, determine that the candidate log file is a third log file, wherein the third log file is a non-abnormal log file.
[0056] It should be noted that step S201 is an implementation method for detecting that the candidate log file is a non-abnormal log file, and can also be implemented by using any non-abnormal log file detection method in the related art.
[0057] S202: Store the third log file in a second buffer area different from the first buffer area.
[0058] It should be noted that the second buffer is a storage space for log files, and there is no excessive limitation on the second buffer, for example, it may include the physical memory of the computer. The second buffer is used to store the third log file, that is, the second buffer is used to store the identified non-abnormal log files. It is understandable that the number of the third log files in the second buffer is at least one. The second buffer and the first buffer are different buffers.
[0059] In one implementation, the number of the third log files in the second buffer is less than or equal to S, that is, the second buffer stores at most S third log files.
[0060] For example, if S=3 and the number of the third log files in the second buffer is 0, the first buffer includes log files 1 to 5, and the generation order of log files 1 to 5 from earliest to latest is log files 4, 2, 1, 3, 5. The candidate log files include log files 1, 2, and 4.
[0061] The log file 4 can be taken out from the first buffer, and it is identified whether the log file 4 includes the setting abnormal keyword. If the log file 4 does not include the setting abnormal keyword, it is determined that the log file 4 is the third log file, and the log file 4 is stored in the second buffer. At this time, the number of the third log file in the second buffer is 1.
[0062] Continue to take out log file 2 from the first buffer, identify whether log file 2 includes the setting abnormal keyword, if log file 2 does not include the setting abnormal keyword, determine that log file 2 is the third log file, and store log file 2 in the second buffer. At this time, the number of third log files in the second buffer is 2.
[0063] Continue to take out log file 1 from the first buffer, identify whether log file 1 includes the setting abnormal keyword, if log file 1 does not include the setting abnormal keyword, determine that log file 1 is the third log file, and store log file 1 in the second buffer. At this time, the number of third log files in the second buffer is 3.
[0064] Therefore, in this method, if the candidate log file does not include the set abnormal keyword, the candidate log file is determined to be the third log file, wherein the third log file is a non-abnormal log file, and the third log file is stored in a second buffer different from the first buffer, that is, the non-abnormal log file is stored separately.
[0065] Based on any of the above embodiments, the second log file includes a fourth log file, and the generation order of the fourth log file is earlier than that of the first log file.
[0066] like Figure 3As shown, determining the second log file from the multiple log files in step S103 also includes:
[0067] S301, identifying whether the generation order of the third log file in the second buffer is earlier than that of the first log file, and if the generation order of the third log file is earlier than that of the first log file, determining the third log file as the fourth log file.
[0068] S302: Get a fourth log file from the second buffer.
[0069] For example, the third log file in the second buffer includes log files 1 to 5. If the first log file is log file 6, the generation order of log files 1, 2, and 4 is earlier than that of log file 6, and the generation order of log files 3 and 5 is later than that of log file 6, then log files 1, 2, and 4 can be determined as the fourth log file, and log files 1, 2, and 4 are taken out from the second buffer.
[0070] In one implementation, taking out the fourth log file from the second buffer includes taking out the fourth log file with the latest generation order from the second buffer.
[0071] In one embodiment, the plurality of fourth log files in the second buffer are sorted from earliest to latest in the order of generation. Taking out the fourth log file from the second buffer includes obtaining a target number S of the fourth log files, and if the number of the fourth log files in the second buffer is less than or equal to S, taking out all the fourth log files from the second buffer, or, if the number of the fourth log files in the second buffer is greater than S, taking out the sorted S fourth log files from the second buffer. Thus, the method can take into account the number of the fourth log files in the second buffer and take out all or part of the fourth log files from the second buffer.
[0072] It can be understood that, the later the fourth log file is ranked, the later the generation order of the fourth log file is, that is, the generation order of the fourth log file is closer to the generation order of the first log file.
[0073] For example, taking S=3 as an example, if the second buffer includes the fourth log files 1 and 2, and the number of the fourth log files in the second buffer is less than S, the fourth log files 1 and 2 are taken out from the second buffer.
[0074] For example, taking S=3 as an example, if the second buffer includes fourth log files 1 to 5, and the generation order of the fourth log files 1 to 5 from early to late is fourth log files 4, 2, 1, 3, 5, at this time, the number of fourth log files in the second buffer is greater than S, and the three fourth log files after sorting are taken out from the second buffer, that is, the fourth log files 1, 3, 5 are taken out from the second buffer.
[0075] Therefore, in this method, if the third log file is generated earlier than the first log file, the third log file is determined as the fourth log file, and the fourth log file is taken out from the second buffer to obtain the fourth log file generated earlier than the first log file.
[0076] Based on any of the above embodiments, the second log file includes a fifth log file, and the generation order of the fifth log file is later than that of the first log file.
[0077] like Figure 4 As shown, determining the second log file from the multiple log files in step S103 includes:
[0078] S401, identifying whether the generation order of the candidate log file in the first buffer is later than that of the first log file, and if the generation order of the candidate log file is later than that of the first log file, determining the candidate log file as the fifth log file.
[0079] S402: Retrieve a fifth log file from the first buffer.
[0080] For example, the candidate log files in the first buffer include log files 1 to 5. If the first log file is log file 6, the generation order of log files 1, 2, and 4 is earlier than that of log file 6, and the generation order of log files 3 and 5 is later than that of log file 6, then log files 3 and 5 can be determined as the fifth log files, and log files 3 and 5 are taken out from the first buffer.
[0081] In one implementation, taking out the fifth log file from the first buffer includes taking out the fifth log file with the earliest generation order from the first buffer.
[0082] In one embodiment, the plurality of fifth log files in the first buffer are sorted from earliest to latest in the order of generation. Taking out the fifth log file from the first buffer includes obtaining a target number T of fifth log files, and if the number of fifth log files in the first buffer is less than or equal to T, taking out all the fifth log files from the first buffer, or, if the number of fifth log files in the first buffer is greater than T, taking out the first T fifth log files from the first buffer. Thus, the method can take into account the number of fifth log files in the first buffer and take out all or part of the fifth log files from the first buffer.
[0083] It can be understood that, the higher the ranking of the fifth log file is, the earlier the generation order of the fifth log file is, that is, the generation order of the fifth log file is closer to the generation order of the first log file.
[0084] For example, taking T=4 as an example, if the first buffer includes the fifth log files 1 and 2, and the number of the fifth log files in the first buffer is less than T, the fifth log files 1 and 2 are taken out from the first buffer.
[0085] For example, taking T=4 as an example, if the first buffer includes fifth log files 1 to 5, the generation order of the fifth log files 1 to 5 from early to late is fifth log files 4, 2, 1, 3, 5, at this time, the number of fifth log files in the first buffer is greater than T, and the first 4 fifth log files in the order are taken out from the first buffer, that is, fifth log files 4, 2, 1, 3 are taken out from the first buffer.
[0086] Therefore, in this method, if the candidate log file is generated later than the first log file, the candidate log file is determined as the fifth log file, and the fifth log file is taken out from the first buffer to obtain the fifth log file whose generation order is later than the first log file.
[0087] Figure 5 The figure is a flowchart of a method for storing log files according to another embodiment of the present disclosure.
[0088] like Figure 5 As shown, after storing the first log file and the second log file in the storage space of the abnormal log file in step S104, the method further includes:
[0089] S501, identifying that the storage space of the abnormal log file reaches a set rolling condition.
[0090] It should be noted that there are no excessive restrictions on setting the rolling conditions. For example, it may include that the number of log files in the storage space of abnormal log files reaches a set threshold, and / or the current time reaches a set rolling time.
[0091] S502, take out the first N log file identifiers from the target identifier queue, where the target identifier queue is used to store the log file identifier of the first log file and the log file identifier of the second log file, the log file identifier is used to represent the log file identity information, and the log file identifiers in the target identifier queue are sorted from early to late according to the generation order of the log files, and N is a positive integer.
[0092] There is no limitation on the specific log file identification method. For example, the inode includes metadata such as the log file's permissions, owner, group, creation date, and file size. The inode can be used as a log file identifier to represent the log file's identity information. Each log file corresponds to a unique inode.
[0093] S503: Determine, from the storage space of the abnormal log file, a sixth log file that corresponds one-to-one to the log file identifier.
[0094] S504, deleting N sixth log files from the storage space of abnormal log files.
[0095] It should be noted that there are no excessive restrictions on N, for example, N=1.
[0096] It should be noted that the target identification queue is used to store the identification of log files in the storage space of abnormal log files, and the log files in the storage space of abnormal log files include a first log file and a second log file, that is, the target identification queue is used to store the log file identification of the first log file and the log file identification of the second log file, and the sixth log file includes the first log file and / or the second log file.
[0097] For example, taking N=1 as an example, the storage space of the abnormal log file includes log files 1 to 5, and the log file identifiers of log files 1 to 5 are a, b, c, d, and e respectively. The target identifier queue includes d, b, a, c, and e. The generation order of log files 1 to 5 can be determined from the target identifier queue to be log files 4, 2, 1, 3, and 5 from early to late, respectively. The first-ranked log file identifier d can be taken out from the target identifier queue, and based on the log file identifier d, it can be determined that log file 4 in the storage space of the abnormal log file is the sixth log file, and log file 4 can be deleted from the storage space of the abnormal log file.
[0098] In one embodiment, before taking out the first N log file identifiers from the target identifier queue, it also includes obtaining the generation order of the first log file and the second log file, and storing the log file identifier of the first log file and the log file identifier of the second log file in sequence from early to late according to the generation order to the tail of the target identifier queue.
[0099] For example, the target identification queue includes d, b, a, c, and e. The generation order of the first log file 1 and the second log files 2 to 5 is second log file 2, second log file 3, first log file 1, second log file 4, and second log file 5. The log file identifier of the first log file 1 is f, and the log file identifiers of the second log files 2 to 5 are g, h, i, and j respectively. The log file identifiers f, g, h, i, and j can be stored in the order of second log file 2, second log file 3, first log file 1, second log file 4, and second log file 5 at the end of the target identification queue.
[0100] That is, first store the log file identifier g to the tail of the target identifier queue to update the target identifier queue to d, b, a, c, e, g, and store the log file identifier h to the tail of the target identifier queue to update the target identifier queue to d, b, a, c, e, g, h, and store the log file identifier f to the tail of the target identifier queue to update the target identifier queue to d, b, a, c, e, g, h, f, and store the log file identifier i to the tail of the target identifier queue to update the target identifier queue to d, b, a, c, e, g, h, f, i, and store the log file identifier j to the tail of the target identifier queue to update the target identifier queue to d, b, a, c, e, g, h, f, i, j.
[0101] In one implementation, the target identification queue is a FIFO (First Input First Output) queue.
[0102] In summary, according to the log file storage method of the embodiment of the present invention, when the storage space of the abnormal log file reaches the set rolling condition, the first N log file identifiers are taken out from the target identifier queue, wherein the target identifier queue is used to store the log file identifier of the first log file and the log file identifier of the second log file, and the log file identifiers in the target identifier queue are sorted from early to late according to the generation order of the log files. The target identifier queue can be used to determine the sixth log file with an earlier generation order in the storage space of the abnormal log file, so as to realize the rolling storage of the log files in the storage space of the abnormal log file.
[0103] In order to implement the above embodiment, the present disclosure also proposes a storage device for log files.
[0104] Figure 6 The figure is a schematic diagram of the structure of a storage device for log files according to an embodiment of the present disclosure.
[0105] like Figure 6 As shown, the log file storage device 100 of the embodiment of the present disclosure includes: a processing module 110 , an identification module 120 , a determination module 130 and a storage module 140 .
[0106] The processing module 110 is used to retrieve the candidate log file from the first buffer, wherein the first buffer is used to store the candidate log file;
[0107] The identification module 120 is used to identify whether the candidate log file includes the set abnormality keyword, and if the candidate log file includes the set abnormality keyword, determine that the candidate log file is a first log file, wherein the first log file is an abnormal log file;
[0108] A determination module 130, configured to determine a second log file from a plurality of log files, wherein the first log file and the second log file are generated in an adjacent order;
[0109] The storage module 140 is used to store the first log file and the second log file in the storage space of the abnormal log file.
[0110] In one embodiment of the present disclosure, the identification module 120 is also used to: if the candidate log file does not include the set abnormal keyword, determine that the candidate log file is a third log file, wherein the third log file is a non-abnormal log file; and store the third log file in a second buffer different from the first buffer.
[0111] In one embodiment of the present disclosure, the second log file includes a fourth log file, and the generation order of the fourth log file is earlier than that of the first log file; the determination module 130 is further used to: identify whether the generation order of the third log file in the second buffer is earlier than that of the first log file, and if the generation order of the third log file is earlier than that of the first log file, determine the third log file as the fourth log file; and take out the fourth log file from the second buffer.
[0112] In one embodiment of the present disclosure, the multiple fourth log files in the second buffer are sorted from early to late according to the order of generation; the determination module 130 is also used to: obtain a target number S of the fourth log files, where S is a positive integer; if the number of fourth log files in the second buffer is less than or equal to S, take out all the fourth log files from the second buffer; or, if the number of fourth log files in the second buffer is greater than S, take out the sorted S fourth log files from the second buffer.
[0113] In one embodiment of the present disclosure, the second log file includes a fifth log file, and the generation order of the fifth log file is later than that of the first log file; the determination module 130 is further used to: identify whether the generation order of the candidate log file in the first buffer is later than that of the first log file, if the generation order of the candidate log file is later than that of the first log file, determine the candidate log file as the fifth log file; and take out the fifth log file from the first buffer.
[0114] In one embodiment of the present disclosure, the multiple fifth log files in the first buffer are sorted from early to late according to the order of generation; the determination module 130 is also used to: obtain the target number T of the fifth log files, where T is a positive integer; if the number of fifth log files in the first buffer is less than or equal to T, take out all the fifth log files from the first buffer; or, if the number of fifth log files in the first buffer is greater than T, take out the first T fifth log files from the first buffer.
[0115] In one embodiment of the present disclosure, the storage module 140 is also used to: identify that the storage space of the abnormal log file reaches the set rolling condition; take out the first N log file identifiers from the target identifier queue, wherein the target identifier queue is used to store the log file identifier of the first log file and the log file identifier of the second log file, and the log file identifier is used to characterize the log file identity information, and the log file identifiers in the target identifier queue are sorted from early to late according to the generation order of the log files, and N is a positive integer; determine the sixth log file corresponding to the log file identifier one by one from the storage space of the abnormal log file; and delete N of the sixth log files from the storage space of the abnormal log file.
[0116] In one embodiment of the present disclosure, the storage module 140 is also used to: obtain the generation order of the first log file and the second log file; store the log file identifier of the first log file and the log file identifier of the second log file in sequence from early to late according to the generation order to the tail of the target identifier queue.
[0117] It should be noted that for details not disclosed in the storage device of the log file in the embodiment of the present disclosure, please refer to the details disclosed in the storage method of the log file in the embodiment of the present disclosure, which will not be repeated here.
[0118] In summary, the storage device for log files of the embodiment of the present invention can determine a second log file whose generation order is adjacent to the generation order of the first log file from multiple log files, and store both the first log file and the second log file in the storage space of the abnormal log file. It can specifically store the abnormal log file, as well as the log files before and after the abnormal log file. Compared with the related art that mostly stores the abnormal log file and the normal log file together, the abnormal log file is distinguished from the normal log file, and the abnormal log file and the log files before and after the abnormal log file are stored separately, which avoids the abnormal log file from being accidentally deleted due to the rolling of the normal log file, and is beneficial to the subsequent system abnormality analysis.
[0119] In order to implement the above embodiment, Figure 7As shown, an embodiment of the present disclosure proposes an electronic device 200, including: a memory 210, a processor 220, and a computer program stored in the memory 210 and executable on the processor 220, and when the processor 220 executes the program, the above-mentioned log file storage method is implemented.
[0120] The electronic device of the disclosed embodiment can determine, through a processor executing a computer program stored in a memory, a second log file whose generation order is adjacent to the generation order of the first log file from multiple log files, and store both the first log file and the second log file in the storage space of the abnormal log file. It can specifically store the abnormal log file and the log files before and after the abnormal log file. Compared with the related art that mostly stores the abnormal log file and the normal log file together, the abnormal log file is distinguished from the normal log file, and the abnormal log file and the log files before and after the abnormal log file are stored separately, which avoids the abnormal log file from being accidentally deleted due to the rolling of the normal log file, and is beneficial to the subsequent system abnormality analysis.
[0121] In order to implement the above embodiment, the embodiment of the present disclosure proposes a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the above log file storage method is implemented.
[0122] The computer-readable storage medium of the disclosed embodiment can determine a second log file whose generation order is adjacent to the generation order of the first log file from multiple log files by storing a computer program and being executed by a processor, and store both the first log file and the second log file in the storage space of the abnormal log file. The abnormal log file and the log files before and after the abnormal log file can be stored specifically. Compared with the related art that mostly stores the abnormal log file and the normal log file together, the abnormal log file is distinguished from the normal log file, and the abnormal log file and the log files before and after the abnormal log file are stored separately, which avoids the abnormal log file from being accidentally deleted due to the rolling of the normal log file, and is beneficial to the subsequent system abnormality analysis.
[0123] In order to implement the above embodiment, the embodiment of the present disclosure proposes a vehicle, including the above log file storage device; or the above electronic device; or the above computer-readable storage medium.
[0124] The vehicle of the disclosed embodiment can determine a second log file whose generation order is adjacent to the generation order of the first log file from multiple log files, and store both the first log file and the second log file in the storage space of the abnormal log file. The abnormal log file and the log files before and after the abnormal log file can be stored specifically. Compared with the related art that mostly stores the abnormal log file and the normal log file together, the abnormal log file is distinguished from the normal log file, and the abnormal log file and the log files before and after the abnormal log file are stored separately, which avoids the abnormal log file from being accidentally deleted due to the rolling of the normal log file, and is beneficial to the subsequent system abnormality analysis.
[0125] In the description of the present disclosure, it needs to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present disclosure.
[0126] In addition, 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 the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present disclosure, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0127] In the present disclosure, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present disclosure can be understood according to specific circumstances.
[0128] In the present disclosure, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or the first and second features are in indirect contact through an intermediate medium. Moreover, a first feature being "above", "above" or "above" a second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" or "below" a second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0129] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0130] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present disclosure.
Claims
1. A method for storing log files, characterized in that: include: Taking out a candidate log file from a first buffer, wherein the first buffer is used to store the candidate log file; Identify whether the candidate log file includes a setting abnormality keyword, and if the candidate log file includes the setting abnormality keyword, determine that the candidate log file is a first log file, wherein the first log file is an abnormal log file; Determine a second log file from a plurality of log files, wherein the generation order of the first log file and the second log file is adjacent; The first log file and the second log file are stored in a storage space of an abnormal log file.
2. The method according to claim 1, characterized in that The identifying whether the candidate log file includes setting abnormal keywords also includes: If the candidate log file does not include the set abnormal keyword, determining that the candidate log file is a third log file, wherein the third log file is a non-abnormal log file; The third log file is stored in a second buffer area different from the first buffer area.
3. The method according to claim 2, characterized in that The second log file includes a fourth log file, and the generation order of the fourth log file is earlier than that of the first log file; The step of determining the second log file from the plurality of log files comprises: identifying whether the generation order of the third log file in the second buffer is earlier than that of the first log file, and if the generation order of the third log file is earlier than that of the first log file, determining the third log file as the fourth log file; The fourth log file is retrieved from the second buffer.
4. The method according to claim 3, characterized in that The plurality of fourth log files in the second buffer are sorted from earliest to latest according to the generation order; The taking out the fourth log file from the second buffer includes: Obtaining a target number S of the fourth log file, where S is a positive integer; If the number of fourth log files in the second buffer is less than or equal to S, taking out all fourth log files from the second buffer; or, If the number of fourth log files in the second buffer is greater than S, the sorted S fourth log files are taken out from the second buffer.
5. The method according to claim 1, characterized in that The second log file includes a fifth log file, and the generation order of the fifth log file is later than that of the first log file; The step of determining the second log file from the plurality of log files comprises: identifying whether the generation order of the candidate log file in the first buffer is later than that of the first log file, and if the generation order of the candidate log file is later than that of the first log file, determining the candidate log file as the fifth log file; The fifth log file is retrieved from the first buffer.
6. The method according to claim 5, characterized in that The plurality of fifth log files in the first buffer are sorted from earliest to latest according to the generation order; The taking out the fifth log file from the first buffer includes: Obtaining a target number T of the fifth log file, where T is a positive integer; If the number of fifth log files in the first buffer is less than or equal to T, all fifth log files are retrieved from the first buffer; or, If the number of fifth log files in the first buffer is greater than T, the first T fifth log files in the sorting order are retrieved from the first buffer.
7. The method according to any one of claims 1 to 6, characterized in that After storing the first log file and the second log file in the storage space of the abnormal log file, the method further includes: Identify that the storage space of the abnormal log file reaches a set rolling condition; Taking out the first N log file identifiers from the target identifier queue, wherein the target identifier queue is used to store the log file identifier of the first log file and the log file identifier of the second log file, the log file identifier is used to represent the identity information of the log file, and the log file identifiers in the target identifier queue are sorted from early to late according to the generation order of the log files, and N is a positive integer; Determine, from the storage space of the abnormal log file, a sixth log file corresponding one-to-one to the log file identifier; Delete N sixth log files from the storage space of the abnormal log file.
8. The method according to claim 7, characterized in that Before taking out the top N log file identifiers from the target identifier queue, the method further includes: Obtaining a generation order of the first log file and the second log file; The log file identifier of the first log file and the log file identifier of the second log file are stored in sequence from earliest to latest at the end of the target identifier queue according to the generation order.
9. A storage device for log files, characterized in that: include: A processing module, used for taking out a candidate log file from a first buffer, wherein the first buffer is used for storing the candidate log file; an identification module, used for identifying whether the candidate log file includes a setting abnormal keyword, and if the candidate log file includes the setting abnormal keyword, determining that the candidate log file is a first log file, wherein the first log file is an abnormal log file; A determination module, configured to determine a second log file from a plurality of log files, wherein the first log file and the second log file are generated in an adjacent order; The storage module is used to store the first log file and the second log file in the storage space of the abnormal log file.
10. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the log file storage method according to any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the log file storage method according to any one of claims 1 to 8 is implemented.
12. A vehicle, characterized in that: include: The storage device for log files as claimed in claim 9; or the electronic device as claimed in claim 10; Or the computer-readable storage medium of claim 11.
