Re: Logging exceptions to a file

2009-05-07 Thread segfaulthunter
On May 7, 1:19 pm, Pierre GM wrote: > On May 7, 5:32 am, Lie Ryan wrote: > > > > > Pierre GM wrote: > > > All, > > > I need to log messages to both the console and a given file. I use the > > > following code (on Python 2.5) > > > import logging > > # > > logging.basicConfig(level=

Re: Logging exceptions to a file

2009-05-07 Thread Stephen Hansen
> > > > > So far so good, but I'd like to record (possibly unhandled) exceptions > > > in the logfile. > > > * Do I need to explicitly trap every single exception ? > > > * In that case, won't I get 2 log messages on the console (as > > > illustrated in the code below: > Check out sys.excepthook,

Re: Logging exceptions to a file

2009-05-07 Thread Pierre GM
On May 7, 5:32 am, Lie Ryan wrote: > Pierre GM wrote: > > All, > > I need to log messages to both the console and a given file. I use the > > following code (on Python 2.5) > > import logging > # > logging.basicConfig(level=logging.DEBUG,) > logfile = logging.FileHandler('log.l

Re: Logging exceptions to a file

2009-05-07 Thread Lie Ryan
Pierre GM wrote: All, I need to log messages to both the console and a given file. I use the following code (on Python 2.5) import logging # logging.basicConfig(level=logging.DEBUG,) logfile = logging.FileHandler('log.log') logfile.setLevel(level=logging.INFO) logging.getLogger('').addHandler(l

Re: Logging exceptions to a file

2009-05-06 Thread Lawrence D'Oliveiro
In message <597627b8- d30b-4b74-9202-9cd46fb1d...@s28g2000vbp.googlegroups.com>, Pierre GM wrote: > ... I'd like to record (possibly unhandled) exceptions in the logfile. python myscript.py 2>error.log -- http://mail.python.org/mailman/listinfo/python-list

Re: logging exceptions

2008-08-27 Thread Vinay Sajip
On Aug 27, 10:30 am, Rob Wolfe <[EMAIL PROTECTED]> wrote: > Vinay Sajip napisa³(a): > > > > > On Aug 26, 10:36 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > > > why doesn'tloggingthrow any exception when it should? how do I > > > configureloggingto throw exceptions? > > > > >>> try: > > > > ...

Re: logging exceptions

2008-08-27 Thread Rob Wolfe
Vinay Sajip napisał(a): > On Aug 26, 10:36 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > > why doesn'tloggingthrow any exception when it should? how do I > > configureloggingto throw exceptions? > > > > >>> try: > > > > ... logging.fatal('asdf %d', '123') > > ... except: > > ... print 'thi

Re: logging exceptions

2008-08-27 Thread Vinay Sajip
On Aug 26, 10:36 am, Alexandru Mosoi <[EMAIL PROTECTED]> wrote: > why doesn'tloggingthrow any exception when it should? how do I > configureloggingto throw exceptions? > > >>> try: > > ... logging.fatal('asdf %d', '123') > ... except: > ... print 'this line is never printed' > ... > Traceback (

Re: logging exceptions

2008-08-26 Thread Rob Wolfe
Alexandru Mosoi napisał(a): > why doesn't logging throw any exception when it should? how do I > configure logging to throw exceptions? > > >>> try: > ... logging.fatal('asdf %d', '123') > ... except: > ... print 'this line is never printed' > ... [...] You need to subclass your handler and