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 6114381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:58:05+00:00 2026-05-23T14:58:05+00:00

In the logging howto documentation there is this example: import logging # create logger

  • 0

In the logging howto documentation there is this example:

import logging

# create logger
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)

# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)

# create formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# add formatter to ch
ch.setFormatter(formatter)

# add ch to logger
logger.addHandler(ch)

Why I should set the level to logging.DEBUG twice, for Logger, and for the StreamHandler?

I understand ch.setLevel(logging.DEBUG) will set the debug level for the stream handler. But what the effect is of setting the level to logger? Where this level is reflected?

I get the same console output if I change the level to, for example, INFO either to the Logger or to the StreamHandler.

That is:

...........
logger.setLevel(logging.INFO)
............
ch.setLevel(logging.DEBUG)

gives the same output in console than

...........
logger.setLevel(logging.DEBUG)
............
ch.setLevel(logging.INFO)
  • 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-05-23T14:58:05+00:00Added an answer on May 23, 2026 at 2:58 pm

    It’s there for fine-tuning (you can have multiple handlers, and each could have different levels set) — you can safely not set level on the handler, which will cause it to process all messages (a.k.a. NOTSET level), and leave level filtering to the logger.

    Logger is also the first to filter the message based on a level — if you set the logger to INFO, and all handlers to DEBUG, you still won’t receive DEBUG messages on handlers — they’ll be rejected by the logger itself. If you set logger to DEBUG, but all handlers to INFO, you won’t receive any DEBUG messages either — because while the logger says “ok, process this”, the handlers reject it (DEBUG < INFO).

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

Sidebar

Related Questions

I haven't been able to find any documentation on how to configure Hibernate's logging
After logging in using the Login control the browser loses the session. This only
What logging library or approach would you recommend for this case: We want to
I have used Log4j and JDK Logger both for logging purpose, so i find
I was able to find the documentation on PageEditor from this answer . But
I am looking for example configuration on how to get Log4net logging to a
How to print the test field in the following query in django res=Resources.objects.filter(test=request.profile) logging.debug(test)
I am creating a twisted plugin. There is documentation here about how to control
I would like to know how can I enable debug-level logging with Axis 2
When using System.Diagnostics TraceSource for logging/tracing, is there a difference between using TraceSource.TraceTransfer and

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.