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
精彩评论