What steps will reproduce the problem?
------------------------------------------------
1. configure a parser pattern like "THREAD PROP(01) PROP(02) PROP(03) PROP(04)
PROP(05) PROP(06) PROP(07) PROP(08) PROP(09) PROP(10)"
2. Load log file with one log entry using this pattern
What is the expected output? What do you see instead?
------------------------------------------------
A log entry should appear but doesn't.
What version of the product are you using? On what operating system?
------------------------------------------------
v1.2.0
Please provide any additional information below.
------------------------------------------------
The problem seems to be that you first of all replace all "PROP" keys and
enumerate them 0..10 when you build your regex in
pl.otros.logview.parser.log4j.Log4jPatternMultilineLogParser.initializePatterns(
). After that you replace all named keywords (e.g. THREAD) and replace them in
your regex.
After replacing all keywords with numerals the regex string from the above
example is:
'10[ ]+0[ ]+1[ ]+2[ ]+3[ ]+4[ ]+5[ ]+6[ ]+7[ ]+8[ ]+9'
Next you iterate over your buildingKeywords starting to replace the first entry
with index 0.
So you search for '0' in the above string and replace it. After this
replacement your string looks like:
'1(.*?)[ ]+0[ ]+1[ ]+2[ ]+3[ ]+4[ ]+5[ ]+6[ ]+7[ ]+8[ ]+9'
So you replaced the first '0' but that's a mistake because it's part of the
keyword with index 10. My workaround was to just change line 495 from
for (int i = 0; i < buildingKeywords.size(); i++) {
to:
for (int i = buildingKeywords.size()-1; i >= 0; i--) {
just traverse backwards which should fix this problem. Of course you can do it
different but it works for me now. Still I had a little bit trouble with line
444 which prevented my workaround first:
before (not working):
current = current.substring(longPropertyName.length() + 1 + index);
after fixing:
current = current.substring(longPropertyName.length() + index);
"+ 1 " was the problem here. If I appended a space at the end of my pattern it
worked but without it didn't.
I attached a further test case
pl.otros.logview.parser.log4j.Log4jPatternMultilineLogParserTest.testPattern_w_1
0_props() and attached a sample logfile.
This problem is not only restricted to "> 10 PROP keywords" in a pattern but
can appear in other constellations with more than 10 keywords in total.
Original issue reported on code.google.com by s.sta...@xeba.de on 28 Aug 2014 at 2:02
Original issue reported on code.google.com by
s.sta...@xeba.de
on 28 Aug 2014 at 2:02Attachments: