Log storage method and device, storage medium and electronic device
By allocating an independent cache queue for each server application and extracting application logs in chronological order, the problem of poor real-time application log cache in the prior art is solved, and the consistency and efficient cache of application logs and server application behavior are achieved.
Patent Information
- Application Number
- CN202411199504.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-08-29
AI Technical Summary
The existing application log management methods have poor cache real-time performance due to competition for shared resource, resulting in lag or loss of application logging, which in turn makes the server application behavior inconsistent with logging.
Ensure application logs stored in the cache queue of each server application by assigning independent cache queues that meet their storage needs, dynamically adjusting cache queue capacity, and extracting application logs in chronological order between multiple cache queues, ensuring application logs stored in the cache queue of each server application is a must Consistent with server application behavior.
Improve the real-time cache of application logs, avoid resource preemption issues, ensure the consistency of server applications and log records, and meet the application log management needs in high concurrency environments.
Smart Images

Figure CN118689859B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the computer field, and more specifically, to a method and device for storing logs on a disk, a storage medium, and an electronic device. Background Art
[0002] With the improvement of chip integration and the continuous increase of mobile device functions, mobile phones, tablet computers and other devices have integrated a variety of commonly used digital functions such as Internet access, games, music playback, video playback, and photography. This diversification of functions has led to the frequent operation of various applications and resource calls within the device. In this case, in order to ensure the normal operation of the system and the accuracy of fault analysis, log management becomes increasingly important.
[0003] Existing application log management methods usually use a circular queue to centrally store application logs generated by multiple server applications. Since the circular queue is a shared resource, when multiple server applications add application logs to the circular queue at the same time, the occupancy of the circular queue must be checked first, that is, each server application needs to confirm whether the circular queue is occupied before adding application logs to the circular queue. If other server applications are also trying to add application logs to the circular queue at this time, they must wait until other server applications have completed adding before adding application logs to the circular queue. This shared resource competition will cause competition between threads and thread priority inversion problems, resulting in important application logs not being cached in time due to time waiting or insufficient space in the circular queue, resulting in application log record delays or even losses, which in turn leads to inconsistencies between server application behavior and application log records.
[0004] In view of the problems in related technologies such as poor real-time performance of application log cache, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present application provide a method and device for storing logs on a disk, a storage medium, and an electronic device, so as to at least solve the problem of poor real-time performance of caching of application logs in the related art.
[0006] According to an embodiment of the present application, a method for writing logs to a disk is provided. N server applications are running on a server, where N is an integer greater than 1. The method is applied to the server, and the method includes:
[0007] Obtaining storage requirement information of each of the N server applications, wherein the storage requirement information is used to indicate the storage space requirement required by the corresponding server application to cache the generated application logs;
[0008] Allocate a cache queue that satisfies the corresponding storage requirement information to each of the N server applications, to obtain M cache queues, wherein each of the M cache queues is used to cache application logs generated by the corresponding server application in the N server applications, and M is an integer greater than or equal to N;
[0009] The application logs are extracted from the M cache queues and written to disk.
[0010] Optionally, the obtaining storage requirement information of each of the N server applications includes:
[0011] Collecting a historical queue usage parameter of each of the N server applications, wherein the historical queue usage parameter is used to indicate usage of a historical cache queue by the corresponding server application, and the historical cache queue is a cache queue allocated to the server application in a historical stage;
[0012] The storage requirement information of the corresponding server application is generated according to the historical queue usage parameters.
[0013] Optionally, the collecting historical queue usage parameters of each of the N server applications includes:
[0014] Collecting a historical queue utilization rate of each of the N server applications, wherein the historical queue utilization rate is a first ratio of a historical queue usage capacity to a historical queue total capacity;
[0015] Determining the historical queue utilization as the historical queue usage parameter;
[0016] The generating the storage requirement information of the corresponding server application according to the historical queue usage parameter includes:
[0017] In the case where the historical queue utilization is greater than the target utilization threshold, generating an expected queue total capacity according to a second ratio of the historical queue usage capacity to the target utilization threshold, wherein the expected queue total capacity is greater than the second ratio, and the expected queue total capacity is the total capacity to be adjusted to the historical cache queue;
[0018] The expected total queue capacity is determined as the storage requirement information.
[0019] Optionally, allocating a cache queue that satisfies the corresponding storage requirement information to each of the N server applications to obtain M cache queues includes one of the following:
[0020] When the storage requirement information of the i-th server application among the N server applications is the i-th expected total queue capacity, and the maximum capacity allowed by the server to be allocated to a single cache queue is greater than or equal to the i-th expected total queue capacity, a cache queue with a capacity of at least the i-th expected total queue capacity is allocated to the i-th server application;
[0021] When the storage demand information of the ith server application among N server applications is the ith expected total queue capacity, and the maximum capacity allowed to be allocated to a single cache queue by the server is less than the ith expected total queue capacity, calculate a third ratio P between the ith expected total queue capacity and the maximum capacity; when P is an integer, allocate at least P cache queues with a capacity equal to the maximum capacity to the ith server application; when P is a non-integer, calculate a fourth ratio Q between the ith expected total queue capacity and P+1; and allocate P+1 cache queues with a capacity greater than or equal to Q to the ith server application, where P and Q are positive numbers.
[0022] Optionally, after allocating a cache queue that meets the corresponding storage requirement information to each of the N server applications to obtain M cache queues, the method further includes:
[0023] Detecting a queue utilization rate of each of the M cache queues, wherein the queue utilization rate is a fifth ratio of a queue usage capacity of the corresponding cache queue to a total queue capacity;
[0024] Each cache queue is recorded as a historical cache queue, and the queue utilization rate of each cache queue is recorded as a historical queue usage parameter of the corresponding historical cache queue.
[0025] Optionally, extracting the application logs from the M cache queues and storing them on disk includes:
[0026] Perform R rounds of extraction of the application logs on the M cache queues until all the application logs in the M cache queues have been extracted to obtain an initial application log sequence;
[0027] The application logs in the initial application log sequence are sorted according to the log generation time of the application logs to obtain a target application log sequence.
[0028] Optionally, performing R rounds of extraction of the application logs on the M cache queues includes:
[0029] The extraction of the application logs in the tth round in the R rounds is performed on the M cache queues through the following steps:
[0030] Obtaining a target extraction order, wherein the target extraction order is a preset order in which the application logs are extracted from the M cache queues;
[0031] Extract k application logs from each of the M cache queues in sequence according to the target extraction order, where k is an integer greater than or equal to 1.
[0032] Optionally, the sorting the application logs in the initial application log sequence according to the log generation time of the application logs to obtain a target application log sequence includes:
[0033] Extracting time parameter information from header information of each application log in the initial application log sequence, wherein the time parameter information is used to indicate a log generation time of the corresponding application log;
[0034] The application logs in the initial application log sequence are sorted according to the time parameter information to obtain a target application log sequence.
[0035] Optionally, after allocating a cache queue that meets the corresponding storage requirement information to each of the N server applications to obtain M cache queues, the method further includes:
[0036] In the case where a target server application in the N server applications has a target application log to be stored, detecting a current storage state of a target cache queue corresponding to the target server application;
[0037] In a case where the storage status is used to indicate that the target cache queue has no remaining storage space, a target storage operation is performed on the target application log according to the target log level of the target application log and the reference log levels of multiple reference application logs currently cached in the target cache queue, wherein the log level is used to indicate the importance of the corresponding log.
[0038] Optionally, performing a target storage operation on the target application log according to a target log level of the target application log and reference log levels of a plurality of reference application logs currently cached in the target cache queue includes:
[0039] Locate a candidate application log whose reference log level is lower than the target log level from the plurality of reference application logs;
[0040] The target storage operation is determined as overwriting the candidate application log with the target application log.
[0041] Optionally, locating a candidate application log whose reference log level is lower than the target log level from the plurality of reference application logs includes:
[0042] Obtaining a candidate application log from the plurality of reference application logs in order of log generation time, and comparing the reference log level of the candidate application log with the target log level, wherein the reference application log with an earlier log generation time is obtained first;
[0043] In a case where the reference log level of the candidate application log is lower than the target log level, determining the candidate application log as the candidate application log;
[0044] When the reference log level of the candidate application log is greater than or equal to the target log level, the next candidate application log is continuously obtained from the plurality of reference application logs in the order of log generation time.
[0045] According to another embodiment of the embodiment of the present application, a log storage device is further provided. N server applications are running on the server, where N is an integer greater than 1. The device is applied to the server, and the device includes:
[0046] An acquisition module, used to acquire storage requirement information of each of the N server applications, wherein the storage requirement information is used to indicate the storage space requirement required by the corresponding server application to cache the generated application logs;
[0047] an allocation module, configured to allocate a cache queue that satisfies the corresponding storage requirement information to each of the N server applications, to obtain M cache queues, wherein each of the M cache queues is used to cache application logs generated by the corresponding server application in the N server applications, and M is an integer greater than or equal to N;
[0048] The extraction module is used to extract the application logs from the M cache queues and store them on disk.
[0049] According to another embodiment of the present application, a computer program product is provided, including a computer program, wherein a processor executes the steps in any one of the above method embodiments.
[0050] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0051] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0052] In an embodiment of the present application, a method for writing logs to a disk is proposed. N server applications are running on a server, where N is an integer greater than 1. The server first obtains storage requirement information of each server application in the N server applications, where the storage requirement information can indicate the storage space requirement required for the corresponding server application to cache the generated application logs; then a cache queue that meets the corresponding storage requirement information is allocated to each server application in the N server applications, to obtain M cache queues, each of the M cache queues can cache the application logs generated by the corresponding server application in the N server applications, where M is an integer greater than or equal to N; finally, the application logs are extracted from the M cache queues for writing to the disk. Through the above method, even if multiple server applications generate application logs at the same time, that is, multiple application logs need to be cached at the same time, the application logs generated by different server applications can be cached separately in the cache queues allocated to different server applications, thereby avoiding the problem of resource preemption, thereby avoiding the problem in the prior art that when a server application caches an application log in a cache queue, it needs to wait for other server applications to complete the caching, resulting in poor real-time performance of the cache, thereby ensuring that the application logs stored in the cache queue of each server application are consistent with the behavior of the server application. The above technical solution solves the problem of poor real-time performance of application log cache in related technologies, and achieves the technical effect of improving the real-time performance of application log cache. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a hardware structure block diagram of a computer device of a log storage method according to an embodiment of the present application;
[0054] Figure 2 This is a flow chart of a method for storing logs on a disk according to an embodiment of the present application;
[0055] Figure 3 is a schematic diagram of a cache queue for storing application logs of all levels indiscriminately according to an embodiment of the present application;
[0056] Figure 4 is a schematic diagram of a cache queue for storing logs according to application log levels according to an embodiment of the present application;
[0057] Figure 5 is a schematic diagram of an initial application log sequence according to an embodiment of the present application;
[0058] Figure 6is a schematic diagram of a target application log sequence according to an embodiment of the present application;
[0059] Figure 7 It is a schematic diagram of a cache queue state for storing application logs of all levels indiscriminately according to an embodiment of the present application;
[0060] Figure 8 It is a schematic diagram of a cache queue state storing logs according to an application log level according to an embodiment of the present application;
[0061] Fig. 9 It is a schematic diagram of a process of storing server application logs on a disk according to an embodiment of the present application;
[0062] Fig.10 It is a schematic diagram of a server application log storage interaction process according to an embodiment of the present application;
[0063] Fig.11 It is a structural block diagram of a log disk placement device according to an embodiment of the present application;
[0064] Fig.12 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0065] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0066] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0067] The method embodiments provided in the embodiments of the present application can be executed in a server device or a similar computing device. Taking running on a server device as an example, Figure 1 1 is a hardware structure block diagram of a computer device for a method of storing logs on a disk according to an embodiment of the present application. Figure 1 As shown, the server device may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the above-mentioned server device may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above server device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0068] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method of storing logs on a disk in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the server 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.
[0069] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the server device. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0070] The nouns involved in the embodiments of the present application are explained as follows:
[0071] Ring queue: A circular data structure that is connected end to end, allowing the free front space to continue to be used when the queue is full, thereby realizing the circular use of storage space;
[0072] UART: An interface for serial data transmission, responsible for asynchronous sending and receiving of data.
[0073] log: refers to a log, which is a record generated by a system, application, or device, containing information such as operation process, error information, and user behavior.
[0074] The present application proposes a method for storing logs on a disk. Before describing the optional embodiments of the present application, in order to better understand the inventive concept of the present application and the creativity of the solution, the related technologies are first described:
[0075] In the related art, a common application log management method is to use a shared circular queue to store and process application logs generated from multiple server applications. The circular queue has a fixed capacity storage space, and when the storage space of the circular queue becomes full, the new application log will overwrite the oldest application log, and the log storage space will be used cyclically. Due to the storage space resource sharing of the circular queue, each server application needs to check whether the queue is occupied by other server applications before trying to add application logs to the queue. If other server applications are currently adding application log data to the queue, it is necessary to wait for the application logs of other server applications to be stored and the queue storage resources to be released before continuing the operation. Obviously, in the case of high concurrency, when multiple server applications try to add application logs to the circular queue at the same time, resource competition problems will occur, which will cause delays in application log recording. This delay will cause storage lag of application log data, and the real-time performance of application log storage is poor, which makes the application log recording behavior inconsistent with the actual system behavior. Especially when the system is abnormal, it may not be possible to accurately analyze the application log data generated by different server applications at the same time, and thus it is impossible to accurately reflect the system status. In response to the above-mentioned problems existing in the related technology, the present application proposes a method for writing logs to disk, which uses multiple cache queues to store application logs of different servers, and extracts the application log data in each cache queue in turn, so that the current system operation status can be viewed by simply sorting the application logs in chronological order of timestamps. This aims to avoid delays in application log recording, improve the consistency of application log data, and meet the needs of application log management in a high-concurrency environment.
[0076] In this embodiment, a method for storing logs on a disk is provided. Figure 2 is a flow chart of a method for storing logs on a disk according to an embodiment of the present application. Figure 2 As shown, N server applications are running on the server, where N is an integer greater than 1. The method is applied to the server, and the process includes the following steps:
[0077] Step S12, obtaining storage requirement information of each of the N server applications, wherein the storage requirement information is used to indicate the storage space requirement required by the corresponding server application to cache the generated application logs;
[0078] Step S14, allocating a cache queue that meets the corresponding storage demand information to each of the N server applications, to obtain M cache queues, wherein each of the M cache queues is used to cache application logs generated by the corresponding server application in the N server applications, and M is an integer greater than or equal to N;
[0079] Step S16: extract the application logs from the M cache queues and write them to disk.
[0080] Optionally, in this embodiment, the storage requirement information of the server application can be obtained in the following manner, but is not limited to: by analyzing the historical operation data of N server applications, such as the storage capacity of the historical logs generated by each server application, to predict the storage requirement of the corresponding server application for generating logs in the future. In this way, the cache capacity of each server application can be dynamically adjusted, thereby allocating cache resources more accurately.
[0081] Optionally, in this embodiment, the cache queue may be, but is not limited to, any queue that satisfies the first-in-first-out storage mode, including a ring queue and a linked list queue, etc. The number of server applications is not necessarily the same as the number of corresponding cache queues, and one server application may be assigned one cache queue or multiple cache queues.
[0082] Optionally, in this embodiment, a cache queue that meets corresponding storage demand information is allocated to each of the N server applications to obtain M cache queues. The allocation method may include but is not limited to the following methods:
[0083] 1) Allocate cache resources based on the storage requirements of server applications. Server applications with large storage requirements are allocated larger cache queues, and server applications with small storage requirements are allocated smaller cache queues. Figure 3 is a schematic diagram of a cache queue for storing application logs of all levels indiscriminately according to an embodiment of the present application, such as Figure 3 As shown, the cache queue for generating logs by server application 1 is queue 1, and the cache queues for generating logs by server application 2 are queues 2 and queue 3, which constitute the cache queue group corresponding to server application 2. The cache queue group stores application logs of all levels indiscriminately, thereby reasonably utilizing cache resources and preventing application log data overflow and loss.
[0084] 2) When allocating cache resources to meet the storage requirements of the corresponding server applications, the number of cache queues is divided according to the number of application log levels. For example, the storage requirement capacity of the i-th server application among N server applications is D, and the application log level is divided into m levels. Then, at least m cache queues with a total capacity of at least D can be allocated to the i-th server application to form a cache queue group corresponding to the i-th server application. Figure 4 is a schematic diagram of a cache queue for storing logs according to application log levels according to an embodiment of the present application, such as Figure 4As shown in the figure, assume there are 3 application log levels, namely: i: info; e: error; f: fatal, where the priority level is info < error < fatal. The cache queue group corresponding to server application 3 includes queue 4, queue 5, and queue 6. It is set that queue 4 stores application logs with a log level of "f", queue 5 stores application logs with a log level of "e", and queue 6 stores application logs with a log level of "i". In this way, different cache queues can be used to store application logs of different application log levels. After the storage space of the application logs stored in cache queue 4 (with a level of "f") is full, new application logs with a log level of "f" can directly overwrite the application logs with a level of "i" in cache queue 6 without discrimination. Similarly, after the storage space of cache queue 5 is full, it can also choose to store and overwrite the application logs in cache queue 6 with a lower application log level. This avoids the waste of resources and time caused by the comparison of application log levels, improves the storage efficiency of application logs, and saves the resource consumption of application log storage.
[0085] Optionally, in this embodiment, the method of extracting the application logs from the M cache queues for disk writing may include, but is not limited to: setting a scheduled task to extract all the application logs from the cache queue in a preset order at a predetermined time interval, such as every few minutes or hours, for disk writing; performing an application log extraction operation when the application log data in the cache queue reaches a certain quantity or triggers a specific condition; and preferentially extracting the application log data of high-priority applications from the cache queue according to the priority of the application logs.
[0086] As an alternative solution, obtaining the storage requirement information of each of the N server applications includes:
[0087] S21, collecting the historical queue usage parameters of each of the N server applications, where the historical queue usage parameters are used to indicate the usage of the corresponding server application for the historical cache queue, and the historical cache queue is the cache queue allocated to the server application in the historical stage;
[0088] S22, generating the storage requirement information of the corresponding server application according to the historical queue usage parameters.
[0089] Optionally, in this embodiment, the storage requirement information may include, but is not limited to, any information that can reflect the storage space requirements of the server application, including the utilization rate of the storage resources by a single server application, the length of time that the application log data needs to be retained in the cache, the priority of the server application, the speed and frequency of the generation of application logs, and so on.
[0090] As an optional solution, the collecting of historical queue usage parameters of each of the N server applications includes:
[0091] S31, collecting a historical queue utilization rate of each of the N server applications, wherein the historical queue utilization rate is a first ratio of a historical queue usage capacity to a historical queue total capacity;
[0092] S32, determining the historical queue utilization as the historical queue usage parameter;
[0093] S33, the step of generating the storage requirement information of the corresponding server application according to the historical queue usage parameter includes:
[0094] S34, when the historical queue utilization is greater than the target utilization threshold, generating an expected queue total capacity according to a second ratio of the historical queue usage capacity to the target utilization threshold, wherein the expected queue total capacity is greater than the second ratio, and the expected queue total capacity is the total capacity to be adjusted to the historical cache queue;
[0095] S35: Determine the expected total queue capacity as the storage requirement information.
[0096] Optionally, in this embodiment, the historical queue usage parameter used to measure the historical queue usage may be, but is not limited to, the average utilization of the queue within a period of time and the number of queue overflows, etc. For example, if the average utilization of a cache queue exceeds a certain threshold within a predetermined historical time period, it can be indicated that the queue has an overflow risk, and the cache queue of the corresponding server application needs to be adjusted to a larger capacity to cache application logs.
[0097] Optionally, in this embodiment, the historical queue utilization is used to measure the historical queue usage, and the historical queue utilization is determined based on the ratio of the historical queue usage capacity to the historical queue total capacity. The expected total queue capacity of each cache queue is determined in different ways due to the different historical queue usage, and the determination method may be, but is not limited to: pre-setting a target utilization threshold, when the historical queue utilization is less than or equal to the target utilization threshold, it means that the current queue capacity of the queue is likely to be sufficient for the corresponding server application, and thus there is no need to adjust the capacity, and the expected total queue capacity is the historical queue total capacity; when the historical queue utilization is greater than the target utilization threshold, it means that the queue has an overflow risk, and the expected total queue capacity needs to be adjusted to be greater than the historical queue total capacity, and the minimum value of the adjusted expected total queue capacity may be, but is not limited to, the ratio of the historical queue usage capacity to the target utilization threshold.
[0098] As an optional solution, allocating a cache queue that meets the corresponding storage demand information to each of the N server applications to obtain M cache queues includes one of the following:
[0099] S41, when the storage requirement information of the i-th server application among the N server applications is the i-th expected total queue capacity, and the maximum capacity allowed by the server to be allocated to a single cache queue is greater than or equal to the i-th expected total queue capacity, allocate a cache queue with a capacity of at least the i-th expected total queue capacity to the i-th server application;
[0100] Optionally, in this embodiment, for example, the total capacity of the ith expected queue is 20G and the maximum capacity is 40G, then at least 20G of cache queue is allocated.
[0101] S42, when the storage requirement information of the ith server application among the N server applications is the ith expected total queue capacity, and the maximum capacity allowed to be allocated to a single cache queue by the server is less than the ith expected total queue capacity, calculate a third ratio P between the ith expected total queue capacity and the maximum capacity; when P is an integer, allocate at least P cache queues with a capacity equal to the maximum capacity to the ith server application; when P is a non-integer, calculate a fourth ratio Q between the ith expected total queue capacity and P+1; allocate P+1 cache queues with a capacity greater than or equal to Q to the ith server application, where P and Q are positive numbers.
[0102] Optionally, in this embodiment, for example, the total capacity of the i-th expected queue is 120G, the maximum capacity is 40G, and the third ratio P is 3, then at least 3 cache queues with a capacity of the maximum capacity are allocated. For another example, the total capacity of the i-th expected queue is 90G, the maximum capacity is 40G, and the third ratio P is 2.25, then at least 3 cache queues with a capacity of the maximum capacity are allocated, or at least 3 cache queues with a capacity of 30G are allocated.
[0103] As an optional solution, after allocating a cache queue that meets the corresponding storage requirement information to each of the N server applications to obtain M cache queues, the method further includes:
[0104] S51, detecting a queue utilization rate of each of the M cache queues, wherein the queue utilization rate is a fifth ratio of a queue usage capacity of the corresponding cache queue to a total queue capacity;
[0105] S52. Record each of the cache queues as a historical cache queue, and record the queue utilization rate of each cache queue as the historical queue usage parameter of the corresponding historical cache queue.
[0106] Optionally, in this embodiment, the utilization rate may also be, but is not limited to, the sixth ratio of the total usage capacity to the total capacity of the cache queue group corresponding to a single server application. Record all the cache queue groups of each server application as a historical cache queue group, and record the utilization rate of each server application as the historical queue usage parameter of the corresponding historical cache queue group.
[0107] As an alternative solution, the extracting the application logs from the M cache queues for disk writing includes:
[0108] S61. Perform R rounds of extraction of the application logs on the M cache queues until all the application logs in the M cache queues have been extracted, to obtain an initial application log sequence;
[0109] S62. Sort the application logs in the initial application log sequence according to the log generation time of the application logs, to obtain a target application log sequence.
[0110] Optionally, in this embodiment, the application logs in the M cache queues may be extracted in, but are not limited to, the following ways: Way 1. Perform extraction operations on the M cache queues in sequence, and extract a certain amount of application logs each time; Way 2. In the case of allocating cache queues according to the application log levels, set the extraction rounds according to the number of application log levels, and perform extraction in the order from the highest application log level to the lowest application log level. For example, there are 3 application log levels, namely: i:info; e:error; f:fatal, where the priority is info < error < fatal, that is, there are 3 levels of cache queues corresponding to them, and 3 rounds of extraction operations are performed in sequence. In the first round, perform extraction on all the highest-level cache queues in sequence, that is, the fatal level; in the second round, perform extraction on all the second-highest-level cache queues in sequence, that is, the error level; in the third round, perform extraction on all the lowest-level cache queues in sequence, that is, the info level. By Way 2, it can ensure that the highest-priority application logs are processed and written to disk in a timely manner, which helps to quickly locate and diagnose in case of system failures.
[0111] As an alternative solution, the performing R rounds of extraction of the application logs on the M cache queues includes:
[0112] S71. Perform the t-th round of extraction of the application logs on the M cache queues through the following steps:
[0113] S72, obtaining a target extraction order, wherein the target extraction order is a preset order in which the application logs are extracted from the M cache queues;
[0114] S73: extract k application logs from each of the M cache queues in sequence according to the target extraction order, where k is an integer greater than or equal to 1.
[0115] Optionally, in this embodiment, the extraction of the application log may be, but is not limited to, the following method: extract application log records from M cache queues in sequence, first obtain a preset target extraction order, then extract k application log records from each cache queue in sequence according to the target extraction order, and repeat the process until all application log records are extracted from all cache queues. During the extraction process, if it is detected that there are less than k application log records in a certain cache queue, all application log records in the cache queue are taken out; if it is detected that a certain cache queue is empty, the subsequent extraction operation will skip the empty queue, and only the extraction operation will be continued on the remaining non-empty queues until all application log records in all non-empty queues are extracted.
[0116] As an optional solution, the application logs in the initial application log sequence are sorted according to the application log generation time of the application logs to obtain a target application log sequence, including:
[0117] S81, extracting time parameter information from header information of each application log in the initial application log sequence, wherein the time parameter information is used to indicate a log generation time of the corresponding application log;
[0118] S82: Sort the application logs in the initial application log sequence according to the time parameter information to obtain a target application log sequence.
[0119] Optionally, in this embodiment, Figure 5 is a schematic diagram of an initial application log sequence according to an embodiment of the present application, such as Figure 5 As shown, all application log records in all current cache queues are obtained in the above manner, and each application log includes header information and data information, wherein the header information includes application log level information and timestamp information (equivalent to time parameter information).
[0120] Optionally, in this embodiment, Figure 6 is a schematic diagram of a target application log sequence according to an embodiment of the present application, such as Figure 6As shown, after parsing the header information in each application log and obtaining the timestamp information in turn, the obtained full amount of application log records are sorted according to time, and the sorted new sequence is determined as the target application log sequence.
[0121] As an optional solution, after allocating a cache queue that meets the corresponding storage requirement information to each of the N server applications to obtain M cache queues, the method further includes:
[0122] S91, when a target server application among the N server applications has a target application log to be stored, detecting a current storage state of a target cache queue corresponding to the target server application;
[0123] S92, when the storage status is used to indicate that the target cache queue has no remaining storage space, a target storage operation is performed on the target application log according to the target log level of the target application log and the reference log levels of multiple reference application logs currently cached in the target cache queue, wherein the log level is used to indicate the importance of the corresponding log.
[0124] Optionally, in this embodiment, during the process of storing the target application logs, if it is detected that the cache queue group of the target server application still has storage space, application logs of all levels can be added to the cache queue group; if it is detected that the cache queue group is full, the application logs with lower levels in the cache queue are first overwritten, and the application logs with higher levels are retained, and the application logs with higher levels are preserved to the maximum extent.
[0125] As an optional solution, performing a target storage operation on the target application log according to the target log level of the target application log and the reference log levels of multiple reference application logs currently cached in the target cache queue includes:
[0126] S101, locating a candidate application log whose reference log level is lower than the target log level from a plurality of reference application logs;
[0127] S102: Determine the target storage operation as overwriting the candidate application log with the target application log.
[0128] Optionally, in this embodiment, Figure 7 is a schematic diagram of a cache queue state for storing application logs of all levels indiscriminately according to an embodiment of the present application, such as Figure 7As shown, the left side shows that new application logs continue to be added when the cache queue is full. The operational process of storing new application logs in a full queue is as follows: First, the application log at the head of the cache queue is determined as the reference application log, and whether the log level of the reference application log is greater than or equal to the newly added log level is determined. If the log level of the reference application log is greater than or equal to the log level to be stored in the queue, the next header information in the cache queue is determined as the reference application log, and the reference application log and the newly added application log level are parsed and compared. The reference application logs are determined in sequence according to the storage order of the cache queue until the reference application log level is less than the newly added application log level, and the reference application log is overwritten with the newly added application log. As shown Figure 7 Take the left side as an example. If the current newly added application log level is "e", and the reference application log level is "i", and the reference application log level is lower than the newly added application log level "e", the newly added application log will be inserted into the queue and overwrite the reference application log. According to the operation flow, all the newly added application logs to be processed will be inserted into the cache queue according to the application log level, and finally the queueing operation of the newly added application log will be completed. Figure 7 Shown on the right.
[0129] Optionally, in this embodiment, Figure 8 is a schematic diagram of a cache queue state storing logs according to an application log level according to an embodiment of the present application, such as Figure 8 As shown, on the left side, the newly added application log continues to be added when the cache queue group is not full. The operational process of storing the newly added application log in the queue is as follows: first, detect that the newly added application log level is "f", find queue 4 with the cache application log level of "f", and directly insert the newly added application log into the queue when the queue is not full; if the cache queue corresponding to the newly added application log level is full, then insert the newly added application log into the queue with the smallest difference between the non-empty cache application log level and the newly added application log level. For example, when the newly added application log is detected to be "16 f log", that is, the newly added application log level is "f", find queue 4 with the cache application log level of "f", detect that queue 4 is full, and determine that the queue with the smallest difference between the current non-empty cache application log level and the newly added application log level "f" is queue 5, then insert the newly added application log into queue 5. According to the described operational process, all the newly added application logs to be processed are inserted into the cache queue according to the application log level, and finally the enqueue operation of the newly added application log is completed, as shown in Figure 8 Shown on the right.
[0130] As an optional solution, locating a candidate application log whose reference log level is lower than the target log level from the plurality of reference application logs includes:
[0131] S111, sequentially acquiring a candidate application log from the plurality of reference application logs in order of log generation time, and comparing the reference log level of the candidate application log with the target log level, wherein the reference application log with an earlier log generation time is acquired first;
[0132] S112, when the reference log level of the candidate application log is lower than the target log level, determining the candidate application log as the candidate application log;
[0133] S113: When the reference log level of the candidate application log is greater than or equal to the target log level, continue to obtain the next candidate application log from the plurality of reference application logs in the order of log generation time.
[0134] Optionally, in this embodiment, Fig. 9 is a schematic diagram of a process of storing server application logs on a disk according to an embodiment of the present application, such as Fig. 9 As shown, the system allocates an independent cache queue to each server application, and sets the size of the corresponding cache queue according to the actual running status of the application, so that the server application can store the application log in the queue according to the actual generation of the application log; then, the application log of each server application is taken out from each cache queue in turn in multiple rounds to obtain the initial application log sequence; then, the timestamp information contained in the application log header information is parsed, and the application log is sorted in chronological order to obtain the target application log sequence; at the same time, it can filter according to the application log level, and save the relevant data to the storage unit in the system, which helps users to understand the usage of each application in the system more accurately and further optimize the capacity of the cache queue. The problems of thread competition, thread priority inversion, and inconsistency between log behavior and server application behavior between server applications are solved.
[0135] The log storage method proposed in this application involves the interaction between multiple objects, including host (host / server), APP (server application), circular queue (cache queue), consumer (thread) and transmitter (uart). Fig.10 is a schematic diagram of a server application log storage interaction process according to an embodiment of the present application, such as Fig.10As shown in the figure, the host creates multiple APP server applications and log collection tasks according to the business scenario. Then the host performs system initialization, including initializing UART, configuring baud rate, check mode, stop bit and other parameters. After that, each server application APP applies for and initializes a dedicated ring queue, and the size of the ring queue can be flexibly configured according to the business. Then each server application first determines whether the ring queue is full, and at the same time checks whether the remaining capacity of the ring queue meets the capacity of the application log added this time. If the requirements are met, all the generated application logs are written to the tail of its own ring queue. If the ring queue is full, the newly added log content (application log) is inserted according to the application log level. When writing the application log to the ring queue, the log level information (i:info / e:error / f:fatal) and timestamp information (time parameter information) of the queue need to be recorded. When executing the task of collecting logs, first determine whether the queue content is empty in turn. If it is not empty, take out the data content in the queue from the head of each queue in turn. By parsing the timestamp information in the log, the collected full logs are sorted in chronological order. Finally, the full amount of log information (application log) is input into UART, and the log is output to the host side through UART, so that users can view the current system operation status online. After that, the full amount of log is filtered according to the log level and saved to the storage unit in the system, which helps users understand the usage of each application in the system more accurately. It is worth noting that Fig.10 Only one server application and the corresponding ring queue are shown, but in reality multiple applications and multiple ring queues will be created.
[0136] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0137] In this embodiment, a log disk device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0138] Fig.11 is a structural block diagram of a log disk placement device according to an embodiment of the present application; Fig.11 As shown, N server applications are running on the server, where N is an integer greater than 1, and the device is applied to the server, and the device includes:
[0139] The acquisition module 1102 is used to acquire storage requirement information of each of the N server applications, wherein the storage requirement information is used to indicate the storage space requirement required by the corresponding server application to cache the generated application logs;
[0140] The allocation module 1104 is used to allocate a cache queue that meets the corresponding storage demand information to each of the N server applications, so as to obtain M cache queues, wherein each of the M cache queues is used to cache application logs generated by the corresponding server application in the N server applications, and M is an integer greater than or equal to N;
[0141] The extraction module 1106 is used to extract the application logs from the M cache queues and store them on disk.
[0142] In an exemplary embodiment, the acquisition module includes:
[0143] a collecting unit, configured to collect a historical queue usage parameter of each of the N server applications, wherein the historical queue usage parameter is used to indicate usage of a historical cache queue by the corresponding server application, and the historical cache queue is a cache queue allocated to the server application in a historical stage;
[0144] The first generating unit is used to generate the storage requirement information of the corresponding server application according to the historical queue usage parameter.
[0145] In an exemplary embodiment, the acquisition unit comprises:
[0146] Collecting a historical queue utilization rate of each of the N server applications, wherein the historical queue utilization rate is a first ratio of a historical queue usage capacity to a historical queue total capacity;
[0147] Determining the historical queue utilization as the historical queue usage parameter;
[0148] The generating the storage requirement information of the corresponding server application according to the historical queue usage parameter includes:
[0149] In the case where the historical queue utilization is greater than the target utilization threshold, generating an expected queue total capacity according to a second ratio of the historical queue usage capacity to the target utilization threshold, wherein the expected queue total capacity is greater than the second ratio, and the expected queue total capacity is the total capacity to be adjusted to the historical cache queue;
[0150] The expected total queue capacity is determined as the storage requirement information.
[0151] In an exemplary embodiment, the allocation module includes one of the following:
[0152] an allocating unit, configured to allocate a cache queue having a capacity of at least the i-th expected queue total capacity to the i-th server application, when the storage requirement information of the i-th server application among the N server applications is the i-th expected queue total capacity and the maximum capacity allowed to be allocated to a single cache queue by the server is greater than or equal to the i-th expected queue total capacity;
[0153] A calculation unit is used to calculate a third ratio P of the i-th expected queue total capacity and the maximum capacity when the storage demand information of the i-th server application among the N server applications is the i-th expected queue total capacity and the maximum capacity allowed to be allocated to a single cache queue by the server is less than the i-th expected queue total capacity; when P is an integer, allocate at least P cache queues with a capacity of the maximum capacity to the i-th server application; when P is a non-integer, calculate a fourth ratio Q of the i-th expected queue total capacity and P+1; and allocate P+1 cache queues with a capacity greater than or equal to Q to the i-th server application, where P and Q are positive numbers.
[0154] In an exemplary embodiment, the apparatus further comprises:
[0155] A first detection module is configured to detect a queue utilization rate of each of the M cache queues after allocating a cache queue that satisfies the corresponding storage demand information to each of the N server applications to obtain the M cache queues, wherein the queue utilization rate is a fifth ratio of a queue usage capacity of the corresponding cache queue to a total queue capacity;
[0156] The recording module is used to record each of the cache queues as a historical cache queue, and record the queue utilization rate of each of the cache queues as a historical queue usage parameter of the corresponding historical cache queue.
[0157] In an exemplary embodiment, the extraction module comprises:
[0158] an extraction unit, configured to perform R rounds of extraction of the application logs on the M cache queues until all the application logs in the M cache queues have been extracted to obtain an initial application log sequence;
[0159] The second generating unit is configured to sort the application logs in the initial application log sequence according to the log generation time of the application logs to obtain a target application log sequence.
[0160] In an exemplary embodiment, the extraction unit comprises:
[0161] The extraction of the application logs in the tth round in the R rounds is performed on the M cache queues through the following steps:
[0162] Obtaining a target extraction order, wherein the target extraction order is a preset order in which the application logs are extracted from the M cache queues;
[0163] Extract k application logs from each of the M cache queues in sequence according to the target extraction order, where k is an integer greater than or equal to 1.
[0164] In an exemplary embodiment, the second generating unit includes:
[0165] Extracting time parameter information from header information of each application log in the initial application log sequence, wherein the time parameter information is used to indicate a log generation time of the corresponding application log;
[0166] The application logs in the initial application log sequence are sorted according to the time parameter information to obtain a target application log sequence.
[0167] In an exemplary embodiment, the device further comprises:
[0168] A second detection module is used for, after allocating a cache queue that satisfies the corresponding storage demand information to each of the N server applications to obtain the M cache queues, detecting a current storage state of a target cache queue corresponding to the target server application when there is a target application log to be stored in the target server application among the N server applications;
[0169] An execution module is used to perform a target storage operation on the target application log according to a target log level of the target application log and reference log levels of multiple reference application logs currently cached in the target cache queue when the storage status indicates that the target cache queue has no remaining storage space, wherein the log level is used to indicate the importance of the corresponding log.
[0170] In an exemplary embodiment, the execution module includes:
[0171] a locating unit, configured to locate, from the plurality of reference application logs, a candidate application log whose reference log level is lower than the target log level;
[0172] An overwriting unit is used to determine the target storage operation as overwriting the candidate application log with the target application log.
[0173] In an exemplary embodiment, the positioning unit comprises:
[0174] Obtaining a candidate application log from the plurality of reference application logs in order of log generation time, and comparing the reference log level of the candidate application log with the target log level, wherein the reference application log with an earlier log generation time is obtained first;
[0175] In a case where the reference log level of the candidate application log is lower than the target log level, determining the candidate application log as the candidate application log;
[0176] When the reference log level of the candidate application log is greater than or equal to the target log level, the next candidate application log is continuously obtained from the plurality of reference application logs in the order of log generation time.
[0177] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0178] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in each embodiment of the present application; the computer program product also includes a non-volatile computer-readable storage medium, which stores the computer program, and when executed by a processor, implements the steps of the method described in each embodiment of the present application.
[0179] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.
[0180] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0181] An embodiment of the present application further provides an electronic device, Fig.12 is a schematic diagram of an electronic device according to an embodiment of the present application, such as Fig.12 As shown, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0182] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0183] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0184] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0185] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for storing logs on a disk, characterized in that: N server applications are running on the server, where N is an integer greater than 1. The method is applied to the server, and the method includes: Obtaining storage requirement information of each of the N server applications, wherein the storage requirement information is used to indicate the storage space requirement required by the corresponding server application to cache the generated application logs; Allocate a cache queue that satisfies the corresponding storage requirement information to each of the N server applications, to obtain M cache queues, wherein each of the M cache queues is used to cache application logs generated by the corresponding server application in the N server applications, and M is an integer greater than or equal to N; Extract the application logs from the M cache queues and write them to disk; Among them, the obtaining of the storage requirement information of each of the N server applications includes: collecting historical queue usage parameters of each of the N server applications, wherein the historical queue usage parameters are used to indicate the usage of a historical cache queue by the corresponding server application, and the historical cache queue is a cache queue allocated to the server application in a historical stage; generating the storage requirement information of the corresponding server application according to the historical queue usage parameters.
2. The method according to claim 1, characterized in that The collecting of historical queue usage parameters of each of the N server applications includes: Collecting a historical queue utilization rate of each of the N server applications, wherein the historical queue utilization rate is a first ratio of a historical queue usage capacity to a historical queue total capacity; Determining the historical queue utilization as the historical queue usage parameter; The generating the storage requirement information of the corresponding server application according to the historical queue usage parameter includes: In the case where the historical queue utilization is greater than the target utilization threshold, generating an expected queue total capacity according to a second ratio of the historical queue usage capacity to the target utilization threshold, wherein the expected queue total capacity is greater than the second ratio, and the expected queue total capacity is the total capacity to be adjusted to the historical cache queue; The expected total queue capacity is determined as the storage requirement information.
3. The method according to claim 2, characterized in that The step of allocating a cache queue that satisfies the corresponding storage requirement information to each of the N server applications to obtain M cache queues includes one of the following: When the storage requirement information of the i-th server application among the N server applications is the i-th expected total queue capacity, and the maximum capacity allowed by the server to be allocated to a single cache queue is greater than or equal to the i-th expected total queue capacity, a cache queue with a capacity of at least the i-th expected total queue capacity is allocated to the i-th server application; When the storage requirement information of the i-th server application among the N server applications is the i-th expected queue total capacity, and the maximum capacity allowed by the server to be allocated to a single cache queue is less than the i-th expected queue total capacity, calculate a third ratio P of the i-th expected queue total capacity to the maximum capacity; When P is an integer, allocating at least P cache queues with a capacity equal to the maximum capacity to the i-th server application; When P is a non-integer, calculate a fourth ratio Q of the i-th expected total queue capacity and P+1; P+1 cache queues with a capacity greater than or equal to Q are allocated to the i-th server application, where P and Q are positive numbers.
4. The method according to claim 1, characterized in that: After allocating a cache queue that meets the corresponding storage requirement information to each of the N server applications to obtain M cache queues, the method further includes: Detecting a queue utilization rate of each of the M cache queues, wherein the queue utilization rate is a fifth ratio of a queue usage capacity of the corresponding cache queue to a total queue capacity; Each cache queue is recorded as a historical cache queue, and the queue utilization rate of each cache queue is recorded as a historical queue usage parameter of the corresponding historical cache queue.
5. The method according to claim 1, characterized in that The extracting the application logs from the M cache queues and storing them on disks includes: Perform R rounds of extraction of the application logs on the M cache queues until all the application logs in the M cache queues have been extracted to obtain an initial application log sequence; The application logs in the initial application log sequence are sorted according to the log generation time of the application logs to obtain a target application log sequence.
6. The method according to claim 5, characterized in that The performing R rounds of extracting the application logs on the M cache queues includes: The extraction of the application logs in the tth round in the R rounds is performed on the M cache queues through the following steps: Obtaining a target extraction order, wherein the target extraction order is a preset order in which the application logs are extracted from the M cache queues; Extract k application logs from each of the M cache queues in sequence according to the target extraction order, where k is an integer greater than or equal to 1.
7. The method according to claim 5, characterized in that The step of sorting the application logs in the initial application log sequence according to the log generation time of the application logs to obtain a target application log sequence includes: Extracting time parameter information from header information of each application log in the initial application log sequence, wherein the time parameter information is used to indicate a log generation time of the corresponding application log; The application logs in the initial application log sequence are sorted according to the time parameter information to obtain a target application log sequence.
8. The method according to claim 1, characterized in that After allocating a cache queue that meets the corresponding storage requirement information to each of the N server applications to obtain M cache queues, the method further includes: In the case where a target server application in the N server applications has a target application log to be stored, detecting a current storage state of a target cache queue corresponding to the target server application; In a case where the storage status is used to indicate that the target cache queue has no remaining storage space, a target storage operation is performed on the target application log according to the target log level of the target application log and the reference log levels of multiple reference application logs currently cached in the target cache queue, wherein the log level is used to indicate the importance of the corresponding log.
9. The method according to claim 8, characterized in that The performing a target storage operation on the target application log according to the target log level of the target application log and the reference log levels of multiple reference application logs currently cached in the target cache queue includes: Locate a candidate application log whose reference log level is lower than the target log level from the plurality of reference application logs; The target storage operation is determined as overwriting the candidate application log with the target application log.
10. The method according to claim 9, characterized in that The step of locating a candidate application log whose reference log level is lower than the target log level from the plurality of reference application logs includes: Obtaining a candidate application log from the plurality of reference application logs in order of log generation time, and comparing the reference log level of the candidate application log with the target log level, wherein the reference application log with an earlier log generation time is obtained first; In a case where the reference log level of the candidate application log is lower than the target log level, determining the candidate application log as the candidate application log; When the reference log level of the candidate application log is greater than or equal to the target log level, the next candidate application log is continuously obtained from the plurality of reference application logs in the order of log generation time.
11. A log placement device, characterized in that: N server applications are running on the server, where N is an integer greater than 1, and the device is applied to the server, and the device includes: An acquisition module, used to acquire storage requirement information of each of the N server applications, wherein the storage requirement information is used to indicate the storage space requirement required by the corresponding server application to cache the generated application logs; an allocation module, configured to allocate a cache queue that satisfies the corresponding storage requirement information to each of the N server applications, to obtain M cache queues, wherein each of the M cache queues is used to cache application logs generated by the corresponding server application in the N server applications, and M is an integer greater than or equal to N; An extraction module, used for extracting the application logs from the M cache queues and writing them to disk; Among them, the acquisition module includes: a collection unit, used to collect the historical queue usage parameters of each of the N server applications, wherein the historical queue usage parameters are used to indicate the usage of the historical cache queue by the corresponding server application, and the historical cache queue is the cache queue allocated to the server application in the historical stage; a first generation unit, used to generate the storage requirement information of the corresponding server application according to the historical queue usage parameters.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 10 when executed by a processor.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 10 are implemented.
Citation Information
Patent Citations
Log information processing method and device, electronic equipment and medium
CN115630033A