How can I conditionally suppress logging in Express (or Connect)? <p>When using the logger middleware which is part of Connect (as well as Express), I would like to be able to disable logging on certain requests, say by setting a flag on the response or something.</p> <p>I managed to do it by saying:</p> <pre><code>res.doNotLog = true; </code></pre> <p>and then, deep in logger.js (part of the Connect module), I put</p> <pre><code>if(res.doNotLog) return; </code></pre> <p>in the right place. But of course I don't want to be modifying code in the module itself. Is there any way I can cause the same to happen without having to hack the module?</p> <p><strong>Edit:</strong></p> <p>This worked:</p> <pre><code>var app = _express.createServer(); // set 'hello' routing...note that this is before middleware // so it won't be logged app.get('/sayhello', function(req, res) {res.send("hey");}); // configure middleware: logging, static file serving app.configure(function() { app.use(_express.logger()); app.use(_express.static(__dirname + '/www')); }); // set 'goodbye' routing...note that this is after middleware // so it will be logged app.get('/saygoodbye', function(req, res) {res.send("later...");}); </code></pre>