title: Error logging with express.logger in node.js
body: <p>I am attempting to log only certain events to a file via express.logger(...) with a custom function and it is hanging when the response and request do not meet the criteria I have set.</p>
  
  <pre><code>var express = require('express'),
   app = express.createServer(
    express.logger(function(req, res) {
     var status = res.statusCode,
     color = 32;
  
     if (status &gt;= 500) color = 31;
     else if (status &gt;= 400) color = 33;
     else if (status &gt;= 300) color = 36;
  
     if (req.method==='POST' &amp;&amp; req.originalUrl!=='/plankton') {
      return '\033[90m' + req.method
       + ' ' + req.originalUrl + ' '
       + '\033[' + color + 'm' + res.statusCode
       + ' \033[90m'
       + (new Date - req._startTime)
       + 'ms\033[0m';
     }
     else if (res.statusCode&gt;=400) {
      return '\033[90m' + req.method
       + ' ' + req.originalUrl + ' '
       + ' ' + req.body + ' '
       + '\033[' + color + 'm' + res.statusCode
       + ' \033[90m'
       + (new Date - req._startTime)
       + 'ms\033[0m';
     } else {
  // what should be inserted here?
  // I only want to log the above events...
     }
    });
   )
  </code></pre>
  
  <p>return '' in the else does not work. It hangs, my guess is that its not allowing the response to finish/send.</p>
  
  <p>Perhaps I should use a different method to log, but I like the simplicity of the express middleware since it allows me to not have to include log messages everywhere - or can I get around that as well and have a listener for the certain events..</p>
  
  <p>Any ideas on what I should have in the else? Or suggestions on a better method?</p>