tstack / lnav

Log file navigator
http://lnav.org
BSD 2-Clause "Simplified" License
7.9k stars 314 forks source link

'hide-fields body' does not hide multi-line bodies #483

Open jefft opened 6 years ago

jefft commented 6 years ago

Hi,

Java apps love their stacktraces, and it would be glorious if lnav could collapse them.

I was hoping to achieve this with hide-fields body to hide the body field. Unfortunately this only hides the first line of body.

Take the example log file:

2017-12-19 09:05:50,430 ERROR Code threw exception
java.lang.NullPointerException
    at com.atlassian.confluence.image.effects.ImageFilterServlet.buildAttachmentContext(ImageFilterServlet.java:231)
    at com.atlassian.confluence.image.effects.ImageFilterServlet.doGetInTransaction(ImageFilterServlet.java:149)

I have extended the 'java_log' format to accept this multi-line format, by placing the following in ~/.lnav/formats/installed/multiline_java.json:

{
  "java_log" : {
    "regex" : {
      "multiline format" : {
                    "pattern" : "^(?<timestamp>\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}) (?<alert_level>\\w+) (?<body>(?:.|\\n)*)$"
      }
    }
  }

}

My sample file is now recognised as type java_log: image If I hit p I can see that body is correctly matching the multi-line string: image I then run hide-fields body and hit x, which gives me: image I would expect the whole stacktrace to be hidden.

nickpeirson commented 6 years ago

I've just run into this as well, doing pretty much the same thing. The only slight variation is that I've split the stacktrace into it's own field in the pattern match so I could hide the stack trace while leaving the body displaying. See this gist for the format I'm using.

The pattern matching works well, but issuing :hide-fields stacktrace does nothing. I long for the day I can hit x to toggle stack traces on and off!

jianhuiz commented 5 years ago

I have the same problem, we use glog but there are quite a few multi-line logs which prints dumped requests and responses. Alternatively, can we join the multi-line logs or fold them?

krenzlin commented 4 years ago

Any ideas/updates on this? Even a grep -v 'at ' would help taming these Java traces.