<?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>Ralph's TechBlog &#187; logging</title>
	<atom:link href="http://techblog.ralph-schuster.eu/tag/logging/feed/" rel="self" type="application/rss+xml" />
	<link>http://techblog.ralph-schuster.eu</link>
	<description>Technical stuff for IT experts</description>
	<lastBuildDate>Tue, 27 Dec 2011 09:38:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Log4j Configuration Problem</title>
		<link>http://techblog.ralph-schuster.eu/2009/12/08/log4j-configuration-problem/</link>
		<comments>http://techblog.ralph-schuster.eu/2009/12/08/log4j-configuration-problem/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 13:46:53 +0000</pubDate>
		<dc:creator>Ralph</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Log4j]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://techblog.ralph-schuster.eu/?p=159</guid>
		<description><![CDATA[It seems that some documentation that is hanging around the net contains incorrect information about correct configuration of the log4j system. Take care that you specify the properties filename as an URL rather than simple plain path location, e.g java -Dlog4j.configuration=file:///my/path/to/log4j.properties ... Log4j should find your configuration then. So make sure you include file:// there&#8230;]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.ralph-schuster.eu%2F2009%2F12%2F08%2Flog4j-configuration-problem%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.ralph-schuster.eu%2F2009%2F12%2F08%2Flog4j-configuration-problem%2F&amp;source=TechnicalG&amp;style=compact&amp;hashtags=Log4j,logging&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>It seems that some documentation that is hanging around the net contains incorrect information about correct configuration of the log4j system.</p>
<p>Take care that you specify the properties filename as an URL rather than simple plain path location, e.g</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">java -Dlog4j.configuration=<span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>my<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>log4j.properties ...</pre></div></div>

<p>Log4j should find your configuration then. So make sure you include file:// there&#8230; <img src='http://techblog.ralph-schuster.eu/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://techblog.ralph-schuster.eu/2009/12/08/log4j-configuration-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Message Logging</title>
		<link>http://techblog.ralph-schuster.eu/2007/11/19/perl-message-logging/</link>
		<comments>http://techblog.ralph-schuster.eu/2007/11/19/perl-message-logging/#comments</comments>
		<pubDate>Mon, 19 Nov 2007 10:04:26 +0000</pubDate>
		<dc:creator>Ralph</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://techblog.ralph-schuster.eu/2007/11/19/perl-message-logging/</guid>
		<description><![CDATA[The following code is a quick and dirty, but nevertheless usefull snippet to add logging facility to any perl script. You might want to add additional severities at lines 2-6, change the timestamp format at line 14, or enable logging into a file at lines 42-54. 1 2 3 4 5 6 7 8 9 [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ftechblog.ralph-schuster.eu%2F2007%2F11%2F19%2Fperl-message-logging%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ftechblog.ralph-schuster.eu%2F2007%2F11%2F19%2Fperl-message-logging%2F&amp;source=TechnicalG&amp;style=compact&amp;hashtags=logging&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The following code is a quick and dirty, but nevertheless usefull snippet to add logging facility to any perl script. You might want to add additional severities at lines 2-6, change the timestamp format at line 14, or enable logging into a file at lines 42-54.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Defines severities of messages to log</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%TYPES</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
   ERROR <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
   DEBUG <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
   INFO  <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Creates the time string for log messages</span>
<span style="color: #666666; font-style: italic;"># Usage: getTimestring($unixTimeValue)</span>
<span style="color: #000000; font-weight: bold;">sub</span> getTimestring <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$t</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$t</span> <span style="color: #339933;">=</span> <span style="color: #000066;">time</span> <span style="color: #b1b100;">if</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">$t</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@T</span> <span style="color: #339933;">=</span> <span style="color: #000066;">localtime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$time</span> <span style="color: #339933;">=</span> <span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%02d/%02d/%04d %02d:%02d:%02d&quot;</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">$T</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$T</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$T</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1900</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$T</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$T</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$T</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">return</span> <span style="color: #0000ff;">$time</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># logs an error message</span>
<span style="color: #666666; font-style: italic;"># Usage: logError($message);</span>
<span style="color: #000000; font-weight: bold;">sub</span> logError <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   logEntry<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$s</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'ERROR'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># logs an information message</span>
<span style="color: #666666; font-style: italic;"># Usage: logInfo($message);</span>
<span style="color: #000000; font-weight: bold;">sub</span> logInfo <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   logEntry<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$s</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'INFO'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># logs a debug message</span>
<span style="color: #666666; font-style: italic;"># Usage: logDebug($message);</span>
<span style="color: #000000; font-weight: bold;">sub</span> logDebug <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   logEntry<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$s</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'DEBUG'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># logs a single entry with given message severity</span>
<span style="color: #666666; font-style: italic;"># Usage: logEntry($message, $severity);</span>
<span style="color: #000000; font-weight: bold;">sub</span> logEntry <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">return</span> <span style="color: #b1b100;">if</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">$TYPES</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$type</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># build timestamp and string</span>
   <span style="color: #0000ff;">$type</span> <span style="color: #339933;">=</span> rpad<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$type</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$time</span> <span style="color: #339933;">=</span> getTimestring<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">s/\n/\n$time $type - /g</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># print to STDOUT if required</span>
   <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$time $type - $s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Right pads a string</span>
<span style="color: #666666; font-style: italic;"># Usage: rpad($string, $maxlen[, $padchar]);</span>
<span style="color: #000000; font-weight: bold;">sub</span> rpad <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$len</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$char</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #0000ff;">$char</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">' '</span> <span style="color: #b1b100;">if</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">$char</span><span style="color: #339933;">;</span>
   <span style="color: #0000ff;">$s</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$char</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">length</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$s</span><span style="color: #009900;">&#41;</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$len</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000066;">return</span> <span style="color: #0000ff;">$s</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://techblog.ralph-schuster.eu/2007/11/19/perl-message-logging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

