• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing only the stack trace in log file  RSS feed

 
Rithanya Laxmi
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to create a log analyzer which parse the log files are retrive only the stack trace in the log file. The log file capacity is 800 kb.

1) What is the best way of parsing the log file and retrieve only the stack trace in java? I know we need to use IO package ?
2) Is there any better way to parse only the respective stack trace rather than parsng the whole log file line by line?
3) To parse the stack trace alone, how will we identify the stacktrace to be retrived as there is no delimeter associated with the stack trace?
4) To to parse the stack trace is there a way to use the regular expression to retrive only stack trace?

Please shed some light into this? any links/code is highly appreciated.

Thanks.
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) What is the best way of parsing the log file and retrieve only the stack trace in java? I know we need to use IO package ?

Basically you have to read the file line by line and identify the start and end of the stack trace sections.

2) Is there any better way to parse only the respective stack trace rather than parsng the whole log file line by line?

Unless you can send the stack trace to some other file or intercept it as it is written to the log file (which probably means changing your program) then no.

3) To parse the stack trace alone, how will we identify the stacktrace to be retrived as there is no delimeter associated with the stack trace?

Without seeing the format of the log file it's hard to say but generally you have to look for some unique feature that identifies the bits you want.

4) To to parse the stack trace is there a way to use the regular expression to retrive only stack trace?

See the answer above, but probably.
 
Rithanya Laxmi
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. Below is the stack trace:-

.....
2012-08-10 08:19:17 java.lang.NullPointerException
2012-08-10 08:19:17 at net.minecraft.server.World.tickEntities(World.java:1146)
2012-08-10 08:19:17 at net.minecraft.server.MinecraftServer.q(MinecraftServer.java:567)
2012-08-10 08:19:17 at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:212)
2012-08-10 08:19:17 at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:476)
2012-08-10 08:19:17 at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:408)
2012-08-10 08:19:17 at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
...
....

How to parse only the stack trace using regex? If i have put the stacktrace to a separate log file, what config needs to be done in log4j to capture only the stack trace?
 
Rithanya Laxmi
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys any response for this?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!