Skip to content

How can I stop the logging of HTTP requests to the app? #430

Description

@cole-wilson

Currently my app writes the following to the console:

172.18.0.1 - - [08/Aug/2021 03:13:53] "GET / HTTP/1.1" 404 -

There are messages like this for every request to my app. I would not like to see this printed to the console.

Is there a way to disable this? The default python logging module does not seem to work.
Thank you!

Activity

  1. cloudguruab commented on Aug 8, 2021

    @cloudguruab

    Hey, to help with your issue I am assuming you'd like to suppress the output of stdout to the console. To do so:

    from contextlib import contextmanager
    import sys, os
    
    @contextmanager
    def suppress_stdout():
        with open(os.devnull, "w") as devnull:
            old_stdout = sys.stdout
            sys.stdout = devnull
            try:  
                yield
            finally:
                sys.stdout = old_stdout
    

    with this

    print("Now you see it")
    # with suppress_stdout():
        print("Now you don't")
    
  2. added this to the 1.8.0 milestone on Aug 9, 2021
  3. seratch commented on Aug 9, 2021

    @seratch
    Contributor

    Hi @cole-wilson, thanks for asking this question. As you are already aware of, there is no way to customize it at the moment. I'll add a new option to configure it in the next version: #431

    If you need more granular configuration on logging, I would recommend using a different web framework/sever for your app development. Here is a Flask app example:

    @cloudguruab Thanks for jumping in and helping other developers!

  4. cole-wilson commented on Aug 9, 2021

    @cole-wilson
    Author

    Thank you so much for both of your quick responses!

  5. added a commit that references this issue on Aug 10, 2021
    a233837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions