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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:18:01+00:00 2026-05-26T16:18:01+00:00

In django we have settings.py that defines the DEBUG for the whole project. Now,

  • 0

In django we have settings.py that defines the DEBUG for the whole project.

Now,
My have debug level is independently configured in settings.py.

How should I use logging.DEBUG ?

Way1:

if settings.DEBUG:
    logging.debug("Debug message")

Way2:

# Without checking settings.DEBUG
logging.debug("Debug message")

What is a good practice ?

I think we should use Way2 since logging level already decides – if the message will be logged or not.
But, some say that Way1 is a standard practice.

  • 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-26T16:18:02+00:00Added an answer on May 26, 2026 at 4:18 pm

    I think it’s not a good thing to rely too much on a global setting such as DEBUG, which changes the whole behavior of your app.

    What if you want to audit code and log stuff in production ? You’re not going to turn DEBUG to true to do this, are you ? You’d rather tone down your log filter.

    On a more stylistic point of view, it makes little sense and is not very pythonistic to have 2 settings (DEBUG and log level) affect a single behavior.

    Long answer short: my opinion is that method 2 is superior, technically and stylisticly speaking.

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

Sidebar

Related Questions

I have a Django project that uses SQLAlchemy to use some legacy ORM objects.
I have a Fabric task that needs to access the settings of my Django
I got a Django project, with 1 application in it. If I have debug
I have a python package that needs to pull in settings from my project
I have django installed on my server with pymongo and mongoengine.My django project settings.py
I have a settings.py file and a dev_settings.py file that I use to override
Why doesn't django just have the model to use for User configured in the
I have a django project that works fine with the embedded server, but when
This is probably a setting error somewhere. I have a django app that works
I'm trying to get Django's manage.py to run with modified settings files. I have

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.