开发者

Advantages and disadvantages of using log4j [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I have been told to use log4j for my logging project,but before using log4j, i wanted to know what all are its disadv开发者_JAVA百科antages, so that i can find some solution to do away with those disadvantages.


If I would be starting a new project today I'd use SLF4J for the logging. This is a simple API which sits in between your program and the logging library that you use. Your program will use the SLF4J API, which passes the calls to the actual logging library that you plug in. You can use different logging libraries with SLF4J (for example Log4J or java.util logging), and you can switch to a different logging library without changing anything to your own source code.

There is a "native" implementation of the SLF4J API called Logback. Last year I was on a project in which we decided to switch from Log4J to Logback very late in the project, because Log4J locks logfiles and Logback does not (which means that on Windows, you can't delete a logfile while Log4J has it open; Logback doesn't have that problem).


I would recommend reading about log4j vs JUL in the following post - http://java.sys-con.com/node/48541. It offers a comprehensive discussion on when log4j is required and what benefits it offers.

I assume that you understand the advantages of logging. As skaffman pointed out in order to compare apple with oranges - you need to know about your oranges

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜