Skip to content

Instantly share code, notes, and snippets.

@skowron-line
Last active December 30, 2023 18:58
Show Gist options
  • Save skowron-line/000733c361f63206cc9e to your computer and use it in GitHub Desktop.
Save skowron-line/000733c361f63206cc9e to your computer and use it in GitHub Desktop.
lnav Monolog format
{
"monolog": {
"title": "Monolog log file",
"description": "Monolog log format",
"url": "https://github.com/Seldaek/monolog",
"regex": {
"default": {
"pattern": "\\[(?P<timestamp>.*)\\] (?P<logger>\\w+).(?P<level>\\w+): (?P<message>[^\\[\\{]+) (?P<context>[\\[\\{].*[\\]\\}]) (?P<extra>[\\[\\{].*[\\]\\}])"
}
},
"level-field" : "level",
"level" : {
"error" : "ERROR",
"debug" : "DEBUG",
"info" : "INFO",
"warning" : "WARNING"
},
"value": {
"logger": {
"kind": "string",
"identifier": true
},
"level": {
"kind": "string",
"identifier": true
},
"message": {
"kind": "string"
},
"context": {
"kind": "string"
},
"extra": {
"kind": "string"
}
},
"sample": [
{
"line": "[2015-08-10 15:05:12] event.DEBUG: Notified event \"kernel.terminate\" to listener \"Symfony\\Component\\HttpKernel\\EventListener\\ProfilerListener::onKernelTerminate\". [] []"
}
]
}
}
@skowron-line
Copy link
Author

Instalation lnav -i monolog.json

@SourceCode
Copy link

Thanks for this!

@marcin-jozwikowski
Copy link

Works perfect! Thanks!

@MisatoTremor
Copy link

Thanks!

@pnoeric
Copy link

pnoeric commented Jul 24, 2019

Great, just what I needed... thanks for figuring this out and sharing it. E

@ostrolucky
Copy link

ostrolucky commented Apr 21, 2020

Unfortunately I am not sure this is much of an improvement.

Before:
Screenshot 2020-04-21 at 21 05 53
After
Screenshot 2020-04-21 at 21 05 25

So alright, it recognizes level now, but highlighting of enquoted strings and most importantly JSON parts is missing now.

@mitjafelicijan
Copy link

I am getting this error.

lnav -i monolog.json logs/application.log
info: installed: /home/m/.lnav/formats/installed/monolog.json
warning:logs/application.log:line 1
warning:  unexpected path --
warning:    #
warning:  accepted paths --
warning:    /(?<format_name>\w+)/  -- The definition of a log file format.
error:logs/application.log:1:invalid json -- parse error: after array element, I expect ',' or ']'
                                [2020-12-26 06:15:06] application
                     (right here) ------^

@ostrolucky
Copy link

I've created https://github.com/ostrolucky/lnav-formats as a replacement of this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment