473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

logging breakdown

Hello,

I'm getting strange exception raised using module logging.
It's strange because it happens only sometimes, and it happens
in different places (but always in a logging method).
i.e. this line of code:

log.info('SMS sent')

produces following traceback:

Traceback (most recent call last):
File "L:\_progs\python\test\send_sms.py", line 36, in send_sms
log.info('SMS sent')
File "L:\Python23\lib\logging\__init__.py", line 893, in info
apply(self._log, (INFO, msg, args), kwargs)
File "L:\Python23\lib\logging\__init__.py", line 994, in _log
self.handle(record)
File "L:\Python23\lib\logging\__init__.py", line 1004, in handle
self.callHandlers(record)
File "L:\Python23\lib\logging\__init__.py", line 1037, in callHandlers
hdlr.handle(record)
File "L:\Python23\lib\logging\__init__.py", line 592, in handle
self.emit(record)
File "L:\Python23\lib\logging\__init__.py", line 684, in emit
self.handleError(record)
File "L:\Python23\lib\logging\__init__.py", line 636, in handleError
traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)
File "L:\Python23\lib\traceback.py", line 123, in print_exception
print_tb(tb, limit, file)
File "L:\Python23\lib\traceback.py", line 69, in print_tb
if line: _print(file, ' ' + line.strip())
File "L:\Python23\lib\traceback.py", line 13, in _print
file.write(str+terminator)
IOError: [Errno 9] Bad file descriptor
This is the way I initialize logging:

def initLogger(filename):
log = logging.getLogger('test')
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')

# file
hdlr = logging.FileHandler(filename)
hdlr.setFormatter(formatter)
log.addHandler(hdlr)

# screen
hdlr = logging.StreamHandler(sys.stdout)
hdlr.setFormatter(formatter)
log.addHandler(hdlr)

log.setLevel(logging.DEBUG)

return log

log = initLogger('test.log')

I pass variable "log" to functions requesting it.
My script runs continually, sleeping 1h, doing something, sleeping 1h, etc.
Is it possible that file handler expires or something?

Do I do something wrong?

Thanks,
Marek Augustyn
Jul 18 '05 #1
0 1298

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sean Ross | last post by:
Here's a breakdown of most of the syntax discussed re: PEP318 using an example from python-dev. There are probably several more (I've added ). The example applies both function decoration and...
1
by: jjesso | last post by:
I am trying to add a new logging level. logging.config.fileConfig("bengineLog.cfg") logging.CLIENT = logging.INFO + 1 logging.addLevelName( logging.CLIENT, 'CLIENT' ) logging.root.setLevel( )...
0
by: Karuppasamy | last post by:
H I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net I installed everything as per the Instructions given in the 'Development Using the Logging Block' ...
6
by: pmatos | last post by:
Hi all, I am trying to create a simple but efficient C++ logging class. I know there are lots of them out there but I want something simple and efficient. The number one requirement is the...
0
by: BuddyWork | last post by:
Hello, I want to know if there any good tools out there which will show me a breakdown of the memory allocation in Gen 2 heap, basically a breakdown by object is what I'm looking for. The...
16
by: Atley | last post by:
I am trying to get a overall difference on two dates, I can get the difference in Years, Months, Weeks, Days, Hours, Minutes, Seconds, no problems... What I cannot seem to figure out is how to...
0
by: robert | last post by:
As more and more python packages are starting to use the bloomy (Java-ish) 'logging' module in a mood of responsibility and as I am not overly happy with the current "thickener" style of usage, I...
3
by: Daron | last post by:
Is it possible to use SQL to take a field, and break it down by denominations? I would like to take a field, and then break this out into the number of bills($100's, $50's, etc) I would need:...
1
by: Benny | last post by:
I might be overcomplicating the solution, but the problem is I have to make a breakdown of each week for many ranges of dates within a particular year. So for example one record might have a start...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.