开发者

Logging in Java Desktop app

开发者 https://www.devze.com 2023-01-25 14:56 出处:网络
I\'m developing a Java desktop app and was wondering what are the best practices for logging bugs and exceptions. I\'d like to log the exceptions in a file that\'s sent to me when there\'s a p开发者_如

I'm developing a Java desktop app and was wondering what are the best practices for logging bugs and exceptions. I'd like to log the exceptions in a file that's sent to me when there's a p开发者_如何学JAVAroblem. Are there any good frameworks for doing this or is it a retarded idea? Thanks a lot

Elsanto 696


log4j is the de facto standard (with the standard Java logging framework a close second).

You should use Version 1.2.x for production use.

You can configure log4j via code (at runtime) or via a configuration file (either Java properties or XML format).

From the website:

The target of the log output can be a file, an OutputStream, a java.io.Writer, a remote log4j server, a remote Unix Syslog daemon, or many other output targets.

There is a SMTPAppender that can be configured for sending mails with log entries on specific conditions, in case eMail is what you meant by "sent to me".


log4J is better framework to log

Here is good tutorial and article on log4j


There are various Java Logging Frameworks out there. Pick one!

  • Log4J.
  • SLF4J.
  • LogBack.
  • java.util.logging.


Java4 Logging works pretty well, though it lacks some of the features in Log4j. The real problem is sending data from a user's PC to you directly - you would probably have to get their permission for this. The usual approach is to log to a file, and have the user give you that file in the event that there is a problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消