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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:16:07+00:00 2026-05-17T20:16:07+00:00

I have a logger that functions properly at the start of a script, then

  • 0

I have a logger that functions properly at the start of a script, then breaks in the middle. It looks like its handler is getting overwritten by a str, but I can’t figure out where.

At the start of the script, I’m printing the handler and its level. The following code:

print 'Array of handlers', logger.handlers
    for h in logger.handlers:
        print 'Handler', h
        print 'Handler level', h.level

produces this:

Array of handlers [<logging.FileHandler instance at 0x19ef320>]
Handler <logging.FileHandler instance at 0x19ef320>
Handler level 0

Now in the middle of execution, you’ll see that the logger’s handler (hdlr) is interpreted as a str.

Started from <class 'mymodule.ext.freebase.HTTPMetawebSession'>.
Traceback (most recent call last):
  File "hadoop/get_web_data.py", line 144, in <module>
    main()
  File "hadoop/get_web_data.py", line 121, in main
    for count, performer in enumerate(results):
  File "/home/wraith/dev/modules/mymodule/ext/freebase.py", line 126, in mqlreaditer
    r = self._httpreq_json(service, 'POST', form=dict(query=qstr))
  File "/home/wraith/dev/modules/mymodule/contrib/freebase/api/session.py", line 369, in _httpreq_json
    resp, body = self._httpreq(*args, **kws)
  File "/home/wraith/dev/modules/mymodule/contrib/freebase/api/session.py", line 346, in _httpreq
    self.log.info('%s %s%s%s', method, url, formstr, headerstr)
  File "/usr/lib/python2.5/logging/__init__.py", line 985, in info
    apply(self._log, (INFO, msg, args), kwargs)
  File "/usr/lib/python2.5/logging/__init__.py", line 1101, in _log
    self.handle(record)
  File "/usr/lib/python2.5/logging/__init__.py", line 1111, in handle
    self.callHandlers(record)
  File "/usr/lib/python2.5/logging/__init__.py", line 1147, in callHandlers
    if record.levelno >= hdlr.level:
AttributeError: 'str' object has no attribute 'level'

In the last 2 lines, hdlr.level blows up because hdlr is not a str.

if record.levelno >= hdlr.level:
AttributeError: 'str' object has no attribute 'level'

After setting the handler at the beginning, which is fine, I do not add another handler or alter the existing in any way. The only command I call on logger is logger.info('event to log').

What would alter the logger’s handler in this way?

  • 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-17T20:16:08+00:00Added an answer on May 17, 2026 at 8:16 pm

    The contents of the string might give you a clue as to how and why it is going wrong.

    I suggest putting

    print(repr(self.log.handlers))
    

    right before your call to info:

    self.log.info('%s %s%s%s', method, url, formstr, headerstr)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a logger in a c++ application that uses defines as follows: #define
I have a Matlab program that is running longer than I'd like it to.
I have a <ul> tag that is hardcoded in my markup: So, something like:
I have an asp.net c# website that I am having a problem getting the
Today I realized that I no longer have a Web Content Form option (where
I have a query that is longer than 8000 in length I tried to
I have a subscription link on a page that the logged in users can
I have some code that gets the current logged in user. userID = request.session.get(_auth_user_id)
I have a custom component that is vertically longer than the screen height and
I have a Windows service that runs as a logged-in user (local admin). During

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.