<?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>Thu, 17 Jun 2010 22:13:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Rails-Like SQL Query Logging in WordPress</title>
		<link>http://www.bsdeluxe.com/2009/08/31/rails-like-sql-query-logging-in-wordpress/</link>
		<comments>http://www.bsdeluxe.com/2009/08/31/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. <a href="http://www.bsdeluxe.com/2009/08/31/rails-like-sql-query-logging-in-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
<pre>
define('SAVEQUERIES', true);
</pre>
<p>In your functions.php, add this:</p>
<pre>
// outputs SQL queries to a log
add_action('shutdown', 'sql_logger');
function sql_logger() {
	global $wpdb;
	$log_file = fopen(ABSPATH.'/sql_log.txt', 'a');
	fwrite($log_file, "//////////////////////////////////////////\n\n" . date("F j, Y, g:i:s a")."\n");
	foreach($wpdb->queries as $q) {
		fwrite($log_file, $q[0] . " - ($q[1] s)" . "\n\n");
	}
	fclose($log_file);
}
</pre>
<p>Jackpot! Now, you have a log file to go to town on.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bsdeluxe.com/2009/08/31/rails-like-sql-query-logging-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
