log4j & stack traces

Notes, tips, and other usefull things on how to use LogMX

Moderator: admin

Post Reply
bedge
Posts: 10
Joined: Sun Aug 24, 2014 2:11 am

log4j & stack traces

Post by bedge »

I have a log4j parser setup and working fine, unless the file I try to load contains a stack trace.

eg:
  • 2014-08-20 19:15:05,003 ERROR qtp62367132-408 com.nim.aws.S3ContentRepo - Get versionList failed
    com.amazonaws.services.s3.model.AmazonS3Exception: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint. (Service: Amazon S3; Status Code: 301; Error Code: PermanentRedirect; Request ID: 9FDC1550CAF86ABE), S3 Extended Request ID: MD5o4O6pTGXrwCDUXLWtvxC9k8OHB/2PWLzBhtGqGHYAFlBIUt4jToqogLZsMBcq
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:937)
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:506)
Mu log4j parser os:

Code: Select all

%d{ISO8601} %p %t %c - %m%n
So the normal log messages work, but stack traces cause the file load to fail. In the case above it's assuming that "bucket" is a new log level.

How does one special case java stack traces?
admin
Site Admin
Posts: 555
Joined: Sun Dec 17, 2006 10:30 pm

Re: log4j & stack traces

Post by admin »

Hello,

I've just tested this log file with this Log4j Pattern, and it works great, using LogMX version 5.1.2.
In this log file you gave as example, LogMX detects one log entry, with an attached Stack trace, so it displays a single table row in main LogMX window, this row containing several lines (the first for the message "Get versionList failed", the others for stack trace)

To change the number of lines of text to display per table row, go to "Tools" > "Options" > "Display".

If LogMX still doesn't display several lines of text for this log entry, please tell us which version you are using.

Xavier
bedge
Posts: 10
Joined: Sun Aug 24, 2014 2:11 am

Re: log4j & stack traces

Post by bedge »

I've pruned down the log file such that it still generates the error and attached it, along with the error dialog and version info.
error dialog
error dialog
Screen Shot 2014-08-24 at 11.28.18 AM.png (24.64 KiB) Viewed 10646 times
error dialog
error dialog
Screen Shot 2014-08-24 at 11.28.00 AM.png (32.78 KiB) Viewed 10646 times
version info
version info
Screen Shot 2014-08-24 at 11.28.30 AM.png (43.21 KiB) Viewed 10646 times
bedge
Posts: 10
Joined: Sun Aug 24, 2014 2:11 am

Re: log4j & stack traces

Post by bedge »

Maxed out upload limit, log file attached here.
Attachments
log.zip
zipped log
(1.96 KiB) Downloaded 259 times
admin
Site Admin
Posts: 555
Joined: Sun Dec 17, 2006 10:30 pm

Re: log4j & stack traces

Post by admin »

OK, I reproduced your issue with your log file (for previous test, I was using a smaller stack trace).
I think I know what causes this issue. If I'm right, you simply have to go to "Tools" > "Options" > "Parsers", and enter the text "100" in the text field "Switch to next parser when no entry found after ... lines in file".
Indeed, with your log file beginning with this stack trace which contains 86 lines, the Parser needs a second log entry to send the first one to LogMX. So LogMX discards this Parser as soon as it reaches line 50 with the default parameter.
If you have a great number of enabled Parsers, you may issue a small performance penalty when opening log files if you use a too big number for this parameter (like say, greater than 100), because each Parser will parse the X first lines, as long as a suitable Parser has been found.

Note: From what I see in your screenshots, you are using a "Regular Expression" Parser. I don't know if you used such a Parser just for this test, but if your logs come from Log4j, it would be easier to use a "Log4j Pattern" Parser instead: you only have to specify your Log4j Pattern ("%d{ISO8601} %p %t %c - %m%n" in your case), and you are ready to go. If you're not sure how to use such a Parser, please let me know.

Xavier
bedge
Posts: 10
Joined: Sun Aug 24, 2014 2:11 am

Re: log4j & stack traces

Post by bedge »

The "Switch to next parser when no entry found after ... lines in file". was the problem.
I guess that needs to be longer than the length of a stack trace.

Thanks for the help, works perfectly now. Will be ordering shortly.
Post Reply