<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Udi Dahan - The Software Simplist &#187; Logging</title>
	<atom:link href="http://www.udidahan.com/category/logging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.udidahan.com</link>
	<description>Enterprise Development Expert &#38; SOA Specialist</description>
	<lastBuildDate>Sat, 24 Jul 2010 20:06:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Logging &#8211; The Smart Way</title>
		<link>http://www.udidahan.com/2008/08/01/logging-the-smart-way/</link>
		<comments>http://www.udidahan.com/2008/08/01/logging-the-smart-way/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 13:07:20 +0000</pubDate>
		<dc:creator>udidahan</dc:creator>
				<category><![CDATA[AOP]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Logging]]></category>

		<guid isPermaLink="false">http://www.udidahan.com/2008/08/01/logging-the-smart-way/</guid>
		<description><![CDATA[Don&#8217;t.
Not in applicative code anyway.
This follows up on Ayende&#8217;s post about the AOP way.
Now, I have nothing against AOP but some developers are leery of it.
In broader terms, all logging goes in framework-level code. For smart clients, one really good place to put logging is in your Command infrastructure &#8211; every time a command is [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t.</p>
<p>Not in applicative code anyway.</p>
<p>This follows up on Ayende&#8217;s post about the <a href="http://ayende.com/Blog/archive/2008/07/31/Logging--the-AOP-way.aspx">AOP way</a>.</p>
<p>Now, I have nothing against AOP but some developers are leery of it.</p>
<p>In broader terms, all logging goes in framework-level code. For smart clients, one really good place to put logging is in your Command infrastructure &#8211; every time a command is invoked, log it and the args. For data access, well, any decent O/R Mapper has a lot of logging already, just use it. For communication, ditto. Funny that just last week this was one of the major bits of feedback I gave in a code review.</p>
<h4>The Important Part <a href="http://www.udidahan.com/wp-content/uploads/image34.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="204" alt="image" src="http://www.udidahan.com/wp-content/uploads/image-thumb30.png" width="244" align="right" border="0"></a> </h4>
<p>Logging is useful for developers to find out <em>why</em> a system isn&#8217;t working correctly.</p>
<p>It is terrible for knowing <em>that</em> a system isn&#8217;t working correctly.</p>
<p>If you&#8217;re entire exception management strategy is &#8220;write it to the log&#8221;, how will an admin know that something&#8217;s wrong? Did you remember to configure your logging library that errors (and maybe warnings too) should be pushed out to a monitoring system? Do you have a monitoring system?</p>
<p>And if the admins don&#8217;t know anything&#8217;s wrong, they won&#8217;t know they need to increase the fidelity of the logs, will they? Are you planning on providing training for your admins telling them this (and all the other things they need to know)? Or maybe this will all be set up as an automatic script?</p>
<h4>An Agile Digression</h4>
<p>I hope all that&#8217;s on your agile (&#8221;we can ship at the end of every 2 week iteration&#8221;) product backlog (pardon my cynicism). I hope it&#8217;s at least something that you&#8217;re looking at per release and feeding the relevant features into your iterations. Yes, there&#8217;s project work to do (writing training manuals) that isn&#8217;t &#8220;development&#8221; that needs to be handled; if you don&#8217;t timebox it into the same iterations, it won&#8217;t get done.</p>
<p>Now, back to you&#8217;re regularly schedule logging&#8230;</p>
<h4>Things Logging Doesn&#8217;t Address<a href="http://www.udidahan.com/wp-content/uploads/image35.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://www.udidahan.com/wp-content/uploads/image-thumb31.png" width="140" align="right" border="0"></a> </h4>
<p>Logging is a mildly useless tool for pinpointing <em>where</em> in the system the source of a problem is.</p>
<blockquote><p>&#8220;I know the entity isn&#8217;t in the database. I can see that. I want to know <em>why</em> it isn&#8217;t there.&#8221;</p>
</blockquote>
<p>Sure, if you had every SQL statement logged you could figure these sorts of things out out. Of course, performance-wise, you wouldn&#8217;t put the system into production like that. In which case, the delete statement wouldn&#8217;t have been logged leaving you with precious little information to solve the root cause.</p>
<p>Also consider that the more logging you do, the more crap you&#8217;ll have to sift through to find the proverbial needle. Developers often don&#8217;t think twice about increasing the amount of <strike>crap</strike> logs they generate&#8230;</p>
<h4>The Real Problem</h4>
<p>The real problem is that developers think too much about logging and not <strike>at all</strike> nearly enough about designing the system in ways that it&#8217;ll be <strike>easy</strike> possible to answer questions like those above without having to know exactly how the system is built. One of the reasons that developers should care about this is that it&#8217;ll decrease the number of times they need to get up at 3:00 am to answer those questions.</p>
<h4>A Path to the Solution<a href="http://www.udidahan.com/wp-content/uploads/image36.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="244" alt="image" src="http://www.udidahan.com/wp-content/uploads/image-thumb32.png" width="184" align="right" border="0"></a> </h4>
<p>Now, if you had some kind of business activity monitoring (BAM) capability in your system, an admin could do a simple search/query [WHEN entity DELETED] and find out answers to the questions above, find out the time that the relevant activities occurred, figure out what the problem is on their own, and maybe even fix it &#8211; especially if it has to do with some esoteric configuration variable.Regardless of whether you buy a BAM tool or roll what you need yourself, you need to understand what about the system needs to be monitored. That&#8217;s a very different thought-process to go through than &#8220;should we log this? Yeah, sure, why not.&#8221;</p>
<p>It&#8217;s called &#8220;Design for Operations&#8221;.</p>
<p>Take a holistic perspective on exception management, logging, monitoring, etc. Think about questions like those above and then analyse your use of the relevant tools in that context. Think about all the different kinds of users of the information that&#8217;s going to be generated and how quickly their going to need to act on that information. Admins in the data-center in the middle of a crisis are going to have different needs than developers analysing logs on their machine. Think about:</p>
<ul>
<li>How will the administrator know that a server has been configured properly?</li>
<li>If the system is feeling slow, how can the administrator know which server/process is to blame?</li>
<ul>
<li>So that maybe they can scale out that part of the system.</li>
</ul>
</ul>
<h4>In Closing<a href="http://www.udidahan.com/wp-content/uploads/image37.png"><img style="border-right: 0px; border-top: 0px; margin: 0px 0px 10px 10px; border-left: 0px; border-bottom: 0px" height="162" alt="image" src="http://www.udidahan.com/wp-content/uploads/image-thumb33.png" width="162" align="right" border="0"></a> </h4>
<p>It&#8217;s a mindset. </p>
<p>It takes time to make the shift.</p>
<p>It takes more time to bring the development process to this kind of maturity (god, I hate that word).</p>
<p>Writing exceptions to the log is not a strategy.</p>
<p>At the very best, its a tactic.</p>
<p>What&#8217;s your strategy?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.udidahan.com/2008/08/01/logging-the-smart-way/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
