python日志库的模块化方法
python日志库的模块化方法
1、模块化方法
日志库采用模块化方法,并提供几类组件:记录器(loggers),处理器(handlers),过滤器(filters)和格式化器(formatters)。
记录器发布APP代码直接使用的界面。
处理器将日志(由记录器创建)发送到适当的目标。
过滤器提供了更细致的设施,以确定需要输出的日志记录。
格式化器指定最终输出中的日志记录布局。
2、日志事件实例
日志事件信息在LogRecord实例中的记录器,处理器,过滤器和格式化器之间传递。
通过在Logger类的实例(以下称为记录器)上调用方法来执行日志记录。每个实例都有一个名称,它们在概念上以点(句点)作为分隔符排列在命名空间层次结构中。例如,名为“scan”的记录器是记录器'scan.text','scan.html'和'scan.pdf'的父级。记录器名称可以是您想要的任何名称,并指明记录消息来源的应用程序区域。
当命名记录程序时,一个好习惯是,在使用记录程序的每个模块中使用模块级记录程序,其名称如下:
logger=logging.getLogger(__name__)
以上就是python日志库的模块化的方法,希望能对大家有所帮助,更多Python学习教程请关注IT培训机构:千锋教育。

猜你喜欢LIKE
相关推荐HOT
更多>>
python中yagmail库有何用法?
python中yagmail库有何用法?本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。yagmail库一直被称作是最有良心的库,主要的原因还是因...详情>>
2023-11-14 05:52:35
python中操作文件的模块有几种?
python中操作文件的模块有几种?本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。Python对文件操作采用的统一步骤是:打开—操作—关...详情>>
2023-11-14 03:37:12
python time.asctime()的字符串返回
pythontime.asctime()的字符串返回在我们学习了一些time函数后,对于它们各自的用法有一定的了解,就可以配合其他函数同时作用。就拿time.ascti...详情>>
2023-11-14 02:27:35
pandas中如何使用合并append函数?
pandas中如何使用合并append函数?介绍了这么多关于pandas拼接的方法,那你知道如果想要拼接拼接一个或者多个,还可以追加serise到原来的datafra...详情>>
2023-11-14 01:29:58热门推荐
如何自定义Python库创建和使用?
沸python中strip()和split()如何作用于字符串?
热如何使用python中的input()函数?
热python oracle数据库如何安装?
新python pexpect模块是什么?
如何使用python实现图片处理?
python中yagmail库有何用法?
python中Mako库怎么用?
python中series如何转为list?
python中如何编写函数并调用?
pandas拼接字符串的cat()方法如何使用?
python中操作文件的模块有几种?
datime包在python中计算时间差
python time.asctime()的字符串返回
技术干货






