Are logs with different message formats supported in one file? #1255
-
For example, if logs from the entire system are collected into one file, the programs in which have their own format for recording messages. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Sorry, no, lnav expects a single format per file. There can be multiple regex patterns in a format, though. The reason is that lnav uses the regex patterns to find the start of a log message. If none of the patterns in a format match a given line, then it's considered a continuation of the current log message. Supporting multiple log formats in a single file would mean that we would have to try every single pattern whenever a mismatch occurred, which would seriously affect performance. |
Beta Was this translation helpful? Give feedback.
-
It may not have much impact, you just need to improve the string matching algorithm
Thus, if the file contains lines of only one format, then performance will not change. If the file contains lines of different formats, then the execution time of the program will slow down in the worst case by the number of formats times, provided that the lines are constantly interleaved. If the file contains wrap lines for which the simple invalid line condition is not met, then program execution will slow down by the number of such lines multiplied by the number of possible formats. Usually there are not many messages with line breaks in the logs. In any case, you can make this behavior optional and define it in the configuration. This will not be a problem for users who care about speed, because the option will be disabled by default. And for users who analyze small logs, but with different message formats, it will make their work easier. But if the problem is really solved by the ability to define several string formats in one file format, then there is no need to complicate the program logic. The only thing that would be appropriate is to supplement the log file format so that it can be composite and contain links to the file formats used in it. |
Beta Was this translation helpful? Give feedback.
Sorry, no, lnav expects a single format per file. There can be multiple regex patterns in a format, though.
The reason is that lnav uses the regex patterns to find the start of a log message. If none of the patterns in a format match a given line, then it's considered a continuation of the current log message. Supporting multiple log formats in a single file would mean that we would have to try every single pattern whenever a mismatch occurred, which would seriously affect performance.