<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Log4J and Clojure Configuration</title>
	<atom:link href="http://www.paullegato.com/blog/log4j-clojure/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.paullegato.com/blog/log4j-clojure/</link>
	<description></description>
	<lastBuildDate>Sat, 07 Jan 2012 12:13:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jeff Weiss</title>
		<link>http://www.paullegato.com/blog/log4j-clojure/comment-page-1/#comment-430</link>
		<dc:creator>Jeff Weiss</dc:creator>
		<pubDate>Fri, 11 Mar 2011 20:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.paullegato.com/?p=292#comment-430</guid>
		<description>Hi Paul - 
I know it&#039;s a bit late here, but I have run into the same problem with clojure.contrib.logging.

I can at least explain what the author meant by his cryptic remarks.  Log libraries get the &quot;location&quot; (class/method) of the log item from the java stack.  In java, this is straightforward because they can just look at the stack when they are called, ignore their own elements at the top of the stack, and figure out who called them.  

In clojure this doesn&#039;t quite work because clojure.contrib.logging is sandwiched between the calling code and log4j.  So log4j thinks it&#039;s always clojure.contrib.logging that&#039;s calling it.  From a java perspective, that&#039;s exactly right.

What needs to happen is the log library needs to pop off one extra element off that stack to get the true caller location.

Unfortunately I don&#039;t see any public API for log4j that lets you tell it how to do that. 

java.util.logging has API Logger.logp() that lets you pass in the location yourself.  So I hacked up a version of clojure.contrib.logging that figures it out and passes in the right value.  In my version I commented out commons logging support because it chooses it first over the java.util implementation. 

Look around line 180 for &quot;.getStackTrace&quot;. https://github.com/weissjeffm/webui-framework/blob/unify/src/com/redhat/qe/logging.clj

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Hi Paul &#8211;<br />
I know it&#8217;s a bit late here, but I have run into the same problem with clojure.contrib.logging.</p>
<p>I can at least explain what the author meant by his cryptic remarks.  Log libraries get the &#8220;location&#8221; (class/method) of the log item from the java stack.  In java, this is straightforward because they can just look at the stack when they are called, ignore their own elements at the top of the stack, and figure out who called them.  </p>
<p>In clojure this doesn&#8217;t quite work because clojure.contrib.logging is sandwiched between the calling code and log4j.  So log4j thinks it&#8217;s always clojure.contrib.logging that&#8217;s calling it.  From a java perspective, that&#8217;s exactly right.</p>
<p>What needs to happen is the log library needs to pop off one extra element off that stack to get the true caller location.</p>
<p>Unfortunately I don&#8217;t see any public API for log4j that lets you tell it how to do that. </p>
<p>java.util.logging has API Logger.logp() that lets you pass in the location yourself.  So I hacked up a version of clojure.contrib.logging that figures it out and passes in the right value.  In my version I commented out commons logging support because it chooses it first over the java.util implementation. </p>
<p>Look around line 180 for &#8220;.getStackTrace&#8221;. <a target="_blank" href="https://github.com/weissjeffm/webui-framework/blob/unify/src/com/redhat/qe/logging.clj"  rel="nofollow">https://github.com/weissjeffm/webui-framework/blob/unify/src/com/redhat/qe/logging.clj</a></p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

