This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 9962
    
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Can I log my pintStackTrace () statement into log file?
 
Similar Threads
log4j problem: Multiple RollingFileAppender in an application
How to hide/disable Hibernate log to console
log4j not logging
Log4j doesn't split the log files as it supposed to
Getting log4j to write to multiple log files