<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://java.dzone.com"  xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dz="http://www.developerzone.com/modules/dz/1.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
 <title>Javalobby - Comments for &quot;Using Logs in Unit Tests &quot;</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests</link>
 <description>Comments for &quot;Using Logs in Unit Tests &quot;</description>
 <language>en</language>
<item>
 <title>I ran into the same problems</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests#comment-3132</link>
 <description>&lt;!--paging_filter--&gt;I ran into the same problems while writing a new appender for log4j. Implementing the appender is simple - as long as you don&#039;t intend to test it. Testing log4j is insane. I was close to using reflection and setAccessible(true).</description>
 <pubDate>Thu, 08 May 2008 05:49:18 -0400</pubDate>
 <dc:creator>digulla</dc:creator>
 <guid isPermaLink="false">comment 3132 at http://java.dzone.com</guid>
</item>
<item>
 <title>@Ronald: Seam does inject</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests#comment-2719</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;@Ronald: Seam does inject the commons logger. The injection idea does make some amount of sense because you can have some control over setting up the state of the logger before it is stuffed into your class. You could make your own log factory for that I spose, but if you are doing DI, might as well do it.&lt;/p&gt;&lt;p&gt;@Marcos, et al: Well, in this case I was writing an aspect that logs Repository activities. Wow, I really didn&#039;t expect people would think the idea repellent. If the aspect&#039;s job is to put messages in the log, unit testing that the right messages are going in at the right levels makes sense, no?? As to the idea of a &#039;bad pattern&#039; I don&#039;t get that at all. I am not taking the log message as a proof of some other thing occurring. Frankly, the bad pattern there is to only look at unit tests as proofs. You should look at them also as guarantees of desired behavior, so if someone unwires the aspect, or changes the declarations, your test fails, rather than you pushing out a release that doesn&#039;t have any logging in it. Right?&lt;/p&gt;&lt;p&gt;Thanks for the feedback, Guys. &lt;/p&gt;&lt;p&gt; &lt;/p&gt;</description>
 <pubDate>Mon, 14 Apr 2008 22:59:04 -0400</pubDate>
 <dc:creator>deconcoder</dc:creator>
 <guid isPermaLink="false">comment 2719 at http://java.dzone.com</guid>
</item>
<item>
 <title>There is a flaw in your</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests#comment-2700</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;There is a flaw in your premise, that you can test something on the basis of what it logs that is doing.&lt;/p&gt;&lt;p&gt; Such an approach obviously neglects to test whether the subject actually did what it claimed. e.g. if you checked for &amp;quot;entry&amp;quot; would this pass?&lt;/p&gt;&lt;p&gt;12:00 ACMEmodule: entry&lt;br /&gt;12:00 ACMEmodule: config error, abandoning&lt;/p&gt;&lt;p&gt; Sounds like a dangerous pattern...&lt;/p&gt;&lt;p&gt;just my 2p :) &lt;/p&gt;</description>
 <pubDate>Mon, 14 Apr 2008 05:23:25 -0400</pubDate>
 <dc:creator>gregallen</dc:creator>
 <guid isPermaLink="false">comment 2700 at http://java.dzone.com</guid>
</item>
<item>
 <title>I&#039;ve only used</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests#comment-2698</link>
 <description>&lt;!--paging_filter--&gt;I&#039;ve only used java.util.logging, but if would want to do something with the log in a unit test (maybe fail on a logged error?), you could just use &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/logging/Logger.html#addHandler(java.util.logging.Handler)&quot; title=&quot;Logger#addHandler()&quot;&gt;addHandler()&lt;/a&gt; to do that in the unit test setup.</description>
 <pubDate>Mon, 14 Apr 2008 04:24:37 -0400</pubDate>
 <dc:creator>walter laan</dc:creator>
 <guid isPermaLink="false">comment 2698 at http://java.dzone.com</guid>
</item>
<item>
 <title>Logs in my Unit Tests? No,</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests#comment-2695</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;Logs in my Unit Tests? No, thanks. Could you please show me an example where you need such thing?&lt;/p&gt;&lt;p&gt;Kind Regards &lt;/p&gt;</description>
 <pubDate>Sun, 13 Apr 2008 23:40:46 -0400</pubDate>
 <dc:creator>marcos.pereira</dc:creator>
 <guid isPermaLink="false">comment 2695 at http://java.dzone.com</guid>
</item>
<item>
 <title>Well, I don&#039;t agree that</title>
 <link>http://java.dzone.com/articles/using-logs-unit-tests#comment-2682</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;Well, I don&#039;t agree that commons-logging is useless. It may be bad implemented (I&#039;ve never had those classloader issues people often mention, but they may exist), but it certainly have its place.&lt;/p&gt;&lt;p&gt;What if Spring used LogKit, and Hibernate used Log4j, Seam used its own home-baked logging framework, and I used java.util.logging in my application? I&#039;d have to ship two extra jars (log4j and logkit) and have four logging configuration files? What if it was a desktop application deployed by Java WebStart, and I needed to make it as small as possible?&lt;/p&gt;&lt;p&gt;I had this problem once, because I had to use a library that used Log4j directly, and my module was a Swing application.  My luck is that the library&#039;s implementor worked by my side, and I simply asked him to change it to commons-logging, so he could still use his log4j configuration on the server (it was shared between server and clients), and I could use java.util.logging for my client. I certainly wouldn&#039;t be able to ask Gavin King to do that for me (thanks Gavin, for using commons-logging in Hibernate!). &lt;/p&gt;&lt;p&gt;And this idea of &#039;injecting&#039; loggers is silly... So, now I have to use a container to print some error messages to the console? It may work in a server environment, since you&#039;re already stuck with some kind of container anyway, but even then, maybe your container is not my container (say, Spring, EJB, or Guice), and they don&#039;t support the same APIs for logger injection? If the did, they&#039;d have to agree in a single common API. Maybe it would be... commons-logging&#039;s? :)  &lt;/p&gt;</description>
 <pubDate>Sun, 13 Apr 2008 13:07:27 -0400</pubDate>
 <dc:creator>ronaldtm</dc:creator>
 <guid isPermaLink="false">comment 2682 at http://java.dzone.com</guid>
</item>
</channel>
</rss>
