Use Pattern Parser with variable spaces count


Author
Message
Patrick Dawson
Patrick Dawson
New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)
Group: Forum Members
Posts: 5, Visits: 34
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?
LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
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
Patrick Dawson
Patrick Dawson
New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)New Member (17 reputation)
Group: Forum Members
Posts: 5, Visits: 34
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:



LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
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
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Login

Explore
Messages
Mentions
Search