• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to write printstacktrace() to a file

 
Ranch Hand
Posts: 55
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody suggest me how to write the stack trace of the exception raised, to a file.

i am able to write the message etc. like e.getmessage(); but e.printstacktrace() is returning void but i am able to find that in the console,

so the same console i wanted to write to a file, instead.
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use a proper logging API like Log4J, configure a file appender and call one of the overloaded logging methods that accepts a Throwable.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or if you dont want that for whatever reason i cant think of
printStracktrace also accepts a printstream as parameter. thus you can create a printstream to a file and voila.
 
ilias basha
Ranch Hand
Posts: 55
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

you li wrote:or if you dont want that for whatever reason i cant think of
printStracktrace also accepts a printstream as parameter. thus you can create a printstream to a file and voila.



Thanks a lot!! for the direct answer
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic