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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:44:58+00:00 2026-06-14T16:44:58+00:00

The Python logging tutorial says that the newer ways of formatting are beyond the

  • 0

The Python logging tutorial says that the newer ways of formatting are beyond the scope of the tutorial, without mentioning where to learn about it.

I would appreciate any examples or link to documentation that allow me to use .format() style message formatting in logging calls such as debug(), info(), etc.

  • 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-14T16:44:59+00:00Added an answer on June 14, 2026 at 4:44 pm

    Recently, I was looking for that too. I think I got pointed to the solution here on SO, but I only have the final url at hand. This is what I do:

    # http://plumberjack.blogspot.de/2010/10/supporting-alternative-formatting.html
    class BraceMessage(object):
        def __init__(self, fmt, *args, **kwargs):
            self.fmt = fmt
            self.args = args
            self.kwargs = kwargs
    
        def __str__(self):
            return self.fmt.format(*self.args, **self.kwargs)
    
    _F = BraceMessage
    

    Can be used like this:

    logger.debug(_F("foo {0} {quux}", bar, quux=baz))
    

    The formatting will only take place in the very moment the message is evaluated, so you don’t lose lots of performance if a log level is disabled. The author of that snippet above made this (and some other utilities) available as a package: logutils.

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

Sidebar

Related Questions

In the Python docs I found that logging messages are possible in python scripts
I would like to use the python logging module to log all of the
I have a question about python standard logging mechanism. So if I use logging.config.fileConfig
I'm using the logging module in Python and I would like it to create
The release notes say: Django 1.3 adds framework-level support for Python’s logging module. That's
I am working on an a handler for the python logging module. That essentially
Is there any tools that catches python logging (socket or http) handlers' reports, and
I'm looking for a way to perform partial string formatting in Python logging formatters.
I am using python logging in my django application. A class that connects to
I have a multi-threaded Python application that makes use of the built in logging

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.