• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Can I log my pintStackTrace () statement into log file?

 
Simpson Kumar
Ranch Hand
Posts: 261
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I have log4j.xml file with different levels like debug and error, when run the application i can see logs of debug, info, error, etc.. in one log file.

how can i separate error messages to another file?

How Can I log my pintStackTrace () statement into log file?

if i use e.printStackTrace() in java catch block, then I can see exception in console only, but I want to see it in log file.

 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How Can I log my pintStackTrace () statement into log file?
if i use e.printStackTrace() in java catch block, then I can see exception in console only, but I want to see it in log file.


The Logger has APIs which accept the exception object. The stacktrace will then be logged in the log file. See this and similar APIs
 
Simpson Kumar
Ranch Hand
Posts: 261
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Pai,

I followed the same thing, but I can's see the stack trace in log file, I just got exception only.

One more question. how can we separate error logs from general logs? i.e. I want to see errors in errorlog file.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic