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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:52:06+00:00 2026-06-09T22:52:06+00:00

Consider this code: import logging print print logging.error(log) I get: print ERROR:root:log now if

  • 0

Consider this code:

import logging
print "print"
logging.error("log")

I get:

print
ERROR:root:log

now if I include a thid-party module at the beginning of the previous code and rerun it I get only:

print

there are some previous question about this, but here I cannot touch the module I’m importing.

The code of the third-party module is here: http://atlas-sw.cern.ch/cgi-bin/viewcvs-atlas.cgi/offline/DataManagement/DQ2/dq2.clientapi/lib/dq2/clientapi/DQ2.py?view=markup, but my question is more general: independently of the module I’m importing I want a clean logging working in the expected way

Some (non-working) proposed solutions:

from dq2.clientapi.DQ2 import DQ2
import logging
del logging.root.handlers[:]

from dq2.clientapi.DQ2 import DQ2
import logging
logging.disable(logging.NOTSET)

logs = logging.getLogger('root')
logs.error("Some error")

the next one works, but produced some additional errors:

from dq2.clientapi.DQ2 import DQ2
import logging
reload(logging)

I get:

print
ERROR:root:log
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/afs/cern.ch/sw/lcg/external/Python/2.6.5/x86_64-slc5-gcc43-    opt/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/afs/cern.ch/sw/lcg/external/Python/2.6.5/x86_64-slc5-gcc43-opt/lib/python2.6/logging/__init__.py", line 1509, in shutdown
    h.close()
  File "/afs/cern.ch/sw/lcg/external/Python/2.6.5/x86_64-slc5-gcc43-opt/lib/python2.6/logging/__init__.py", line 705, in close
    del _handlers[self]
KeyError: <logging.StreamHandler instance at 0x2aea031f7248>
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/afs/cern.ch/sw/lcg/external/Python/2.6.5/x86_64-slc5-gcc43-opt/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/afs/cern.ch/sw/lcg/external/Python/2.6.5/x86_64-slc5-gcc43-opt/lib/python2.6/logging/__init__.py", line 1509, in shutdown
    h.close()
  File "/afs/cern.ch/sw/lcg/external/Python/2.6.5/x86_64-slc5-gcc43-opt/lib/python2.6/logging/__init__.py", line 705, in close
    del _handlers[self]
KeyError: <logging.StreamHandler instance at 0x2aea031f7248>

from dq2.clientapi.DQ2 import DQ2
import logging
logger = logging.getLogger(__name__)
ch = logging.StreamHandler()  
logger.addHandler(ch)
logger.error("log")
  • 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-09T22:52:08+00:00Added an answer on June 9, 2026 at 10:52 pm

    It depends on what the other module is doing; e.g. if it’s calling logging.disable then you can call logging.disable(logging.NOTSET) to reset it.

    You could try reloading the logging module:

    from importlib import reload
    logging.shutdown()
    reload(logging)
    

    The problem is this will leave the third-party module with its own copy of logging in an unusable state, so could cause more problems later.

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

Sidebar

Related Questions

Consider this code: import socket store = [] scount = 0 while True: scount+=1
Consider this code: package Prova; import java.util.ArrayList; public class Prova { private ArrayList<String> people;
Consider this code: if(initscr() == NULL) ERROR(Cannot start ncurses mode.\n); keypad(stdscr, TRUE); cbreak(); int
Consider this code: import java.util.*; class jm45 implements Comparator<jm45> { private int x; jm45(int
Consider this code: import java.util.regex.*; public class Pattern3 { /** * @param args the
Consider this code: import java.util.Collections; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.core.userdetails.User; public class SecureStuff { @PreAuthorize(#user.password
Consider the following code: module ftwr; import std.regex; import std.stdio; import std.conv; import std.traits;
please consider this code: import xml.etree.ElementTree as ET import urllib XML_response = urllib.urlopen('http://www.navlost.eu/aero/metar/?icao=LWSK&dt0=2011-05-03+12%3A00%3A00&c=1&rt=metar').read() tree
Consider this code: import scala.xml.{Node,HasKeyValue} def domatch(x:Node): Node = { val hasBar = new
Consider code like this (Python): import random for i in [1, 2, 3, 4]:

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.