Search code examples
regexlogparser

regex for logback log parsing


Why isn't the following

([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}) (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2},\d{3}) \[(.*?)\] ([^ ]*) +([^ ]*) - (.*)$

not matching any thing from the following

22bd49ad-eff4-4d20-b87d-eae1d0ab90e6 2015-12-28 13:28:19,025 [http-nio-8090-exec-3] DEBUG o.s.b.a.e.mvc.EndpointHandlerMapping apps : Did not find handler method for [/facets/apps/search]

EDIT: posting the correct link

Test linK https://regex101.com/r/lV4wU2/1


Solution

  • You can use this regex:

    ^[a-fA-F0-9]{8}(?:-[a-fA-F0-9]{4}){4}[a-fA-F0-9]{8} (\d{4}(?:-\d{2}){2}) ((?:\d{2}:){2}\d{2},\d{3}) \[(.*?)\] (\S*) +(\S*) [^:]*: (.*?)(?=\n[a-fA-F0-9]{8}|\z)
    

    RegEx Demo

    [^ ]* can be replaced by \S* in your regex and last part doesn't have hyphen.