regexlogparserlog-viewerlogmx

Issue with LogMX Regular Expression Parser


We are using LogMX log viewer to monitor our application logs, using a Regular Expression Parser.

Every time a log message contains the "-" character, LogMX doesn't parse the log event as expected.

For example, the following log event:

[ERROR] | com.nsoft.gmonitor.Controller - File Loader - Error while loading file "C:\GMonitor\prefs.properties - Copy"

Is parsed as:

Instead of:

We are using the following regexp:

\[(.*)\] \| (.*) - (.*) - (.*)

Thank you for your help.


Solution

  • You should use this regexp instead:

    \[(.*)\] \| (.*?) - (.*?) - (.*)

    I just added a ? character after .* for 'Emitter' and 'Thread' fields/groups. This is a common regular-expression issue (not specific to LogMX):

    You can read more about this in JDK API (search for 'greedy') or LogMX docs.

    PS : if you don't want to use regular expressions to parse your logs in LogMX, you could use its "Log4j/Logback pattern Parsers" instead: the pattern [%p] | %c - %t - %m will match your need, and is reluctant by default for all fields/groups by default.