A log collection method, device, device and medium
A collection method and log technology, which is applied in the computer field, can solve the problems of log collection tools such as single function, inflexible use, and difficult maintenance, and achieve the effect of high collection efficiency, powerful functions, and convenient maintenance
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0046] like figure 1 As shown, this embodiment provides a log collection method, including a collection process, and the collection process includes the following steps:
[0047] S11. Go to the specified directory to scan log files every once in a while, and after scanning a log file in the directory, create a file read handle for the log file;
[0048] S12, adjust the starting position of the current reading according to the reading progress, and read the content of the log file from the starting position until the last line; specifically: according to the last time of the log file recorded in the Meta file Read the content and line number to compare the latest content and line number of the log file, check the progress of the last reading, and adjust the starting position of the current reading according to the following conditions:
[0049] If the log content is only newly added, the starting position is the next line of the last collected end line number;
[0050] If the...
Embodiment 2
[0065] like image 3 As shown, in this embodiment, a log collection device (or collector) is provided, including:
[0066] The file scanner is used to scan log files in the specified directory at regular intervals. After scanning the log files in the directory, create a file read handle for the log files;
[0067] A file reader, used to adjust the starting position of the current reading according to the reading progress, and read the contents of the log file from the starting position until the last line;
[0068] The log parser is used to parse the read content according to the customized parsing rules; the parsing rules currently support three parsing rules of kv, split, and regex, and a custom parsing interface is reserved; it can be filtered according to the log level, and can be merged Exception stack log content, combine multiple lines into one line for output, which is convenient for users to view stack information to locate problems;
[0069] The log outputter is us...
Embodiment 3
[0098] This embodiment provides an electronic device, such as Figure 5 As shown, a memory, a processor, and a computer program stored in the memory and running on the processor are included. When the processor executes the computer program, any implementation manner of the first embodiment can be implemented.
[0099] Since the electronic device introduced in this embodiment is the device used to implement the method in the first embodiment of the present application, based on the method introduced in the first embodiment of the present application, those skilled in the art can understand the electronic device in this embodiment. The specific implementation manner and various modifications thereof, so how the electronic device implements the methods in the embodiments of the present application will not be described in detail here. As long as the devices used by those skilled in the art to implement the methods in the embodiments of the present application fall within the sco...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


