<?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>bsdeluxe &#187; logs</title>
	<atom:link href="http://www.bsdeluxe.com/tag/logs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bsdeluxe.com</link>
	<description>...is Bob Sherron</description>
	<lastBuildDate>Tue, 29 Nov 2011 15:04:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Rails-Like SQL Query Logging in WordPress</title>
		<link>http://www.bsdeluxe.com/rails-like-sql-query-logging-in-wordpress/</link>
		<comments>http://www.bsdeluxe.com/rails-like-sql-query-logging-in-wordpress/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 15:58:50 +0000</pubDate>
		<dc:creator>Bob Sherron</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.bsdeluxe.com/?p=24</guid>
		<description><![CDATA[In which the author enables SQL query logging in Wordpress.]]></description>
			<content:encoded><![CDATA[<p>Coming out of doing Rails development for the past couple years, there are several things that I have become pretty accustomed to that are somewhat aggravating not to have in the WordPress environment. The one thing that I miss the most though, is having a log of SQL queries to pore over and see what&#8217;s happening with the DB, and which queries are taking the longest.  After some searching, I came across <a href="http://minutillo.com/steve/weblog/2004/05/25/wordpress-logging-hinters">this post</a>, which led me in the right direction.  After some tweaking here is the result:</p>
<p>In your wp-config.php, add this line:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">define('SAVEQUERIES', true);</div></div>
<p>In your functions.php, add this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">// outputs SQL queries to a log<br />
add_action('shutdown', 'sql_logger');<br />
function sql_logger() {<br />
&nbsp; &nbsp; global $wpdb;<br />
&nbsp; &nbsp; $log_file = fopen(ABSPATH.'/sql_log.txt', 'a');<br />
&nbsp; &nbsp; fwrite($log_file, &quot;//////////////////////////////////////////\n\n&quot; . date(&quot;F j, Y, g:i:s a&quot;).&quot;\n&quot;);<br />
&nbsp; &nbsp; foreach($wpdb-&gt;queries as $q) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; fwrite($log_file, $q[0] . &quot; - ($q[1] s)&quot; . &quot;\n\n&quot;);<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; fclose($log_file);<br />
}</div></div>
<p>Jackpot! Now, you have a log file to go to town on.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bsdeluxe.com/rails-like-sql-query-logging-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

