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
eailfly
V2EX  ›  Python

logging 的写盘机制是怎样的?按时间还是按大小?

  •  
  •   eailfly · 2015-02-09 17:21:04 +08:00 · 2845 次点击
    这是一个创建于 3363 天前的主题,其中的信息可能已经有所发展或是发生改变。
    因为刚开始用logging,发现经常得停止项目才能把日志写如文件,不知道怎样才能即时写磁盘呢?
    下面是logging的配置:
    5 条回复    2015-02-10 06:58:07 +08:00
    Zuckonit
        1
    Zuckonit  
       2015-02-09 17:40:13 +08:00
    时间, 或者大小都可以自己加handler
    大小是RotatingFileHandler,
    时间的自己查下吧
    sujin190
        2
    sujin190  
       2015-02-09 18:03:19 +08:00
    每次写完了就flush了,没有缓存
    wangtai
        3
    wangtai  
       2015-02-09 19:38:58 +08:00
    这是buffer大小的问题吧,和handler无关。
    每次项目停掉才会写磁盘?完全不合理啊,我认为一般不可能出现。这是很严重的bug。
    ryd994
        4
    ryd994  
       2015-02-10 02:30:14 +08:00
    应该就是即时写或者line buffer而已
    但是文件系统有缓存,所以如果系统崩溃的话可能存不下来
    eailfly
        5
    eailfly  
    OP
       2015-02-10 06:58:07 +08:00 via Android
    只要是实时就行,可能是buffer的原因,因为会过一段时间写盘,只是我程序跑得时间短,所以老是感觉结束程序才会写盘。
    谢谢各位。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5416 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 07:29 · PVG 15:29 · LAX 00:29 · JFK 03:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.