V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
ray1888
V2EX  ›  Python

关于 logger 的问题

  •  
  •   ray1888 ·
    ray1888 · 2017-10-22 10:26:10 +08:00 · 2310 次点击
    这是一个创建于 2370 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现在自己在写一个项目,有一个主入口模块和其他的功能模块(每个模块为单独的一个 python 文件),请问一下,有什么方法能把日志打印到同一个文件输出呢?之前只试过对每个 py 文件单独打一个 log,没试过这么多模块来进行输出到一个日志里面,求解答

    4 条回复    2017-10-22 21:56:03 +08:00
    supersu
        2
    supersu  
       2017-10-22 12:57:36 +08:00 via Android
    初始化 logger 的时候日志文件名指定好呀,可以参考一下这个项目中的这个模块有用到 logging 库,所有的日志都写在同一个文件里面 https://github.com/supersu097/mycrawler/blob/master/core/helper.py
    dayinfinte
        3
    dayinfinte  
       2017-10-22 20:41:37 +08:00
    同样有个问题,就是怎么样将项目中的不同级别的日志打到不同的文件中
    ray1888
        4
    ray1888  
    OP
       2017-10-22 21:56:03 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3203 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:57 · PVG 21:57 · LAX 06:57 · JFK 09:57
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.