LogViewPlus Support

Use Pattern Parser with variable spaces count

https://www.logviewplus.com/forum/Topic1519.aspx

By dawsonp - 26 Aug 2022

Hi there. I have a problem when parsing logfiles that contain lines with a variable count of spaces between words. Our logging framework inserts a variable count of spaces (not tabs) between the loglevel and the message like in this example:

2022.07.06-00:33:10.511 - warn: A warning
2022.07.06-00:33:10.623 - info: Some info
2022.07.06-00:33:12.743 - error: This is an error

The error line has fewer spaces than info or warn lines. The only pattern for the pattern parser that works for me is:
%d{yyyy.MM.dd-HH:mm:ss.fff} - %p:%m%n

The only "problem" with this pattern is that the message is not trimmed meaning there are leading spaces. Is there a way to eliminate these leading spaces?
By LogViewPlus Support - 26 Aug 2022

Hi,

You can use a format modifier to specify a minimum length of 7 on the priority field.  For example:
%d{yyyy.MM.dd-HH:mm:ss.fff} - %7p %m%n



Technically, this sets the priority to a value which includes the colon (such as "info:"), but LogViewPlus is still able to work out the correct log value as priority lookups are prefix based.



Hope that helps,

Toby
By dawsonp - 26 Aug 2022

Thank you!  This approach didn't cross my mind but it does help. It is also kind of difficult because the preview of the pattern wizards does not show the correct result:


By LogViewPlus Support - 26 Aug 2022

Thanks for pointing this out - that is something I noticed as well.  I will take a look before the next release. 

In general, the Parser Wizard is best suited to common use cases.  Some edge cases are not supported and I appreciate this can cause confusion.  Where possible we try to address these issues as they arise.

Thanks again,

Toby