Skip to content

Custom log format: log-level is not mapped when the <level> field is on the second line of a multi-line RegEx #1108

@justusthane

Description

@justusthane

lnav version
v0.11.1

Describe the bug
Running into this issue when trying to create a custom log format for Java Tomcat logs.
I believe this is similar to the other multi-line issues, but with a twist. I'm able to use a multi-line RegEx in my custom log format and it seems to work properly (after making subsequent lines optional as per this comment), except the <level> field is not mapped to log_level when <level> does not appear on the first line of the message.

"regex" : {
    "basic" : {
        "pattern" : "^(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z)>>(.*?(?<level>\\w+)>>(?<component>\\w+)>>(?<body>.*))?$"
    }
},

This works, and correctly identifies the various fields:
image

However, lnav does not correctly apply the appropriate log level (i.e. error and warning messages are not highlighted). A SQL query shows that the log_level for all three messages is "info":

image

Contrast this with a similar example, except with the <level> field on the first line of the message:

"regex" : {
  "basic" : {
    "pattern" : "^(?<timestamp>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z)>>(?<level>\\w+)>>(.*?(?<component>\\w+)>>(?<body>.*))?$"
  }
},

In this case the error lines are correctly highlighted:

image

And an SQL query shows that the log_levels are correctly applied:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions