Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8060215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:54:56+00:00 2026-06-05T09:54:56+00:00

When using the logger middleware which is part of Connect (as well as Express),

  • 0

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.

I managed to do it by saying:

res.doNotLog = true;

and then, deep in logger.js (part of the Connect module), I put

if(res.doNotLog) return;

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?

Edit:

This worked:

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...");});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:54:57+00:00Added an answer on June 5, 2026 at 9:54 am

    The most obvious thing would be to put the handlers for those requests before the logger. This is easy in pure Connect, not sure how to do it in Express because a lot of the router code is shared between routes. If there were only a few such requests, you could handle them Connect-style earlier in the stack than app.router.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom HTTP Module. I would like to inject the logger using
I found the logging information is printed out twice when using logger.info like BasicConfigurator.configure();
I have a python logger set up, using python's logging module. I want to
I'm using Log4Net to handle logging in my WPF application. Currently, the logger is
I'm using the org.jboss.logging.Logger class, and seem to have come across an incongruity. When
I have a class generating error output that I'd like to output using Logger.
I am using apache logger api for logging the messages, warnings, errors and exception.
Using the standard java logging API (import java.util.logging.Logger), after the construction: Logger l =
I'm using Unity, and I register a logger like this: public class MvcApplication :
I am currently using Logger from Java.Util, The default behavior for logger.info is like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.