473,382 Members | 1,692 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,382 software developers and data experts.

RE: Unusual Exception Behaviour

Hi Mk,
To tell the truth I have never used logging module extensively, so I'm
not expert in this area and can't help you there.

However, it seems to me that you may have stumbled upon some subtle bug
/ side effect of logging module that could cause some side effects in
exceptions. Or perhaps it surfaces only in combination with glib?

If you discover the root cause, please let us know on this ng, I'm also
using Python extensions and bindings to other libraries and this could
be of interest at least to me.
Yeah it's got me a little bemused to be honest, I've tried playing around
with configuration options this morning and not been able to achieve
anything that works properly.

I'll keep testing though and as soon as I have a root cause to the problem
I'll be sure to let the list know.

Thanks mate,

Robert

Jul 18 '08 #1
3 1990
On Jul 18, 12:03 pm, "Robert Rawlins"
<robert.rawl...@thinkbluemedia.co.ukwrote:
>
Yeah it's got me a little bemused to be honest, I've tried playing around
with configuration options this morning and not been able to achieve
anything that works properly.
The logging configuration functionality provided by fileConfig is all-
or-nothing, i.e. it does not support incremental configuration.

Do you know if any libraries you depend on use fileConfig?

If you use programmatic configuration only, and don't use fileConfig
at all, does everything work as expected?

Regards,

Vinay Sajip
Jul 18 '08 #2
The logging configuration functionality provided by fileConfig is all-
or-nothing, i.e. it does not support incremental configuration.

Do you know if any libraries you depend on use fileConfig?

If you use programmatic configuration only, and don't use fileConfig
at all, does everything work as expected?
Vinay,

I changed this over to programmatic configuration this afternoon and it
works just great, all the logging I require, and my exceptions get thrown.
:-D

I have no idea if any of the librarys I use work from a file config, I'm
certainly not aware of them doing so.

This is really quite frustrating as I'd much rather use a conf file than
work this programmatically. I get the feeling that it's because in the
config file I was not attaching any handlers to the root logger, but I don't
know.

Robert

Jul 18 '08 #3
On Jul 18, 5:12 pm, "Robert Rawlins"
<robert.rawl...@thinkbluemedia.co.ukwrote:
>
This is really quite frustrating as I'd much rather use a conf file than
work this programmatically. I get the feeling that it's because in the
config file I was not attaching any handlers to the root logger, but I don't
know.
There's no reason why not having a handler for the root logger would
cause any particular problem. For example, the following script:

#- start of logconftest.py ------------------
import logging, logging.config

logging.config.fileConfig("log.conf")

app_logger = logging.getLogger("application")
sa_logger = logging.getLogger("sqlalchemy")

loggers = [app_logger, sa_logger]

def func1():
raise Exception("Exception from func1")

def func2():
raise TypeError("TypeError from func2")

def func3():
raise ValueError("ValueError from func3")

funcs = [func1, func2, func3]

for x in range(10):
try:
f = funcs[x % 3]
f()
except Exception, e:
loggers[x % 2].exception("%d. Problem in %s", x, f.__name__)
#- end of logconftest.py --------------------

together with the following configuration file (almost the same as
yours):

;-- start of log.conf -----------------------
[loggers]
keys=root,application,sqlalchemy

[handlers]
keys=hand01,hand03

[formatters]
keys=form01

[logger_root]
level=DEBUG
handlers=

[logger_application]
level=DEBUG
handlers=hand01
qualname=application

[logger_sqlalchemy]
level=DEBUG
handlers=hand03
qualname=sqlalchemy

[handler_hand01]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=form01
args=('application.log', 'a', 800000, 5)

[handler_hand03]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=form01
args=('sqlalchemy.log', 'a', 800000, 5)

[formatter_form01]
format=%(asctime)s %(filename)s %(lineno)d %(levelname)-8s %(message)s
datefmt=
class=logging.Formatter
;-- end of log.conf -------------------------

gives the following output:

-- start of application.log -----------------
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 0. Problem in func1
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 11, in func1
raise Exception("Exception from func1")
Exception: Exception from func1
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 2. Problem in func3
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 17, in func3
raise ValueError("ValueError from func3")
ValueError: ValueError from func3
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 4. Problem in func2
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 14, in func2
raise TypeError("TypeError from func2")
TypeError: TypeError from func2
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 6. Problem in func1
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 11, in func1
raise Exception("Exception from func1")
Exception: Exception from func1
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 8. Problem in func3
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 17, in func3
raise ValueError("ValueError from func3")
ValueError: ValueError from func3
-- end of application.log -------------------

-- start of sqlalchemy.log ------------------
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 1. Problem in func2
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 14, in func2
raise TypeError("TypeError from func2")
TypeError: TypeError from func2
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 3. Problem in func1
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 11, in func1
raise Exception("Exception from func1")
Exception: Exception from func1
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 5. Problem in func3
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 17, in func3
raise ValueError("ValueError from func3")
ValueError: ValueError from func3
2008-07-20 14:47:05,608 logconftest.py 26 ERROR 7. Problem in func2
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 14, in func2
raise TypeError("TypeError from func2")
TypeError: TypeError from func2
2008-07-20 14:47:05,625 logconftest.py 26 ERROR 9. Problem in func1
Traceback (most recent call last):
File "C:\Temp\logconftest.py", line 24, in <module>
f()
File "C:\Temp\logconftest.py", line 11, in func1
raise Exception("Exception from func1")
Exception: Exception from func1
-- end of sqlalchemy.log --------------------
which is, from a quick scan, the expected result - all the expected
exceptions are thrown. Note the absence of any handlers on the root
logger.

Regards,

Vinay Sajip
Jul 20 '08 #4

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

Similar topics

11
by: Karlo Basic | last post by:
Greetings! I'm wondering how do the expressions in the following piece of code evaluate and why: #include <iostream> using namespace std; int main() { int n = 5, p;
5
by: juergen perlinger | last post by:
Hello out there. sometimes I need to have proper control of the floating point arithmetic of the C(and C++) runtime system, and using the f.p. exception handling of the C99 standard is quite...
3
by: Farooq Khan | last post by:
why does Response.Write in a method of code-beind class when called from inpage code (i.e in <%---%>), after creating object of that class, fails when called while it works perfectly ok while...
14
by: Rowland Shaw | last post by:
I've got a databound combo (databound to a System.Data.DataTable), but some rather unpredicatable behaviour -- even though I have 8 rows in the source table, only the first 6 are showing up in the...
7
by: Rithish | last post by:
Hello. I noticed a strange thing while using strtotime() and date() functions in combination to generate from MySQL into a readable format. By default, the MySQL date field will be 0000-00-00...
132
by: Zorro | last post by:
The simplicity of stack unraveling of C++ is not without defective consequences. The following article points to C++ examples showing the defects. An engineer aware of defects can avoid...
7
by: brett.estabrook | last post by:
I have written a multi-threaded c# windows service in .net 1.1 (Visual Studio .net 2003). The service has several threads that poll a Sql 6.5 database on another machine. Each thread will execute a...
9
by: mos | last post by:
Hi! When call a null function pointer will cause a execption, but it can't be caught as std::exception, then which exception it is? The following code is a example: typedef void (*testfunc)(int...
0
by: mk | last post by:
http://linux.byexamples.com/archives/365/python-convey-the-exception-traceba That's seriously weird. What's your Python version and platform? On my Windows and Linux machines, with more recent...
0
by: Robert Rawlins | last post by:
That's seriously weird. What's your Python version and platform? On my Thanks for that MK. I'm using Debian with Python 2.5 from the stable apt repository, installed but a couple of days ago....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.