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

logging 输出日志怎样对文件过滤

  •  
  •   kayanoa1 · 2022-11-07 11:24:42 +08:00 · 1877 次点击
    这是一个创建于 561 天前的主题,其中的信息可能已经有所发展或是发生改变。

    举例:有两个文件 a.pyb.py a 会调用 b 中的方法并输出很冗长的日志。 需求:对日志输出的文件名进行过滤,如果文件名为 b ,则不输出日志。 希望得到大佬的指教

    3 条回复    2022-11-07 14:47:10 +08:00
    maybedk
        1
    maybedk  
       2022-11-07 11:49:06 +08:00
    在 python 中如何只记录目标文件输出的日志_芳樽里的歌的博客-CSDN 博客
    https://blog.csdn.net/SunJW_2017/article/details/120241354
    kayanoa1
        2
    kayanoa1  
    OP
       2022-11-07 12:51:31 +08:00
    @maybedk 好的。感谢。这个 bolg 我也有搜到过。找到项目中所有的 py 文件感觉应该会增加脚本耗时。我两个对比一下。
    julyclyde
        3
    julyclyde  
       2022-11-07 14:47:10 +08:00
    @kayanoa1 不需要改所有的吧
    从程序入口开始改一下就是可以的吧?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5395 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 02:09 · PVG 10:09 · LAX 19:09 · JFK 22:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.