Forums Register Login

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

+Pie Number of slices to send: Send
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.

+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
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.
What's wrong? Where are you going? Stop! Read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1146 times.
Similar Threads
Getting log4j to write to multiple log files
Log4j doesn't split the log files as it supposed to
log4j problem: Multiple RollingFileAppender in an application
how to disable the log
How to hide/disable Hibernate log to console
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:30:57.