<?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>We Heart Code &#187; logging</title>
	<atom:link href="http://www.weheartcode.com/category/logging/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.weheartcode.com</link>
	<description>A discourse on programming</description>
	<lastBuildDate>Sun, 17 Jan 2010 02:16:44 +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>Regular Expression to Replace System.out.println with Log4j</title>
		<link>http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/</link>
		<comments>http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 14:32:10 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/</guid>
		<description><![CDATA[This is nothing fancy, but may help some of you log4j newbies.
I found myself replacing a project's hideous System.out.println statements with log4j log calls.
Just do a File Search in eclipse , tick the regular expression box and do a Replace:


Find: System\.out\.println\&#40;"(.+?)"\&#41;;
Replace: log.info&#40;"\1"&#41;;



Now you just have to go in and add your imports and your log [...]]]></description>
			<content:encoded><![CDATA[<p>This is nothing fancy, but may help some of you log4j newbies.</p>
<p>I found myself replacing a project's hideous System.out.println statements with log4j log calls.</p>
<p>Just do a File Search in eclipse , tick the regular expression box and do a Replace:</p>
<div class="syntax_hilite">
<div id="code-2">
<div class="code">Find: System\.<span style="">out</span>\.<span style="">println</span>\<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"(.+?)"</span>\<span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
Replace: log.<span style="">info</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"<span style="color:#000099; font-weight:bold;">\1</span>"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>Now you just have to go in and add your imports and your log field variable to your classes.</p>
<!-- Social Bookmarks BEGIN --><div class="social_bookmark"><em>Bookmark to:</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/&amp;title=Regular+Expression+to+Replace+System.out.println+with+Log4j" title="Add 'Regular Expression to Replace System.out.println with Log4j' to Del.icio.us"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/delicious.png" title="Add 'Regular Expression to Replace System.out.println with Log4j' to Del.icio.us" alt="Add 'Regular Expression to Replace System.out.println with Log4j' to Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/&amp;title=Regular+Expression+to+Replace+System.out.println+with+Log4j" title="Add 'Regular Expression to Replace System.out.println with Log4j' to digg"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/digg.png" title="Add 'Regular Expression to Replace System.out.println with Log4j' to digg" alt="Add 'Regular Expression to Replace System.out.println with Log4j' to digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Regular+Expression+to+Replace+System.out.println+with+Log4j&amp;u=http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/" title="Add 'Regular Expression to Replace System.out.println with Log4j' to FURL"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/furl.png" title="Add 'Regular Expression to Replace System.out.println with Log4j' to FURL" alt="Add 'Regular Expression to Replace System.out.println with Log4j' to FURL" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/&amp;title=Regular+Expression+to+Replace+System.out.println+with+Log4j" title="Add 'Regular Expression to Replace System.out.println with Log4j' to reddit"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/reddit.png" title="Add 'Regular Expression to Replace System.out.println with Log4j' to reddit" alt="Add 'Regular Expression to Replace System.out.println with Log4j' to reddit" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/" title="Add 'Regular Expression to Replace System.out.println with Log4j' to Technorati"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/technorati.png" title="Add 'Regular Expression to Replace System.out.println with Log4j' to Technorati" alt="Add 'Regular Expression to Replace System.out.println with Log4j' to Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/&amp;title=Regular+Expression+to+Replace+System.out.println+with+Log4j" title="Add 'Regular Expression to Replace System.out.println with Log4j' to Google Bookmarks"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/google.png" title="Add 'Regular Expression to Replace System.out.println with Log4j' to Google Bookmarks" alt="Add 'Regular Expression to Replace System.out.println with Log4j' to Google Bookmarks" /></a></div>
<!-- Social Bookmarks END -->]]></content:encoded>
			<wfw:commentRss>http://www.weheartcode.com/2008/12/29/regular-expression-to-replace-systemoutprintln-with-log4j/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Limiting log4j SMTPAppender</title>
		<link>http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/</link>
		<comments>http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 14:43:21 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/</guid>
		<description><![CDATA[I wanted to set a maximum amount of e-mails that SMTPAppender would send after filling up a mailbox with 30,000 damn e-mails.
Turns out it was pretty damn easy, I set up my appender in a java class, and the SMTP appender has a method called setEvaluator that takes an instance of TriggeringEventEvaluator, so I just [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to set a maximum amount of e-mails that SMTPAppender would send after filling up a mailbox with 30,000 damn e-mails.</p>
<p>Turns out it was pretty damn easy, I set up my appender in a java class, and the SMTP appender has a method called setEvaluator that takes an instance of TriggeringEventEvaluator, so I just created a quick inner class like so.</p>
<div class="syntax_hilite">
<div id="java-5">
<div class="java"><span style="color: #000000; font-weight: bold;">class</span> LimitingEvaluator <span style="color: #000000; font-weight: bold;">implements</span> TriggeringEventEvaluator<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">int</span> sentEvents = <span style="color: #cc66cc;">0</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">int</span> MAX_EVENTS = <span style="color: #cc66cc;">20</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">boolean</span> isTriggeringEvent<span style="color: #66cc66;">&#40;</span>LoggingEvent arg0<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sentEvents++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>sentEvents&gt;= MAX_EVENTS<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<p>and when i set up my appender I do this</p>
<div class="syntax_hilite">
<div id="java-6">
<div class="java">appender.<span style="color: #006600;">setEvaluator</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LimitingEvaluator<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<!-- Social Bookmarks BEGIN --><div class="social_bookmark"><em>Bookmark to:</em><br /><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/&amp;title=Limiting+log4j+SMTPAppender" title="Add 'Limiting log4j SMTPAppender' to Del.icio.us"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/delicious.png" title="Add 'Limiting log4j SMTPAppender' to Del.icio.us" alt="Add 'Limiting log4j SMTPAppender' to Del.icio.us" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/&amp;title=Limiting+log4j+SMTPAppender" title="Add 'Limiting log4j SMTPAppender' to digg"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/digg.png" title="Add 'Limiting log4j SMTPAppender' to digg" alt="Add 'Limiting log4j SMTPAppender' to digg" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://furl.net/storeIt.jsp?t=Limiting+log4j+SMTPAppender&amp;u=http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/" title="Add 'Limiting log4j SMTPAppender' to FURL"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/furl.png" title="Add 'Limiting log4j SMTPAppender' to FURL" alt="Add 'Limiting log4j SMTPAppender' to FURL" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/&amp;title=Limiting+log4j+SMTPAppender" title="Add 'Limiting log4j SMTPAppender' to reddit"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/reddit.png" title="Add 'Limiting log4j SMTPAppender' to reddit" alt="Add 'Limiting log4j SMTPAppender' to reddit" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/" title="Add 'Limiting log4j SMTPAppender' to Technorati"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/technorati.png" title="Add 'Limiting log4j SMTPAppender' to Technorati" alt="Add 'Limiting log4j SMTPAppender' to Technorati" /></a><a class="social_img" onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/&amp;title=Limiting+log4j+SMTPAppender" title="Add 'Limiting log4j SMTPAppender' to Google Bookmarks"><img src="http://www.weheartcode.com/wp-content/plugins/social_bookmarks/google.png" title="Add 'Limiting log4j SMTPAppender' to Google Bookmarks" alt="Add 'Limiting log4j SMTPAppender' to Google Bookmarks" /></a></div>
<!-- Social Bookmarks END -->]]></content:encoded>
			<wfw:commentRss>http://www.weheartcode.com/2008/02/15/limiting-log4j-smtpappender/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
