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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:07:42+00:00 2026-05-22T02:07:42+00:00

I have a simple command line program written in python. The program logs to

  • 0

I have a simple command line program written in python. The program logs to screen using the logging module configured in the following way:

logging.basicConfig(level=logging.INFO, format='%(levelname)-8s %(message)s')

The weird thing is that in my laptop, the program logs at the right level (INFO) an with the desired format, while when I run the program in a server the program only logs errors and warnings with another format.

In both systems I am running Python 2.7 inside a virtual environment. The environments are not exactly the same.

I think that some module is changing my configuration. I do not understand why it happens only in the server, but is there any way, to find which one?

Thanks in advance,

  • 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-22T02:07:43+00:00Added an answer on May 22, 2026 at 2:07 am

    The basicConfig() API in logging will do nothing (as documented) if the root logger already has handlers configured. Your basicConfig() call may be being ignored because some other code in the server has already configured some handlers for the root logger.

    In general library code should not add handlers – that’s the application developer’s responsibility. However if you are e.g. developing a web application using a framework, the framework may already have configured some handlers.

    You say “on the server”, but it’s not clear whether you’re talking about a service application or just running a utility script on a machine which happens to be a server. As you say, the virtual envs are slightly different, so the difference between them might be the place to look for a hint.

    To find out what’s configuring handlers on the root logger, you could grep the relevant sources for basicConfig() or addHandler().

    Alternatively, you could explicitly add a handler rather than relying on basicConfig() to do it for you:

    f = logging.Formatter('%(levelname)-8s %(message)s')
    h = logging.StreamHandler()
    h.setFormatter(f)
    logging.getLogger().addHandler(h)
    

    but this may result in multiple messages if other console handlers are also added to the root logger.

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

Sidebar

Related Questions

I have a simple C++ program that I can compile (g++ from command line)
I have written a simple program that pings three sites and then reacts to
Since SQL Server does not have a simple batch command line executor for the
I have a Python-based app that can accept a few commands in a simple
Ok, i have simple scenario: have two pages: login and welcome pages. im using
I have a simple little test app written in Flex 3 (MXML and some
For a simple command-line todo manager (that is to be implemented in C), this
I have a simple java program that runs fine in eclipse but cannot find
I have a simple program. Its job is to move files from A to
I have the following source for an assembly program that I got in a

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.