python日志记录模块AttributeError:'str'对象没有属性'写'
问题描述:
我使用龙卷风,在它的应用程序中,我导入日志记录只是想记录一些关于服务器的信息。 我把这个:python日志记录模块AttributeError:'str'对象没有属性'写'
logging.config.dictConfig(web_LOGGING)
权之前:
tornado.options.parse_command_line()
但是当我运行服务器,当我点击任何链接,我得到错误:
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 874, in emit
stream.write(fs % msg)
AttributeError: 'str' object has no attribute 'write'
Logged from file web.py, line 1946
它只是重复时我点击进入任何链接。 真正的问题是什么?
我已经改变了任何文件,目录他人避开命名冲突......
答
心理调试说web_LOGGING
有一个名为stream
与str
值(可能是文件路径)的关键; stream
is only for already opened files, if you want to pass a file path, it's passed as filename
。
'web_LOGGING'的定义是什么?我的回答是一个可能的问题,但你需要提供足够的信息来复制;当我们不知道配置通过时,知道你使用了'dictConfig'并不是特别有用。 – ShadowRanger
我把“流”的处理程序:“ext”#sys.stdout,我打算把任何信息sys.stdout.while警告,我想登录到一个文件,如'文件名':'./web_log/ rotate.log'..所以在这里流错了什么? – simonchou
'“stream”:“ext”'肯定是错误的,而'stream':sys.stdout'应该没问题。不清楚“stream”是什么意思:“ext”#sys.stdout – ShadowRanger