SlideShare une entreprise Scribd logo
1  sur  19
Learning Python logging module


                             @dotecho
                            2012/03/24




        江西唐门计算机系统有限公司   1
What's Logging?




 江西唐门计算机系统有限公司    2
使用 Logging 模块的好处

    无需安装任何第三方库 (logging 在标准库里面 )

    很方便的为应用程序或模块或包记录日志

    日志信息分级

    成熟,众多使用者,稳定

    定制自己所需的 handler




             江西唐门计算机系统有限公司   3
Logging 模块的设计

    Loggers 提供应用程序直接使用的接口

    Handlers 发送日志到适当的位置

    Filters 提供过滤日志输出

    Formatters 指定具体日志的最终显示




             江西唐门计算机系统有限公司   4
Logging 基本使用

    a simple example

    log to a file

    logging from multiple modules

    logging variable data

    Changing the format of displayed messages

    Displaying the date/time in messages



                    江西唐门计算机系统有限公司    5
a simple example




  江西唐门计算机系统有限公司    6
log to a file




江西唐门计算机系统有限公司    7
logging from multiple modules




        江西唐门计算机系统有限公司   8
logging variable data




    江西唐门计算机系统有限公司   9
Changing the format of displayed
          messages




         江西唐门计算机系统有限公司   10
Displaying the date/time in
        messages




      江西唐门计算机系统有限公司   11
Logging Handlers

    Filehandler

    StreamHandler

    WatchFileHandler

    SocketHandler




                  江西唐门计算机系统有限公司   12
Logging Config

    Directly in code

    File conf

    Dictconf




                  江西唐门计算机系统有限公司   13
多进程日志处理

    单进程 server 处理

    WatchedFileHandler + cron job




                 江西唐门计算机系统有限公司      14
Logging in Flask

    http://flask.pocoo.org/docs/quickstart/#logging

    http://flask.pocoo.org/docs/errorhandling/

    extend log handler to tpage.




                  江西唐门计算机系统有限公司        15
Logging in Dajngo

    https://docs.djangoproject.com/en/1.4/topics/log
    ging/




                  江西唐门计算机系统有限公司        16
tlogserver: A simple logging
         sockethandler Server

    简单及方便

    日志集中化管理




            江西唐门计算机系统有限公司   17
Q&A


江西唐门计算机系统有限公司   18
END


江西唐门计算机系统有限公司   19

Contenu connexe

Similaire à Learning python logging module

Times Ten Training
Times Ten TrainingTimes Ten Training
Times Ten TrainingLi Chen
 
腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向topgeek
 
腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向areyouok
 
110329 luopeng-sysopt-openkavass
110329 luopeng-sysopt-openkavass110329 luopeng-sysopt-openkavass
110329 luopeng-sysopt-openkavassZoom Quiet
 
Refactoring
RefactoringRefactoring
Refactoringdreampuf
 
PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法
PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法
PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法Jen Yee Hong
 
腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向George Ang
 
基于Erlang的
基于Erlang的基于Erlang的
基于Erlang的hnoutman
 
通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本abdul_manashi
 
通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本abdul_manashi
 
Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统
Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统
Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统Dahui Feng
 
Operation Logic Manager
Operation Logic ManagerOperation Logic Manager
Operation Logic ManagerLee Seungki
 
Apollo web数据网关demo
Apollo web数据网关demoApollo web数据网关demo
Apollo web数据网关demowen66
 
Django敏捷开发 刘天斯
Django敏捷开发 刘天斯Django敏捷开发 刘天斯
Django敏捷开发 刘天斯liuts
 
twMVC#36讓 Exceptionless 存管你的 Log
twMVC#36讓 Exceptionless 存管你的 LogtwMVC#36讓 Exceptionless 存管你的 Log
twMVC#36讓 Exceptionless 存管你的 LogtwMVC
 
Odoo Development
Odoo DevelopmentOdoo Development
Odoo DevelopmentTsungWei Hu
 
Mobile app security
Mobile app securityMobile app security
Mobile app securitydrewz lin
 

Similaire à Learning python logging module (20)

Times Ten Training
Times Ten TrainingTimes Ten Training
Times Ten Training
 
腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向
 
腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向
 
110329 luopeng-sysopt-openkavass
110329 luopeng-sysopt-openkavass110329 luopeng-sysopt-openkavass
110329 luopeng-sysopt-openkavass
 
Refactoring
RefactoringRefactoring
Refactoring
 
PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法
PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法
PIME - 用 Python 和 JavaScript 快速開發 Windows 的中文輸入法
 
腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向腾讯大讲堂19 系统优化的方向
腾讯大讲堂19 系统优化的方向
 
基于Erlang的
基于Erlang的基于Erlang的
基于Erlang的
 
通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本
 
通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本通用即时到帐接口集成教程 Php版本
通用即时到帐接口集成教程 Php版本
 
Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统
Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统
Yupoo! (花瓣网/又拍云) 架构中的消息与任务系统
 
Operation Logic Manager
Operation Logic ManagerOperation Logic Manager
Operation Logic Manager
 
Mocha Bsm
Mocha BsmMocha Bsm
Mocha Bsm
 
Apollo web数据网关demo
Apollo web数据网关demoApollo web数据网关demo
Apollo web数据网关demo
 
Django敏捷开发 刘天斯
Django敏捷开发 刘天斯Django敏捷开发 刘天斯
Django敏捷开发 刘天斯
 
twMVC#36讓 Exceptionless 存管你的 Log
twMVC#36讓 Exceptionless 存管你的 LogtwMVC#36讓 Exceptionless 存管你的 Log
twMVC#36讓 Exceptionless 存管你的 Log
 
Go
GoGo
Go
 
Odoo Development
Odoo DevelopmentOdoo Development
Odoo Development
 
Hadoop ecosystem
Hadoop ecosystemHadoop ecosystem
Hadoop ecosystem
 
Mobile app security
Mobile app securityMobile app security
Mobile app security
 

Learning python logging module