<?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>[MeIsProgrammer] &#187; Apache</title>
	<atom:link href="http://just-thor.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://just-thor.com</link>
	<description>all play and no work makes me a dull boy</description>
	<lastBuildDate>Sat, 03 Jul 2010 18:28:21 +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>Logging for different requested URI in Apache HTTP Server</title>
		<link>http://just-thor.com/2009/09/01/logging-for-different-requested-uri-in-apache-http-server/</link>
		<comments>http://just-thor.com/2009/09/01/logging-for-different-requested-uri-in-apache-http-server/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:19:57 +0000</pubDate>
		<dc:creator>Thor</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://just-thor.com/?p=40</guid>
		<description><![CDATA[Sometimes,we might want to log differently for different requested URI in Apache http server. Activate custom logging in your Apache http server First,write a line of custom log format and [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes,we might want to log differently for different requested URI in Apache http server.</p>
<h2>Activate custom logging in your Apache http server</h2>
<p>First,write a line of custom log format and name it as CustomLogFormat<br />
<pre>LogFormat &quot;%h %l %u %t \&quot;%r\&quot; %&amp;gt;s %b \&quot;%{Referer}i\&quot; \&quot;%{User-Agent}i\&quot;&quot; CustomLogFormat</pre><br />
Then add another line to activate the logging.<br />
<pre>CustomLog /tmp/logForAll.log CustomLogFormat</pre><br />
Restart the webserver and you shall see the every visits to your server are logged in the log file.</p>
<h2>But wait,what if I want to separate the log files when user visits login.php(or whatsoever file)?</h2>
<p>After the LogFormat line,we add another line to specify the condition.<br />
<pre>SetEnvIf Request_URI &quot;^/login\.php$&quot; isLoginPage</pre><br />
Then we modified the previous CustomLog line to exclude logging on login page visit.<br />
<pre>CustomLog /tmp/logForAll.log CustomLogFormat env=!isLoginPage</pre><br />
At last,we add another line to log only login page visit.<br />
<pre>CustomLog /tmp/logOnlyForLogin.log CustomLogFormat env=isLoginPage</pre><br />
Restart your web server and we are done!</p>
<p>Checkout the <a title="Apache log files documentation" href="http://httpd.apache.org/docs/1.3/logs.html" target="_blank">Apache log files documentation</a> for more info.</p>
<p>Happy coding. <img src='http://just-thor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://just-thor.com/2009/09/01/logging-for-different-requested-uri-in-apache-http-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
