Two questions
Hi,
Got two questions:
- Is it possible to skip formatters at all? Just show log lines
as is(with optional ascii coloring), but use all benefits of lnav? - Is it possible to set the
line formatfor non-json log formats?
- Is it possible to skip formatters at all? Just show log lines as is (with optional ascii coloring), but use all benefits of lnav?
If a file does not match a log format, it is shown in the TEXT view. But, the majority of features will not work. Most parts of lnav depend on knowing where a log message starts and stops as well as the timestamp. The log format defines the patterns that denote the start of a log message.
- Is it possible to set the line format for non-json log formats?
Not at the moment. Issue #1309 tracks this request.
Most parts of lnav depend on knowing where a log message starts and stops as well as the timestamp.
Is it possible to add a super-minimal formatter that just has one regex for the timestamp extraction and consider the end of line as the stop of the message?
Is it possible to add a super-minimal formatter that just has one regex for the timestamp extraction and consider the end of line as the stop of the message?
The builtin generic_log format has a bunch of regexes to try to capture really basic shapes of log messages.
Otherwise, I would say it's pretty straightforward to create a custom log format using the regex101 integration:
- Find a log line that is representative
- Ask chatgpt to create a regex from that log line
- Copy the regex and sample line into regex101
- Tweak the regex, if necessary
- Save the regex in regex101 to create a unique URL
- Run
lnav -m regex101 import <regex101-url> mylog(after replacing the URL) to create the format file
(I think I recently tried asking chatgpt to create the lnav format file, but it didn't do it right...)
it's pretty straightforward to create a custom log format
I agree, it is not hard. Though I found a few unfortunate glitches:
-
sometimes
lnavpermanently hangs (closing the terminal is the only fix) -
sometimes
lnavfalls back to thesyslog_logformatter, though I have a plain text logs such as:2025-09-01T17:42:50.875833+0300 DEBUG tokio-runtime-worker backend::client: macos: >>> Data { None }I think this could be fixed using explicit formatter like
lnav -m some_formatter. -
and the most annoying one: I can't set custom format for the text logs, which you mentioned in the answer to the second question.
Except for that, the lnav is awesome! Thanks!
- sometimes lnav permanently hangs (closing the terminal is the only fix)
That sounds bad, can you give some details? What version are you running? If you pass -d /tmp/lnav.dbg to lnav, it will generate a debug log that might tell me what's wrong.
- sometimes lnav falls back to the syslog_log formatter, though I have a plain text logs such as:
Hmm, the line you gave is detected as generic_log for me. Anyhow, making the format's regex more specific can help fix issues like this. If the regex is more specific than ones in other formats, it will be tested before the others.
If you want to attach the format you're trying and some sample logs to this issue, I can take a look at it.
I think this could be fixed using explicit formatter like lnav -m some_formatter.
See this FAQ entry