Log management method and device, electronic equipment, storage medium and product
By copying the log file to the backup file and setting it empty, combined with process control, the problem that the internal logic of the log producer does not support loop saving is solved, and efficient log management is achieved, avoiding system crashes and not affecting business processes.
Patent Information
- Application Number
- CN202510336805.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-07-04
AI Technical Summary
In the prior art, some log producers do not support the log loop storage mechanism because the internal logic does not support the log loop storage mechanism, resulting in unlimited growth of log files, affecting system stability. Existing solutions such as restarting services or signal triggering mechanisms are not applicable to some log producers, and cannot effectively solve the log loop storage requirements and do not affect business operations.
Copy the original log file of the target log producer to the backup log file through preset trigger conditions, and perform emptying operations on the original log file after copying, combining the process suspension and recovery mechanism to ensure that the log file does not grow without limit.
It realizes the solution to the log circular storage requirements, without restarting the service, avoiding the impact on business operations, and is suitable for log management requirements in different scenarios.
Smart Images

Figure CN120256198A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a log management method, apparatus, electronic device, storage medium and product. Background Art
[0002] In the prior art, some log producers (such as processes) fixedly output the generated log data to a single log file. And due to reasons such as program development defects, the internal logic of such log producers itself does not support the log cyclic storage mechanism. Therefore, as the log producer continuously runs, the size of the log file will grow without limit, which may affect the stability of the system if not handled.
[0003] One existing solution is to restart the service of the log producer to switch to a new log file for storage. However, this method requires restarting the service, which will inevitably affect the business operation of the log producer. The other is to use an additional message / signal triggering mechanism to switch the log producer to a new log file for storage. However, this method is not applicable to log producers that do not support the message / signal triggering mechanism. In summary, how to meet the log cyclic storage requirement of the above log producers without affecting the business operation has become an urgent technical problem to be solved. Summary of the Invention
[0004] The present invention provides a log management method, apparatus, electronic device, storage medium and product to meet the log cyclic storage requirement of log producers without affecting their business operation.
[0005] According to one aspect of the present invention, there is provided a log management method, which includes:
[0006] Copy the original log file of the target log producer to a backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic itself does not support the log cyclic storage mechanism;
[0007] Perform an emptying operation on the original log file after the copying is completed.
[0008] In one embodiment, the target log producer includes a target process, and the method further includes:
[0009] Control the suspension and recovery of the target process.
[0010] In one embodiment, before copying the original log file to the backup log file, it includes:
[0011] Control the suspension of the target process.
[0012] In one embodiment, after copying the original log file to the backup log file, it includes:
[0013] Determine the offset corresponding to the newly added log data in the original log file;
[0014] Control the target process to suspend;
[0015] Write the newly added log data to the backup log file according to the offset.
[0016] In one embodiment, when writing the newly added log data to the backup log file according to the offset, it further includes:
[0017] Add a timeout detection mechanism to the write operation of the newly added log data.
[0018] In one embodiment, after performing the nulling operation on the original log file after copying is completed, it includes:
[0019] Control the target process to resume.
[0020] According to another aspect of the present invention, there is provided a log management device, which includes:
[0021] A log copy module, configured to copy the original log file of the target log producer to the backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data to a single log file, and its internal logic does not support the log cyclic storage mechanism;
[0022] A file nulling module, configured to perform a nulling operation on the original log file after copying is completed.
[0023] According to another aspect of the present invention, there is provided an electronic device, and the electronic device includes:
[0024] At least one processor; and
[0025] A memory communicatively connected to the at least one processor; wherein,
[0026] The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor can execute the log management method according to any embodiment of the present invention.
[0027] According to another aspect of the present invention, there is provided a computer-readable storage medium, and the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the processor to implement the log management method according to any embodiment of the present invention when executed.
[0028] According to another aspect of the present invention, there is provided a computer program product, which includes a computer program that, when executed by a processor, implements the log management method according to any embodiment of the present invention.
[0029] The log management method provided by the embodiments of the present invention copies the original log file of the target log producer to the backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support the log cyclic storage mechanism; an emptying operation is performed on the original log file after the copying is completed. By using this method, the log cyclic storage requirement of this type of log producer whose internal logic does not support the log cyclic storage mechanism can be solved, and there is no need to restart the service, so it will not affect the business operation of the log producer.
[0030] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can obtain other drawings without creative efforts based on these drawings.
[0032] Figure 1 is a flowchart of a log management method provided by Embodiment 1 of the present invention;
[0033] Figure 2 is a flowchart of a log management method provided by Embodiment 2 of the present invention;
[0034] Figure 3 is a flowchart of another log management method provided by Embodiment 2 of the present invention;
[0035] Figure 4 is a flowchart of yet another log management method provided by Embodiment 2 of the present invention;
[0036] Figure 5 is a schematic structural diagram of a log management device provided by Embodiment 3 of the present invention;
[0037] Figure 6 is a schematic structural diagram of an electronic device that implements the log management method of the embodiments of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0038] To enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
[0039] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0040] Embodiment 1
[0041] Figure 1 As shown in the flowchart of a log management method provided in Embodiment 1 of the present invention, this embodiment is applicable to a type of target log producer that can only write the generated log data into a single log file and whose internal logic does not support the log cyclic storage mechanism, and solves the situation of its log cyclic storage requirement. This method can be executed by a log management device, which can be implemented in the form of hardware and / or software. The log management device can be configured in an electronic device, and the electronic device can include, but is not limited to, a computer, a server, etc. As Figure 1 shown, a log management method provided in Embodiment 1 specifically includes the following steps:
[0042] S110. Copy the original log file of the target log producer to the backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support the log cyclic storage mechanism.
[0043] Among them, the preset trigger condition can be understood as a condition for triggering the log cyclic storage process of the target log producer. Exemplarily, the preset trigger condition can include, but is not limited to: reaching the preset log cyclic storage period, detecting that the file size of the original log file reaches the preset threshold, etc.
[0044] A target log producer can be understood as a special type of log producer that, at the beginning of design and development, did not effectively design the automated logic for cyclic log storage. Such producers can only write the generated log data into a single fixed file all the time, and their internal logic does not support the cyclic log storage mechanism. For example, they do not support receiving specific messages or signals for internal logic processing to use a new log file, etc. In one embodiment, the target log producer can include processes, applications, system components, etc. that have a need for cyclic log storage.
[0045] The original log file can refer to the log file used by the target log producer, that is, the log file where it fixedly writes. The backup log file can refer to the file used to temporarily store the copied data in the original log file. That is, the log data in the original log file will be uniformly copied to the backup log file for temporary storage, and then the backup log file can be further processed for unified archiving, deletion, etc.
[0046] In the embodiment of the present invention, for a target log producer that can only write the generated log data into a single log file and whose internal logic does not support the cyclic log storage mechanism, it is possible to monitor the log storage situation of the target log producer, and when it is detected that a preset trigger condition is met, such as the file size of the original log file reaches a preset threshold, all the log data in the original log file corresponding to the target log producer is copied to a pre-created backup log file. In a specific embodiment, the cp command can be used to copy the original log file to the backup file.
[0047] S120. Perform an emptying operation on the original log file after the copying is completed.
[0048] Among them, the emptying operation can be understood as the data emptying operation performed on the original log file.
[0049] In the embodiment of the present invention, after all the log data in the original log file is written into the backup log file, an emptying operation can be performed on the copied original log file, so as to empty the log data in the original log file. In this way, the target log producer will start from an empty file and continuously save the generated log data. This embodiment uses the emptying operation to effectively ensure that the size of the original log file used by the target log producer will not grow without limit, thereby avoiding the problem of system crash caused by the local storage being full. In a specific embodiment, the echo, truncate, etc. commands can be used to perform the emptying operation on the original log file.
[0050] The log management method provided by the embodiments of the present invention copies the original log file of the target log producer to the backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support the log cyclic storage mechanism; after the copying is completed, the original log file is emptied. By using this method, the log cyclic storage requirement of this type of log producer whose internal logic does not support the log cyclic storage mechanism can be solved, and the service does not need to be restarted, so it will not affect the business operation of the log producer.
[0051] Further, on the basis of the above-mentioned embodiments of the invention, the target log producer includes a target process, and the method further includes: controlling the suspension and recovery of the target process.
[0052] Among them, process suspension refers to a process state, indicating that the process temporarily stops execution and does not restart the process, similar to a "breakpoint"; after the process is resumed, the program will still continue to execute from the "breakpoint" and will not interrupt the normal process of the program. Exemplarily, there is a program with steps s1, s2, s3, s4, s5. When the process is suspended when executing to s3, the program will pause at s3. When the process is resumed, the program will continue to execute from s3. This process will not affect the transaction being executed by the process, will not restart the process, and will not affect the normal program flow of the process.
[0053] In the above-mentioned embodiments of the invention, after copying the original log file of the target log producer to the backup log file, by emptying the original log file, the requirement for log cyclic storage of the target log producer can be efficiently solved, but this method needs to pay the price of losing a small amount of log data. The reason is that during the process of copying the original log file to the backup log file and emptying the original log file, the target log producer will continue to write log data into the original log file, and the newly added log data during this period is not copied to the backup log file, resulting in a small amount of log data loss. Therefore, this solution is more suitable for scenarios where the importance of the log is not high and the log production time period is controllable. To solve the above problem of losing log data, in the case where the target log producer includes a target process, the process of suspending and resuming the process can be added to the above-mentioned log management method, so as to meet the requirement of not losing log data.
[0054] In one embodiment, a log management method for process suspension and process recovery is added, which may include the following processes: controlling the suspension of a target process according to a preset trigger condition; copying the original log file of the target process to a backup log file; performing a nulling operation on the original log file after the copying is completed; and controlling the recovery of the target process. It can be understood that in the above method, the suspension time of the target process is the sum of the log file copying time and the time for performing the nulling operation. This method will not lose logs and is applicable to scenarios where the log size is controllable and the log backup time is predictable.
[0055] In another embodiment, a log management method for process suspension and process recovery is added, which may include the following processes: copying the original log file of the target process to a backup log file according to a preset trigger condition; determining the offset corresponding to the newly added log data in the original log file; controlling the suspension of the target process; writing the newly added log data to the backup log file according to the offset; setting the original log file used by the target process to be empty; and controlling the recovery of the target process. It can be understood that in the above method, the suspension time of the target process is the sum of the copying time of the newly added log data and the time for performing the nulling operation. Therefore, the suspension time of the process is shorter and the impact on business operation is smaller. This method also will not lose logs and is applicable to most scenarios where the log production speed is controllable.
[0056] Further, based on the above invention embodiments, when writing the newly added log data to the backup log file according to the offset, it further includes: adding a timeout detection mechanism to the write operation of the newly added log data.
[0057] In the embodiments of the present invention, during the process of copying the newly added log data, a timeout detection mechanism can also be added, that is, setting a timeout time for the copying time of the newly added log data, such as 5 seconds, and terminating the current log cyclic storage process if the time is exceeded. By adding a timeout detection mechanism, the suspension time of the process can be made more controllable and is applicable to scenarios where the log production speed is controllable and the process suspension time is sensitive.
[0058] Further, based on the above invention embodiments, after obtaining a new backup log file, further processing can be performed on the backup log file, such as compression and storage, archiving, deletion, etc. The specific processing process is not specifically limited in this embodiment.
[0059] In one embodiment, the log management method provided by the embodiments of the present invention can be applied to a distributed system and can be deployed on the corresponding node of a target log producer with a log cyclic storage requirement.
[0060] Embodiment 2
[0061] Figure 2The flowchart of a log management method provided in the second embodiment of the present invention is optimized and extended based on the above-mentioned implementation manner, and can be combined with each optional technical solution in the above-mentioned implementation manner. As Figure 2 shown, a log management method provided in the second embodiment of the present invention specifically includes the following steps:
[0062] S210. In response to the trigger of a preset trigger condition, copy the original log file of the target process to a backup log file.
[0063] In the embodiment of the present invention, the following command can be used: cp / var / log / app.log / var / log / app.log.1 to copy the original log file / var / log / app.log of the target process to the backup log file / var / log / app.log.1. It should be understood that at this time, the file descriptor (fd) of the target process still uses the original log file / var / log / app.log, and the log data generated by the process will still be written to the original log file; in addition, when the process runs, it uses the fd of the operating system for reading and writing, rather than directly operating on the file. This belongs to the prior art and will not be elaborated here.
[0064] S220. Set the original log file used by the target process to be empty.
[0065] In the embodiment of the present invention, the following command can be used: echo > / var / log / app.log to perform an emptying operation on the original log file / var / log / app.log after copying. Through the emptying operation, it can effectively prevent the original log file used by the target process from growing without limit, and subsequently the target process will use the empty original log file for reading and writing.
[0066] It should be understood that during the execution of steps S210 and S220, the log data newly generated by the target process is the lost content.
[0067] S230. Process the new backup log file.
[0068] In the embodiments of the present invention, operations such as compressing and saving, and archiving the backup log files can be triggered according to a preset time interval or the size of the backed-up logs. Exemplarily, compression and saving can be performed on a weekly granularity (from Monday to Sunday). The log file can be packaged into an archive file through the following command: tar cvf / var / log / app.log.$(date +%w).tar / var / log / app.log.1, and the current day of the week is used as part of the file name, where $(date +%w) represents obtaining the week date of the current day. After the log archiving is completed, / var / log / app.log.1 can be deleted. Further, the archive file can also be stored in the cloud, for example, using object storage, etc., and this embodiment does not make specific limitations on this.
[0069] The above log management method has the main advantage of being simple and efficient and having no impact on the process at the cost of losing some logs, and is suitable for processes where the importance of logs is not high and the log output time period is controllable.
[0070] Figure 3 It is a flowchart of another log management method provided in the second embodiment of the present invention. As Figure 3 shown, the log management method specifically includes the following steps:
[0071] S310. In response to the triggering of a preset trigger condition, control the target process to suspend.
[0072] In the embodiments of the present invention, the following command can be used: kill - SIGSTOP {pid} to perform a suspension operation on the target process, where pid is the id number of the target process to be suspended.
[0073] S320. Copy the original log file of the target process to the backup log file.
[0074] S330. Set the original log file used by the target process to be empty.
[0075] S340. Control the target process to resume.
[0076] In the embodiments of the present invention, the following command can be used: kill - SIGCONT {pid} to perform a resume operation on the target process. In addition, the total execution time of steps S320 and S330 is the suspension time of the target process.
[0077] S350. Process the new backup log file.
[0078] The above log management method will not lose logs and is applicable to scenarios where the log size is controllable and the log backup time is predictable. When the log backup time is long and the business is highly sensitive to the process suspension time, the execution frequency can be increased or the following log management method can be adopted.
[0079] Figure 4 It is a flowchart of another log management method provided in the second embodiment of the present invention. As Figure 4 shown, the log management method specifically includes the following steps:
[0080] S410. In response to the trigger of a preset trigger condition, copy the original log file of the target process to the backup log file.
[0081] S420. Determine the size of the backup log file.
[0082] In the embodiment of the present invention, after the copying of the original log file is completed, the file size of the backup log file app.log.1 can be determined to facilitate subsequent determination of the offset corresponding to the newly added log data.
[0083] S430. Control the suspension of the target process.
[0084] S440. Write the newly added log data into the backup log file according to the size of the backup log file.
[0085] In the embodiment of the present invention, based on the file size of the backup log file app.log.1 determined in S420, the log data copied in S410 can be skipped, and the newly added log data generated during the execution of S410 can be written into the backup log file in an append manner. For example, it can be implemented using the following command: timeout 5dd if = "${arg_logfile}" bs = 1 skip = ${target_cpsize} >> "${target_logfile}", where timeout 5 indicates that the timeout for copying the newly added log data is 5 seconds, and the backup is abandoned if the time is exceeded; ${arg_logfile} represents the log file used by the process, that is, the original log file app.log; ${target_cpsize} represents the file size of the backup log file determined in S420; ${target_logfile} represents the backup log file app.log.1.
[0086] It can be understood that if S440 is successfully executed, that is, the copying time of the newly added log data does not exceed the preset timeout, the uncompleted log cycle storage process is executed downward; if S440 is not successfully executed, that is, the copying times out, the current log cycle storage process is directly ended.
[0087] S450. Set the original log file used by the target process to be empty.
[0088] S460. Control the target process to resume.
[0089] It can be seen that the suspension time of the target process is the total execution time of steps S440 and S450. Compared with the amount of log data copied in S410, the amount of log data copied in S440 has been greatly reduced. Coupled with the introduced timeout detection mechanism, the process suspension time can be made more controllable.
[0090] S470. Process the new backup log file.
[0091] The above log management method will not lose logs either and is applicable to most scenarios where the log production speed is controllable.
[0092] It can be understood that due to the different services carried by the processes, some attach importance to log content, some have significant peak and off-peak periods, and some are more sensitive. The three log management methods provided in the second embodiment can cover the vast majority of usage scenarios, and appropriate log cyclic storage methods can be selected in actual applications to meet the corresponding service requirements.
[0093] Embodiment 3
[0094] Figure 5 FIG. is a schematic structural diagram of a log management device provided in Embodiment 3 of the present invention. As Figure 5 shown, the log management device includes:
[0095] A log copy module 51, configured to copy the original log file of the target log producer to a backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support a log cyclic storage mechanism;
[0096] A file emptying module 52, configured to perform an emptying operation on the original log file after copying is completed.
[0097] The technical solution of the embodiment of the present invention copies the original log file of the target log producer to a backup log file through the log copy module according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support a log cyclic storage mechanism; the file emptying module performs an emptying operation on the original log file after copying is completed. Using this method, the log cyclic storage requirement of this type of log producer whose internal logic does not support the log cyclic storage mechanism can be solved, and the service does not need to be restarted, so it will not affect the business operation of the log producer.
[0098] Further, based on the above-described embodiments of the invention, the target log producer includes a target process, and the apparatus further includes:
[0099] A process suspension and resume control module, configured to control the suspension and resume of the target process.
[0100] Further, based on the above-described embodiments of the invention, the log management apparatus further includes:
[0101] A first process suspension control module, configured to control the suspension of the target process before copying the original log file to the backup log file.
[0102] Further, based on the above-described embodiments of the invention, the log management apparatus further includes:
[0103] An offset determination module, configured to determine the offset corresponding to the newly added log data in the original log file after copying the original log file to the backup log file;
[0104] A first process suspension control module, configured to control the suspension of the target process;
[0105] A data writing module, configured to write the newly added log data to the backup log file according to the offset.
[0106] Further, based on the above-described embodiments of the invention, the data writing module further includes:
[0107] A timeout detection unit, configured to add a timeout detection mechanism to the write operation of the newly added log data.
[0108] Further, based on the above-described embodiments of the invention, the log management apparatus further includes:
[0109] A process resume control module, configured to control the resume of the target process after performing a nullifying operation on the original log file after copying is completed.
[0110] The log management apparatus provided by the embodiments of the present invention can execute the log management method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.
[0111] Embodiment 4
[0112] Figure 6FIG. 0 shows a schematic structural diagram of an electronic device 60 that can be used to implement embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0113] As Figure 6 shown, the electronic device 60 includes at least one processor 61, and a memory communicatively connected to the at least one processor 61, such as a read-only memory (ROM) 62, a random access memory (RAM) 63, etc. The memory stores a computer program executable by the at least one processor. The processor 61 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 62 or the computer program loaded from the storage unit 68 into the random access memory (RAM) 63. In the RAM 63, various programs and data required for the operation of the electronic device 60 can also be stored. The processor 61, the ROM 62, and the RAM 63 are connected to each other through a bus 64. The input / output (I / O) interface 65 is also connected to the bus 64.
[0114] Multiple components in the electronic device 60 are connected to the I / O interface 65, including: an input unit 66, such as a keyboard, a mouse, etc.; an output unit 67, such as various types of displays, speakers, etc.; a storage unit 68, such as a magnetic disk, an optical disk, etc.; and a communication unit 69, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 69 allows the electronic device 60 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0115] The processor 61 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 61 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 61 executes the various methods and processes described above, such as the log management method.
[0116] In some embodiments, the log management method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 68. In some embodiments, part or all of the computer program may be loaded and / or installed onto the electronic device 60 via the ROM 62 and / or the communication unit 69. When the computer program is loaded into the RAM 63 and executed by the processor 61, one or more steps of the log management method described above may be performed. Alternatively, in other embodiments, the processor 61 may be configured to execute the log management method by any other suitable means (e.g., by means of firmware).
[0117] The various embodiments of the systems and techniques described above in this document may be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on a chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: being implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0118] In some embodiments, the log management method may be implemented as a computer program invisibly embodied in a computer program product. The computer program implements the log management method of the present invention when executed by a processor. The computer program product may be understood as a software product that mainly implements its solution through the computer program. The computer program for implementing the method of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0119] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0120] In order to provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, speech input, or tactile input).
[0121] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0122] A computing system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The relationship between the client and the server is created by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0123] It should be understood that various forms of processes shown above can be used, steps can be reordered, added or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.
[0124] The above specific embodiments do not constitute a limitation to the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A log management method, characterized in that, The method includes: Copying the original log file of the target log producer to a backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support the log cyclic storage mechanism; Performing a nulling operation on the original log file after the copying is completed.
2. The method according to claim 1, characterized in that The target log producer includes a target process, and the method further includes: Controlling the suspension and resumption of the target process.
3. The method according to claim 2, characterized in that Before copying the original log file to the backup log file, it includes: Controlling the suspension of the target process.
4. The method according to claim 2, wherein After copying the original log file to the backup log file, it includes: Determining the offset corresponding to the newly added log data in the original log file; Controlling the suspension of the target process; Writing the newly added log data to the backup log file according to the offset.
5. The method according to claim 4, wherein The writing of the newly added log data to the backup log file according to the offset further includes: Adding a timeout detection mechanism to the writing operation of the newly added log data.
6. The method according to claim 2, characterized in that, After performing the nulling operation on the original log file after the copying is completed, it includes: Controlling the resumption of the target process.
7. A log management device, characterized in that, The apparatus includes: A log copying module, configured to copy the original log file of the target log producer to a backup log file according to a preset trigger condition; wherein, the target log producer has the following characteristics: it can only write the generated log data into a single log file, and its internal logic does not support the log cyclic storage mechanism; A file nulling module, configured to perform a nulling operation on the original log file after the copying is completed.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the log management method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the processor to implement the log management method according to any one of claims 1-6 when executed.
10. A computer program product, characterized in that, The computer program product includes a computer program, and the computer program implements the log management method according to any one of claims 1-6 when executed by the processor.