Logging module: problem with some mapping keys

Peter Otten __peter__ at web.de
Wed Dec 13 13:13:38 EST 2006


Tekkaman wrote:

> I'm getting a strange behaviour from the "pathname" and "lineno"
> formatter mapping keys. Instead of my file and my line number I get:
> 
> /usr/lib/python2.4/logging/__init__.py
> 
> as the file, and 1072 as the line number. I set up my config as
> follows:
> 
> logBaseConf = {
>         'level'   : logging.DEBUG,
>         'format'  : "%(levelname)-8s|%(asctime)s|%(pathname)s,
> %(name)s, line %(lineno)s|%(message)s",
>         'datefmt ': '%d %b %Y, %H:%M:%S',
>         'filename': 'logtest.log',
>         'filemode': 'a'
>         }
> logging.basicConfig(**logBaseConf)
> 
> I'm not using any executable-generating tools such as cx_Freeze or
> Psyco. In fact, I'm getting this error on a very basic script with the
> specific purpose of testing the logging module capabilities.
> 
> Thanks in advance for any contribution.

An evil symlink, maybe?

$ ln -s /usr/local/lib/python2.4/logging
$ python
[snip]
>>> import logging
>>> logging.basicConfig(format="%(pathname)s")
>>> logging.getLogger().critical("yadda")
/usr/local/lib/python2.4/logging/__init__.py
>>>
$ rm logging
$ python
[snip]
>>> import logging
>>> logging.basicConfig(format="%(pathname)s")
>>> logging.getLogger().critical("yadda")
<stdin>

Peter




More information about the Python-list mailing list