[Tutor] IOError: (0, 'Error')

Kent Johnson kent37 at tds.net
Tue Jan 3 03:54:18 CET 2006


Bernard Lebel wrote:
> I'm checking out the logging module atm. I'm trying the second example
> in "Basic example":
> 
> import logging
> 
> logging.basicConfig(level=logging.DEBUG,
>                     format='%(asctime)s %(levelname)s %(message)s',
>                     filename='C:\\pylogger.log',
>                     filemode='w')
> logging.debug('A debug message')
> logging.info('Some information')
> logging.warning('A shot across the bows')
> 
> 
> However when I run that I don't get any log file, while the doc page
> says I should have a log file. Only the warning is printed, as if I
> had not run the basicConfig method. Any suggestion?

If I copy and paste your code and run it, it works as expected creating 
C:\pylogger.log containing

2006-01-02 21:49:21,071 DEBUG A debug message
2006-01-02 21:49:21,071 INFO Some information
2006-01-02 21:49:21,071 WARNING A shot across the bows

This is with Python 2.4.2 on Win2K. What version of Python are you 
using? In versions previous to 2.4, basicConfig() doesn't take keyword 
args. For the Python 2.3 docs see
http://www.python.org/doc/2.3.5/lib/module-logging.html

and the example here:
http://www.python.org/doc/2.3.5/lib/node304.html

Kent



More information about the Tutor mailing list