Log collection method and device, equipment and medium
A collection method and collection device technology, applied in the computer field, can solve the problems of log collection tools such as single function, inflexible use, and low intelligence, and achieve the effect of high collection efficiency, powerful functions, and simple configuration
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0046] Such as figure 1 As shown, this embodiment provides a log collection method, including a collection process, the collection process includes the following steps:
[0047] S11, scan the log file under the specified directory every once in a while, after scanning to have the log file under the directory, set up a file read handle to the log file;
[0048] S12. Adjust the starting position of this reading according to the reading progress, and read the content of the log file from the starting position until the last line; specifically: the last time of the log file recorded according to the Meta file Read the content and line number to compare the latest content and line number of the log file, check the last reading progress, and adjust the starting position of this reading according to the following conditions according to the inspection result:
[0049] If the log content is only added, the starting position is the line next to the end line number of the last collecti...
Embodiment 2
[0065] Such as image 3 As shown, a log collection device (or collector) is provided in this embodiment, including:
[0066] The file scanner is used to scan the log files in the specified directory every once in a while. When the log files are found in the directory, a file read handle is established for the log files;
[0067] A file reader, configured to adjust the starting position of this reading according to the reading progress, and read the content 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: kv, split, and regex, and reserve a custom parsing interface; it can be filtered according to the log level and can be merged Exception stack log content, multiple lines are combined into one line of output, which is convenient for users to view stack information to locate problems;
[0069] The log outpu...
Embodiment 3
[0098] This embodiment provides an electronic device, such as Figure 5 As shown, it includes a memory, a processor, and a computer program stored in the memory and operable on the processor. When the processor executes the computer program, any implementation manner in Embodiment 1 can be realized.
[0099] Since the electronic device introduced in this embodiment is the device used to implement the method in Embodiment 1 of this application, based on the method described in Embodiment 1 of this application, those skilled in the art can understand the electronic device of this embodiment. Specific implementation methods and various variations thereof, so how the electronic device implements the method in the embodiment of the present application will not be described in detail here. As long as a person skilled in the art implements the equipment used by the method in the embodiment of the present application, it all belongs to the protection scope of the present application. ...
PUM
Login to View More Abstract
Description
Claims
Application Information
Login to View More 


