zoukankan      html  css  js  c++  java
  • log日志模块

    import logging

    # 在logging.basciConfig中指定文件中写入
    logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    datefmt='%a, %d %b %Y %H:%M:%S',
    filename="E:\test_allchips\log\logs\test.log", # 注意xpath指定目录文件
    filemode='a')
    logging.debug("User %s is loging" % 'jeck')
    logging.info("User %s attempted wrong password" % 'fuzj')
    logging.warning("user %s attempted wrong password more than 3 times" % 'mary')
    logging.error("select db is timeout")
    logging.critical("server is down")

    # 打印到屏幕
    logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
    datefmt='%a, %d %b %Y %H:%M:%S')
    logging.debug("User %s is loging" % 'jeck')
    logging.info("User %s attempted wrong password" % 'fuzj')
    logging.warning("user %s attempted wrong password more than 3 times" % 'mary')
    logging.error("select db is timeout")
    logging.critical("server is down")

    logging的四大组件
    • Loggers 提供应用程序可直接使用的接口
    • Handlers 发送日志到适当的目的地
    • Filters 提供了过滤日志信息的方法
    • Formatters 指定日志显示格式
  • 相关阅读:
    dubbo学习总结二 服务端
    dubbo学习总结一 API
    mybatis中的#和$的区别
    Spring boot配置注意事项
    dubbo 学习
    框架发展过程
    使用OkHttp模拟登陆LeetCode
    Java设计模式——建造者模式(创建型模式)
    Java设计模式——单例模式(创建型模式)
    Java中static的用法
  • 原文地址:https://www.cnblogs.com/yancy03/p/10177868.html
Copyright © 2011-2022 走看看