<?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>entroducing.com &#187; Programming</title>
	<atom:link href="http://www.entroducing.com/view/category/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.entroducing.com</link>
	<description>to prove that i have too much time</description>
	<lastBuildDate>Sun, 15 May 2011 06:00:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Fix Magento Connect Manager 404 error by resetting the folder permission</title>
		<link>http://www.entroducing.com/view/fix-magento-connect-manager-404-error-by-resetting-the-folder-permission</link>
		<comments>http://www.entroducing.com/view/fix-magento-connect-manager-404-error-by-resetting-the-folder-permission#comments</comments>
		<pubDate>Sun, 15 May 2011 06:00:20 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=361</guid>
		<description><![CDATA[If you encounter 404 error when you connect to Magento Connnect Manager (System-&#62; Magento Connect Manager), it is probably due to your folder permission not set up correctly. Fortunately, there is a quick fix for this. Download the magento clean up tool (a php file) and upload to your store root folder. Once done, browse [...]]]></description>
			<content:encoded><![CDATA[<p>If you encounter 404 error when you connect to Magento Connnect Manager (System-&gt; Magento Connect Manager), it is probably due to your folder permission not set up correctly.</p>
<p>Fortunately, there is a quick fix for this.</p>
<p>Download the <a href="http://www.magentocommerce.com/wiki/groups/227/resetting_file_permissions" target="_blank">magento clean up too</a>l (a php file) and upload to your store root folder.</p>
<p>Once done, browse to the clean up tool (http://www.yourstore.com/magento-cleanup.php) and you will see a list of messages that it has reset the folder permission.</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Ffix-magento-connect-manager-404-error-by-resetting-the-folder-permission&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/fix-magento-connect-manager-404-error-by-resetting-the-folder-permission/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install chinese locale for Magento Admin 1.5</title>
		<link>http://www.entroducing.com/view/install-chinese-locale-for-magento-admin-1-5</link>
		<comments>http://www.entroducing.com/view/install-chinese-locale-for-magento-admin-1-5#comments</comments>
		<pubDate>Sun, 15 May 2011 05:06:22 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=356</guid>
		<description><![CDATA[Unfortunately, the default Magento does not comes with all the languages installed. Changing the language dropdown at the bottom of the page will not change the interface. Here&#8217;s how to install chinese language for the admin 1. go to magento connect and install the below 2.0 extension key http://connect20.magentocommerce.com/community/Locale_Mage_community_zh_CN 2. Once installed, check your app\locale [...]]]></description>
			<content:encoded><![CDATA[<p>Unfortunately, the default Magento does not comes with all the languages installed. Changing the language dropdown at the bottom of the page will not change the interface.</p>
<p>Here&#8217;s how to install chinese language for the admin</p>
<p>1. go to magento connect and install the below 2.0 extension key</p>
<pre class="brush: php">

http://connect20.magentocommerce.com/community/Locale_Mage_community_zh_CN
</pre>
<p>2. Once installed, check your app\locale and you will see a lot of csv files in the folder. Those files are created by the extension&#8230; in the wrong folder!</p>
<p>3. Create a folder &#8216;<strong>zh_CN</strong>&#8216; in <strong>app\locale</strong> and move all the csv files in <strong>app\locale</strong> to <strong>app\locale\zh_CN</strong></p>
<p>4. Once done, go back to admin page and flush your cache (system -&gt; cache management -&gt; flush magento cache)</p>
<p>5. Change the language to chinese (china) and you should be able to view it in chinese (hopefully)</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Finstall-chinese-locale-for-magento-admin-1-5&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/install-chinese-locale-for-magento-admin-1-5/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix google anlaytics in magento custom template</title>
		<link>http://www.entroducing.com/view/fix-google-anlaytics-in-magento-custom-template</link>
		<comments>http://www.entroducing.com/view/fix-google-anlaytics-in-magento-custom-template#comments</comments>
		<pubDate>Sun, 15 May 2011 03:56:48 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=353</guid>
		<description><![CDATA[If you have turned on your google analytics in admin console and you are using custom design template but the google analytics is not showing up in your html codes, look at the below steps to check if the codes are in your custom design are in placed. 1. check page.xml in app\design\frontend\default\[yourtemplate]\layout and verify [...]]]></description>
			<content:encoded><![CDATA[<p>If you have turned on your google analytics in admin console and you are using custom design template but the google analytics is not showing up in your html codes, look at the below steps to check if the codes are in your custom design are in placed.</p>
<p>1. check <strong>page.xml</strong> in <strong>app\design\frontend\default\[yourtemplate]\layout</strong> and verify if the following line is in place.</p>
<pre class="brush: php">
\\app\design\frontend\default\[yourtemplate]\layout\page.xml
</pre>
<p>2. open <strong>*.phtml</strong> in <strong>app\design\frontend\default\magikjewellery\template\page</strong> and verify if the following line is after the  tag</p>
<pre class="brush: php">
\\app\design\frontend\default\[yourtemplate]\template\page\1column.phtml
\\app\design\frontend\default\[yourtemplate]\template\page\1columnhome.phtml
\\app\design\frontend\default\[yourtemplate]\template\page\2columns-left.phtml
\\app\design\frontend\default\[yourtemplate]\template\page\2columns-right.phtml
\\app\design\frontend\default\[yourtemplate]\template\page\print.phtml

...

&lt;!--?php echo $this---&gt;getChildHtml(&#039;after_body_start&#039;) ?&amp;gt;
...
</pre>
<p>3. clear your cache by going to admin -&gt; system -&gt; cache management and flush magento cache</p>
<p>4. open your home page, right click on it and select view source and check if the following codes are generated.</p>
<pre class="brush: php">
&lt;!-- BEGIN GOOGLE ANALYTICS CODE --&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
    (function() {
        var ga = document.createElement(&#039;script&#039;); ga.type = &#039;text/javascript&#039;; ga.async = true;
        ga.src = (&#039;https:&#039; == document.location.protocol ? &#039;https://ssl&#039; : &#039;http://www&#039;) + &#039;.google-analytics.com/ga.js&#039;;
        (document.getElementsByTagName(&#039;head&#039;)[0] || document.getElementsByTagName(&#039;body&#039;)[0]).appendChild(ga);
    })();

    var _gaq = _gaq || [];

_gaq.push([&#039;_setAccount&#039;, &#039;UA-1234567-7&#039;]);
_gaq.push([&#039;_trackPageview&#039;]);

//]]&gt;
&lt;/script&gt;
&lt;!-- END GOOGLE ANALYTICS CODE --&gt;
</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Ffix-google-anlaytics-in-magento-custom-template&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/fix-google-anlaytics-in-magento-custom-template/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony conditional validation</title>
		<link>http://www.entroducing.com/view/symfony-conditional-validation</link>
		<comments>http://www.entroducing.com/view/symfony-conditional-validation#comments</comments>
		<pubDate>Sun, 27 Feb 2011 10:52:54 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=348</guid>
		<description><![CDATA[Below are the snippets on how to implement a conditional validation in the form. i.e. validate field A if field B is true As discussed in this tutorial (though it is for symfony 1.2, it will works in 1.4), the key thing is to set a post validator to validate values after the initial validation. [...]]]></description>
			<content:encoded><![CDATA[<p>Below are the snippets on how to implement a conditional validation in the form. i.e. validate field A if field B is true</p>
<p>As discussed in this <a href="http://www.symfony-project.org/cookbook/1_2/en/conditional-validator" target="_blank">tutorial </a>(though it is for symfony 1.2, it will works in 1.4), the key thing is to set a post validator to validate values after the initial validation.</p>
<p><span id="more-348"></span></p>
<p>Assuming you have two fields &#8211; one checkbox and one textfield.<br />
And you want the textfield to be filled in if the checkbox is ticked.</p>
<p>Here&#8217;s how you do it.</p>
<pre class="brush: php">
// lib\form\doctrine\MyForm.class.php

class MyForm extends BaseContestForm
{
  public function configure()
  {

    // add a post validator
    $this-&amp;gt;validatorSchema-&amp;gt;setPostValidator(
      new sfValidatorCallback(array(&#039;callback&#039; =&amp;gt; array($this, &#039;validateTextField&#039;)))
    );

  }

  public function validateTextField($validator, $values)
  {
    if ($values[&#039;myCheckbox&#039;])
    {
      $this-&amp;gt;validatorSchema[&#039;myTextField&#039;] = new sfValidatorString(array(
          &#039;required&#039;   =&amp;gt; true,
          &#039;max_length&#039; =&amp;gt; 50,
          &#039;min_length&#039; =&amp;gt; 1
        ));
    }

    return $values;
  }

}
</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fsymfony-conditional-validation&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/symfony-conditional-validation/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>symfony backend: displaying thumbnail or photo in listing</title>
		<link>http://www.entroducing.com/view/symfony-backend-displaying-thumbnail-or-photo-in-listing</link>
		<comments>http://www.entroducing.com/view/symfony-backend-displaying-thumbnail-or-photo-in-listing#comments</comments>
		<pubDate>Sun, 09 Jan 2011 06:19:31 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=330</guid>
		<description><![CDATA[if you are using the admin generator to generate your backend application and want to show thumbnail or photo in your listing, you can try the following steps. Here&#8217;s an example of how it will looks like when the thumbnail is showing on the listing page. Before you add it in, you need to check [...]]]></description>
			<content:encoded><![CDATA[<p>if you are using the admin generator to generate your backend application and want to show thumbnail or photo in your listing, you can try the following steps.</p>
<p>Here&#8217;s an example of how it will looks like when the thumbnail is showing on the listing page.</p>
<p><a href="http://www.entroducing.com/wp-content/uploads/2011/01/symfonybackendthumbnail.png" rel="shadowbox[post-330];player=img;" title="symfonybackendthumbnail"><img class="alignnone size-full wp-image-331" title="symfonybackendthumbnail" src="http://www.entroducing.com/wp-content/uploads/2011/01/symfonybackendthumbnail.png" alt="" width="644" height="208" /></a></p>
<p>Before you add it in, you need to check the variable name of the row that the admin generator uses.</p>
<p>To check the variable name, go to the cache folder for the module and open the _list.php file with a notepad.<br />
Take note of the row</p>
<pre class="brush: php">
\\cache\backend\dev\modules\autoContestphoto\templates\_list.php
...
        &lt;?php foreach ($pager-&gt;getResults() as $i =&gt; $contest_photo): $odd = fmod(++$i, 2) ? &#039;odd&#039; : &#039;even&#039; ?&gt;
          &lt;tr class=&quot;sf_admin_row &lt;?php echo $odd ?&gt;&quot;&gt;
            &lt;?php include_partial(&#039;contestphoto/list_td_batch_actions&#039;, array(&#039;contest_photo&#039; =&gt; $contest_photo, &#039;helper&#039; =&gt; $helper)) ?&gt;
            &lt;?php include_partial(&#039;contestphoto/list_td_tabular&#039;, array(&#039;contest_photo&#039; =&gt; $contest_photo)) ?&gt;
            &lt;?php include_partial(&#039;contestphoto/list_td_actions&#039;, array(&#039;contest_photo&#039; =&gt; $contest_photo, &#039;helper&#039; =&gt; $helper)) ?&gt;
          &lt;/tr&gt;
        &lt;?php endforeach; ?&gt;
...
</pre>
<p>In my case, the variable name for the row  is <strong>$contest_photo</strong></p>
<p>Next, create a partial call <strong>_thumbnail.php</strong> in the <strong>template </strong>folder of the module.<br />
In this partial, echo the path of the thumbnail or the photo with a img html tag</p>
<pre class="brush: php">
\\apps\backend\modules\contestphoto\templates\_thumbnail.php
&lt;img src=&quot;&lt;?php echo $contest_photo-&gt;getThumbnailPath() ?&gt;&quot;/&gt;
</pre>
<p>Then, edit the generator file to include the <strong>_thumbnail</strong> column for your list</p>
<pre class="brush: php">
\\apps\backend\modules\contest\config\generator.yml

...

      list:
        title: Contest Photo Management
        display: [=title, contest, category, user, title, isDeleted, _thumbnail]
        sort: [created_at, desc]
        max_per_page: 50

...
</pre>
<p>Clear your cache and see if the thumbnail loads. </p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fsymfony-backend-displaying-thumbnail-or-photo-in-listing&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/symfony-backend-displaying-thumbnail-or-photo-in-listing/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony error : Call to undefined method myUser::setReferer.</title>
		<link>http://www.entroducing.com/view/call-to-undefined-method-myusersetreferer</link>
		<comments>http://www.entroducing.com/view/call-to-undefined-method-myusersetreferer#comments</comments>
		<pubDate>Mon, 27 Dec 2010 13:53:52 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=324</guid>
		<description><![CDATA[If you have this error Call to undefined method myUser::setReferer. and if you are using sfGuard plugin, go to apps\[project]\lib\myUser.class.php and change class myUser extends sfBasicSecurityUser { } to class myUser extends sfGuardSecurityUser { }]]></description>
			<content:encoded><![CDATA[<p>If you have this error</p>
<p><code>Call to undefined method myUser::setReferer.</code></p>
<p>and if you are using sfGuard plugin, go to</p>
<p><code>apps\[project]\lib\myUser.class.php</code></p>
<p>and change</p>
<pre class="brush: php">

class myUser extends sfBasicSecurityUser
{
}
</pre>
<p>to</p>
<pre class="brush: php">

class myUser extends sfGuardSecurityUser
{
}
</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fcall-to-undefined-method-myusersetreferer&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/call-to-undefined-method-myusersetreferer/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>You are not allowed to access this file. Check frontend_dev.php for more information.</title>
		<link>http://www.entroducing.com/view/you-are-not-allowed-to-access-this-file-check-frontend_dev-php-for-more-information</link>
		<comments>http://www.entroducing.com/view/you-are-not-allowed-to-access-this-file-check-frontend_dev-php-for-more-information#comments</comments>
		<pubDate>Sat, 23 Oct 2010 05:26:24 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=319</guid>
		<description><![CDATA[If you had deployed to production/LIVE environment and encounter this error message when you tried to access fontend_dev.php, it is due to a security IP check in fontend_dev.php to check for 127.0.0.1 before it continue. Thus, you need to add your public IP address in fontend_dev.php to tell symfony to let you through in the [...]]]></description>
			<content:encoded><![CDATA[<p>If you had deployed to production/LIVE environment and encounter this error message when you tried to access <em>fontend_dev.php</em>, it is due to a security IP check in <em>fontend_dev.php </em> to check for 127.0.0.1 before it continue.</p>
<p>Thus, you need to add your public IP address in <em>fontend_dev.php</em> to tell symfony to let you through in the production environment. Here&#8217;s how to do it</p>
<p>In your <em>fontend_dev.php</em> file, put in the below line to print out your public ip address</p>
<pre class="brush: php">echo $_SERVER[&#039;REMOTE_ADDR&#039;]. &amp;quot;&amp;lt;br/&amp;gt;&amp;quot;</pre>
<p>Access frontend_dev.php and copy the IP address as shown.</p>
<p>Edit frontend_dev.php and change the line</p>
<pre class="brush: php">if (!in_array(@$_SERVER[&#039;REMOTE_ADDR&#039;], array(&#039;127.0.0.1&#039;, &#039;::1&#039;)))</pre>
<p>to</p>
<pre class="brush: php">if (!in_array(@$_SERVER[&#039;REMOTE_ADDR&#039;], array(&#039;127.0.0.1&#039;, &#039;::1&#039;, &#039;111.222.333.444&#039;)))</pre>
<p>Where 111.222.333.444 is the IP address you copied.</p>
<p>Upload back the frontend_dev.php and try again</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fyou-are-not-allowed-to-access-this-file-check-frontend_dev-php-for-more-information&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/you-are-not-allowed-to-access-this-file-check-frontend_dev-php-for-more-information/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Premature end of script headers in perl script</title>
		<link>http://www.entroducing.com/view/premature-end-of-script-headers-in-perl-script</link>
		<comments>http://www.entroducing.com/view/premature-end-of-script-headers-in-perl-script#comments</comments>
		<pubDate>Sat, 03 Jul 2010 08:30:19 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[perl cgi]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=230</guid>
		<description><![CDATA[&#8216;Premature end of scrip headers&#8217; error message refers to the script being stopped for whatever reason before it actually return any output to the browser. The first time to check is to ensure the below codes are output first print &#38;quot;Content-type: text/html\n\n&#38;quot;; And then to debug the error, simply add the below line(preferably after the [...]]]></description>
			<content:encoded><![CDATA[<p>&#8216;Premature end of scrip headers&#8217; error message refers to the script being stopped for whatever reason before it actually return any output to the browser.</p>
<p>The first time to check is to ensure the below codes are output first</p>
<pre class="brush: perl">print &amp;quot;Content-type: text/html\n\n&amp;quot;;</pre>
<p>And then to debug the error, simply add the below line(preferably after the above code).</p>
<pre class="brush: perl">use CGI::Carp qw(fatalsToBrowser);</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fpremature-end-of-script-headers-in-perl-script&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/premature-end-of-script-headers-in-perl-script/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create new log file with log4j FileAppender when using Quartz Scheduler</title>
		<link>http://www.entroducing.com/view/create-new-log-file-with-log4j-fileappender-when-using-quartz-scheduler</link>
		<comments>http://www.entroducing.com/view/create-new-log-file-with-log4j-fileappender-when-using-quartz-scheduler#comments</comments>
		<pubDate>Tue, 02 Mar 2010 14:49:18 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[quartz]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=177</guid>
		<description><![CDATA[Recently came across a problem whereby the quartz scheduler could not recreate a new log4j FileAppender log when the job is call again. Googled a bit and found out a couple of solutions such as using a custom log4j classes, which create a seperate thread when being called in quartz scheduler. I find that it [...]]]></description>
			<content:encoded><![CDATA[<p>Recently came across a problem whereby the quartz scheduler could not recreate a new log4j FileAppender log when the job is call again.</p>
<p>Googled a bit and found out a couple of solutions such as using a custom log4j classes, which create a seperate thread when being called in quartz scheduler.</p>
<p>I find that it is too complex and had try several ways to recreate the log file inside Quartz.</p>
<p>And finally came up with this one line of code.</p>
<p>Before I begin, let&#8217;s take a look at my log4j config.<br />
This log4j config will create a simple console system out logger and also a FileAppender logger.<br />
For my case, I want to re-create a new log file whenever this job is run.</p>
<pre class="brush: php">
log4j.rootLogger=INFO, stdout
log4j.additivity.stdout=false
log4j.additivity.joblog=false
log4j.appender.ROOT.layout.ConversionPattern=[%d] %t %c %-5p - %m%n

#console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p - %m%n

#per job execution log
log4j.logger.com.yourcompany=INFO, joblog
log4j.appender.joblog=org.apache.log4j.FileAppender
log4j.appender.joblog.layout=org.apache.log4j.PatternLayout
log4j.appender.joblog.File=../jobtemp.log
log4j.appender.joblog.Append=false
log4j.appender.joblog.layout.ConversionPattern=%d %p - %m%n
</pre>
<p>and here&#8217;s the schedule job</p>
<pre class="brush: java">
public class ScheduleJob implements StatefulJob {

	private static Logger logger = Logger.getLogger(ScheduleJob.class);

	public void startJob() throws SchedulerException{
		Scheduler scheduler =
			StdSchedulerFactory.getDefaultScheduler();
		scheduler.start();
	}

	public void execute(JobExecutionContext context)
		throws JobExecutionException {

		//reset log4j config for FileAppender
		PropertyConfigurator.configure(&amp;quot;../conf/log4j.properties&amp;quot;);

		RunJobImmediately newJob  = new RunJobImmediately();
		newJob.performJob();

	}

	public static void main(String args[]){
    	try{
    		ScheduleJob scheduleJob = new ScheduleJob();
    		scheduleJob.startJob();

		}catch(Exception e){
			logger.error(e);
		}
	}
}
</pre>
<p>and finally the one line of code to recreate the log file.<br />
Apparently, this line will somehow &#8216;reload&#8217; the log4j  utitlies, which thus recreate the FileAppender logger to re-create the log file.</p>
<pre class="brush: java">
PropertyConfigurator.configure(&amp;quot;../conf/log4j.properties&amp;quot;);
</pre>
<p>Feel free to let me know if there is any performance issues or it is not working at your side.</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fcreate-new-log-file-with-log4j-fileappender-when-using-quartz-scheduler&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/create-new-log-file-with-log4j-fileappender-when-using-quartz-scheduler/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing out active threads in java</title>
		<link>http://www.entroducing.com/view/printing-out-active-threads-in-java</link>
		<comments>http://www.entroducing.com/view/printing-out-active-threads-in-java#comments</comments>
		<pubDate>Sat, 20 Feb 2010 07:41:30 +0000</pubDate>
		<dc:creator>Benny</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://www.entroducing.com/?p=157</guid>
		<description><![CDATA[Here&#8217;s the code snippets to display the number of running threads in your java program. It&#8217;s good to use it to track your resources. int activeCount = Thread.activeCount(); System.out.println(&#38;quot;total active = &#38;quot; + activeCount); Thread[] threads = new Thread[activeCount]; Thread.enumerate(threads); System.out.println(&#38;quot;before&#38;quot;); for (int j=0; j&#38;lt;threads.length; j++) { System.out.println(threads[j].toString()); } //run your classes Benny benny = new Benny(); [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the code snippets to display the number of running threads in your java program.</p>
<p>It&#8217;s good to use it to track your resources.</p>
<pre class="brush: java">
int activeCount = Thread.activeCount();
System.out.println(&amp;quot;total active = &amp;quot; + activeCount);
Thread[] threads = new Thread[activeCount];
Thread.enumerate(threads);

System.out.println(&amp;quot;before&amp;quot;);
for (int j=0; j&amp;lt;threads.length; j++) {
 System.out.println(threads[j].toString());
}

//run your classes
Benny benny = new Benny();

activeCount = Thread.activeCount();
System.out.println(&amp;quot;total active = &amp;quot; + activeCount);

threads = new Thread[activeCount];
System.out.println(&amp;quot;after&amp;quot;);
Thread.enumerate(threads);
for (int i=0; i&amp;lt;threads.length; i++) {
 System.out.println(threads[i].toString());
}
</pre>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.entroducing.com%2Fview%2Fprinting-out-active-threads-in-java&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.entroducing.com/view/printing-out-active-threads-in-java/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

