• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing to a log file  RSS feed

 
Sayantan Auddy
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way of writing errors to a log file that is a simple text file? Is using the java.util.logging package a good idea?
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there is a "best" way. The feature that util.logging and libraries like Log4J bring to the table is the ability to log at different levels (a DEBUG level for lots of information, INFO for some information, ERROR for just the errors) and to switch what levels are reported (or even what classes are reporting what level) without changing code or recompiling. If you don't need that feature, just opening a file and passing it around may be enough for your purposes. It is very handy, however, to not have to comment/uncomment code every time you go on a bug hunt.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!