<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>acts_as_developer: Minimize or disable WEBrick logging</title>
    <link>http://www.robertshowalter.com/articles/2007/06/24/minimize-or-disable-webrick-logging</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Minimize or disable WEBrick logging</title>
      <description>&lt;p&gt;I wrote a simple application today that used WEBrick servlets to serve up some content, and I wanted to minimize the logging that WEBrick puts out.&lt;/p&gt;


	&lt;p&gt;There are two kings of logging used by WEBrick:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Server logging, which is controlled by the &lt;code&gt;:Server&lt;/code&gt; parameter passed to &lt;code&gt;WEBrick::HTTPServer.new&lt;/code&gt;. This uses syslog-style log levels.&lt;/li&gt;
		&lt;li&gt;Access logging, which is controlled by the &lt;code&gt;:AccessLog&lt;/code&gt; parameter. This logs each request, and is similar to the Apache access log.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The default server log level is &lt;code&gt;INFO&lt;/code&gt;, but I wanted to change it to &lt;code&gt;WARN&lt;/code&gt;. I also wanted to disable Access logging altogether.&lt;/p&gt;


Here&amp;#8217;s what I ended up using:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;WEBrick&lt;/span&gt;
&lt;span class="ident"&gt;server&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;HTTPServer&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;
  &lt;span class="symbol"&gt;:Port&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="number"&gt;8000&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt;
  &lt;span class="symbol"&gt;:Logger&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="constant"&gt;Log&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="constant"&gt;nil&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="constant"&gt;BasicLog&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;WARN&lt;/span&gt;&lt;span class="punct"&gt;),&lt;/span&gt;
  &lt;span class="symbol"&gt;:AccessLog&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;[]&lt;/span&gt;
&lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
Now the server is silent unless an unexpected problem occurs.</description>
      <pubDate>Sun, 24 Jun 2007 22:22:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:624b5593-7706-4583-9ec6-308cc27e3232</guid>
      <author>Bob Showalter</author>
      <link>http://www.robertshowalter.com/articles/2007/06/24/minimize-or-disable-webrick-logging</link>
      <category>Ruby</category>
    </item>
  </channel>
</rss>
