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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:16:15+00:00 2026-06-08T18:16:15+00:00

I have a django app with two management commands, which both call a common

  • 0

I have a django app with two management commands, which both call a common library. Lets call them sync_a and sync_b. I want the log entry to record the calling function (or module), so that I know if the log message comes from sync_a or sync_b

# sync_a.py
from utils.some_module import some_function
import logging
logger = logging.getLogger(__name__)

class Command(BaseCommand):
    some_function('a')

# sync_b.py
from utils.some_module import some_function
import logging
logger = logging.getLogger(__name__)

class Command(BaseCommand):
    some_function('a')

# some_module.py
def some_function(param):
    logger.info("running")

My logging settings in settings.py are:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'semi_verbose': {
            'format': '[%(levelname)s] %(module)s %(name)s %(funcName)s(): %(message)s'
        },
    },
    'handlers': {
        'console':{
            'level':'DEBUG',
            'class':'logging.StreamHandler',
            'formatter': 'semi_verbose'
        }
    },
    'loggers': {
        'app': {
            'handlers': ['console'],
            'level': 'debug',
            'propagate': True
        }
    }
}

The log messages I’m seeing are of the format:

[INFO] utils.some_module some_function(): running

I’d like them to include either sync_a or sync_b.

I’m not sure if what I’m trying to do is unusual or if I’ve configured things incorrectly. I know that I could customise the log.info() line to use the parameter or to use inspect, but I’m trying to find a solution that works without needing to do this because I have several management commands and libraries that I’d like it to work across.

  • 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-08T18:16:16+00:00Added an answer on June 8, 2026 at 6:16 pm

    I took a look at the Python logging documentation, and it doesn’t look like the LogRecord captures the information you’re looking for.

    If I were going to do this, I think I would write a custom Formatter that could look up and add call stack information to the logging call. The inspect module’s stack function is probably the best way to do that.

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

Sidebar

Related Questions

I have two apps in my Django project: a public-facing app, and a management
I have two servers: one running a django app and one running both a
I have a django app which is used for managing registrations to a survey.
I have a Django app which uses LDAP as the authentication backend. I'm not
I have two related models (one to many) in my django app and When
While integrating a Django app I have not used before, I found two different
I have two simple models in my Django app. Here's what they look like:
I have two classes, Foo and Bar, in a Django app (on AppEngine if
I have a Django project which has two apps (one created as debug test).
Here is the situation. I have a django project with two installed apps. Both

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.