记录模块:某些映射键有问题 [英] Logging module: problem with some mapping keys
问题描述
我从路径名中得到了一个奇怪的行为。和lineno
格式化程序映射键。而不是我的文件和我的行号我得到:
/usr/lib/python2.4/logging/__init__.py
as文件,1072作为行号。我设置我的配置为
如下:
logBaseConf = {
''level'':logging.DEBUG,
''格式'':"%(levelname)-8s |%(asctime)s |%(路径名)s,
%(名称)s,行% (lineno)s |%(message)s",
''datefmt'':''%d%b%Y,%H:%M:%S'',
''filename'':''logtest.log'',
''filemode'':''''
}
logging.basicConfig(** logBaseConf)
我没有使用任何可执行生成工具,如cx_Freeze或
Psyco。事实上,我在一个非常基本的脚本上得到了这个错误,其中包含测试日志模块功能的特定目的。
提前感谢任何贡献。
T.
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.
T.
推荐答案
我已经检查了文档,发现logging.basicConfig需要
没有参数(可能我们有不同版本的日志包),
和我已经从来没用过它。
试试这个:
fileName =''testlog.log''
logName =''LOG ''
iHandler = logging.FileHandler(fileName)
iHandler.setFormatter(
logging.Formatter("%(levelname)-8s |%(asctime)s |%(路径名)s,%(名称)s,
行%(lineno)s |%(消息)s"))
iLog = logging.getLogger(logName)
iLog.addHandler(iHandler)
iLog.setLevel(logging.DEBUG)
iLog.info(''你好l og'')
它给了我:
INFO | 2006-12-13 19:57:33,575 | test.py,LOG ,第12行|你好记录
12月13日,19:02,Tekkaman < simone .... @ gmail.comwrote:
Hi, i''ve check documentation, and found that logging.basicConfig takes
no arguments (probably we have different versions of logging package),
and i''ve never used it.
just try this:
fileName = ''testlog.log''
logName = ''LOG''
iHandler = logging.FileHandler(fileName)
iHandler.setFormatter(
logging.Formatter("%(levelname)-8s|%(asctime)s|%(pathname)s,%(name)s,
line %(lineno)s|%(message)s") )
iLog = logging.getLogger(logName)
iLog.addHandler(iHandler)
iLog.setLevel(logging.DEBUG)
iLog.info(''hello logging'')
it gives me:
INFO |2006-12-13 19:57:33,575|test.py,LOG, line 12|hello logging
On 13 Dec., 19:02, "Tekkaman" <simone....@gmail.comwrote:
我从路径名中得到一个奇怪的行为。和lineno
格式化程序映射键。而不是我的文件和我的行号我得到:
/usr/lib/python2.4/logging/__init__.py
as文件,1072作为行号。我设置我的配置为
如下:
logBaseConf = {
''level'':logging.DEBUG,
''格式'':"%(levelname)-8s |%(asctime)s |%(路径名)s,
%(名称)s,行% (lineno)s |%(message)s",
''datefmt'':''%d%b%Y,%H:%M:%S'',
''filename'':''logtest.log'',
''filemode'':''''
}
logging.basicConfig(** logBaseConf)
我没有使用任何可执行生成工具,如cx_Freeze或
Psyco。事实上,我在一个非常基本的脚本上得到了这个错误,其中包含测试日志模块功能的特定目的。
提前感谢任何贡献。
T.
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.
T.
-
Maksim Kasimov
--
Maksim Kasimov
Tekkaman写道:
Tekkaman wrote:
我从路径名中得到一个奇怪的行为。和lineno
格式化程序映射键。而不是我的文件和我的行号我得到:
/usr/lib/python2.4/logging/__init__.py
as文件,1072作为行号。我设置我的配置为
如下:
logBaseConf = {
''level'':logging.DEBUG,
''格式'':"%(levelname)-8s |%(asctime)s |%(路径名)s,
%(名称)s,行% (lineno)s |%(message)s",
''datefmt'':''%d%b%Y,%H:%M:%S'',
''filename'':''logtest.log'',
''filemode'':''''
}
logging.basicConfig(** logBaseConf)
我没有使用任何可执行生成工具,如cx_Freeze或
Psyco。事实上,我在一个非常基本的脚本上得到了这个错误,其中包含测试日志模块功能的特定目的。
提前感谢任何贡献。
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
ln -s /usr/local/lib/python2.4/logging
这篇关于记录模块:某些映射键有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!