<p>Is it still worth to add the log4j library to a Java 5 project just to log
let's say some exceptions to a file with some nice rollover settings.
Or will the standard util.logging facility do the job as well?</p>

<p>What do you think?</p>

[{'answer_id': 31852, 'author': 'Matt Sheppard', 'author_id': 797, 'author_profile': 'https://Stackoverflow.com/users/797', 'pm_score': 7, 'selected': False, 'text': '<p>I\'d say you\'re probably fine with util.logging for the needs you describe.</p>\n<p>For a good decision tree, have a look at <a href="http://web.archive.org/web/20190320144728/http://java.sys-con.com/node/48541" rel="noreferrer">Log4j vs java.util.logging</a></p>\n<blockquote>\n<p>Question One :\nDo you anticipate a need for any of the clever handlers that Log4j has that JUL does not have, such as the SMTPHandler, NTEventLogHandler, or any of the very convenient FileHandlers?</p>\n</blockquote>\n<blockquote>\n<p>Question Two :\nDo you see yourself wanting to frequently switch the format of your logging output? Will you need an easy, flexible way to do so? In other words, do you need Log4j\'s PatternLayout?</p>\n</blockquote>\n<blockquote>\n<p>Question Three :\nDo you anticipate a definite need for the ability to change complex logging configurations in your applications, after they are compiled and deployed in a production environment? Does your configuration sound something like, &quot;Severe messages from this class get sent via e-mail to the support guy; severe messages from a subset of classes get logged to a syslog deamon on our server; warning messages from another subset of classes get logged to a file on network drive A; and then all messages from everywhere get logged to a file on network drive B&quot;? And do you see yourself tweaking it every couple of days?</p>\n</blockquote>\n<blockquote>\n<p>If you can answer yes to any of the above questions, go with Log4j. If you answer a definite no to all of them, JUL will be more than adequate and it\'s conveniently already included in the SDK.</p>\n</blockquote>\n<p>That said, pretty much every project these days seems to wind up including log4j, if only because some other library uses it.</p>\n'}, {'answer_id': 31861, 'author': 'svrist', 'author_id': 86, 'author_profile': 'https://Stackoverflow.com/users/86', 'pm_score': 2, 'selected': False, 'text': '<p>I would go with log4j. The possibilites with log4j is not obsolete at all!</p>\n'}, {'answer_id': 31914, 'author': 'Edmund Tay', 'author_id': 2633, 'author_profile': 'https://Stackoverflow.com/users/2633', 'pm_score': 2, 'selected': False, 'text': '<p>I recommend using <a href="http://commons.apache.org/logging/" rel="nofollow noreferrer">Apache Commmons Logging</a> as your logging interface. That way you have the flexibility to switch logging implementations anytime you want without requiring any code changes on your end.</p>\n'}, {'answer_id': 32015, 'author': 'Brian Matthews', 'author_id': 1969, 'author_profile': 'https://Stackoverflow.com/users/1969', 'pm_score': 6, 'selected': False, 'text': '<p>I recommend that you use the <a href="http://slf4j.org" rel="noreferrer">Simple Logging Facade for Java</a> (SLF4J). It supports different providers that include Log4J and can be used as a replacement for Apache Commons Logging.</p>\n'}, {'answer_id': 36482, 'author': 'Rydell', 'author_id': 2885, 'author_profile': 'https://Stackoverflow.com/users/2885', 'pm_score': 5, 'selected': False, 'text': '<p>Log4j has been around for a long time, and it works very well.  I have no scientific study to back it, but based on what I\'ve seen at a large number of clients, it is easily the logging framework that I see used more than any other.  It has been around for a long time, and not been replaced by the Next Big Logging Framework, which says something.  </p>\n\n<p>It is dead simple to set up, and easy to learn the basic appenders (outputs).  There are a whole host appenders that are available, including:</p>\n\n<ol>\n<li>ConsoleAppender</li>\n<li>DailyRollingFileAppender</li>\n<li>ExternallyRolledFileAppender </li>\n<li>FileAppender</li>\n<li>JDBCAppender</li>\n<li>JMSAppender</li>\n<li>NTEventLogAppender</li>\n<li>RollingFileAppender</li>\n<li>SMTPAppender</li>\n<li>SocketAppender</li>\n<li>SyslogAppender</li>\n<li>TelnetAppender</li>\n<li>WriterAppender</li>\n</ol>\n\n<p>Plus others.  It isn\'t difficult to write your own appender either.  Additionally there is a great deal of flexibility in each of the appenders that allow you to control specifically what is output in your log.</p>\n\n<p>One note, I had a series of classloader problems when I used apache commons logging in addition to log4j.  It was only for one specific application, but I found it simpler to use log4j alone, rather than to have the flexibility offered when using an abstraction layer like commons logging.    </p>\n\n<p>See this article for\n<a href="http://www.qos.ch/logging/thinkAgain.jsp" rel="noreferrer">more details</a>:</p>\n\n<p>Good luck!</p>\n'}, {'answer_id': 51201, 'author': 'Will Sargent', 'author_id': 5266, 'author_profile': 'https://Stackoverflow.com/users/5266', 'pm_score': 3, 'selected': False, 'text': "<p>log4j is a much nicer package overall, and doesn't have some of the hiccups that java.util.logging contains.  I'd second that using log4j directly is easier than using the commons logging.</p>\n"}, {'answer_id': 370981, 'author': 'adam', 'author_id': 33604, 'author_profile': 'https://Stackoverflow.com/users/33604', 'pm_score': 4, 'selected': False, 'text': '<p>java.util.logging offers a comprehensive logging package without the excess baggage some of the others provide..</p>\n'}]
['https://Stackoverflow.com/questions/31840', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3360/']