aspose file tools*
The moose likes Other Open Source Projects and the fly likes How Can I log my pintStackTrace () statement into log file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How Can I log my pintStackTrace () statement into log file?" Watch "How Can I log my pintStackTrace () statement into log file?" New topic
Author

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

Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
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.



Thanks,
Kumar
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10048
    
163

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


[My Blog] [JavaRanch Journal]
Simpson Kumar
Ranch Hand

Joined: Mar 19, 2008
Posts: 261
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How Can I log my pintStackTrace () statement into log file?