learning python logging module

19
江江江江江江 江江江江 西 1 Learning Python logging module @dotecho 2012/03/24

Upload: dotecho

Post on 28-Nov-2014

633 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

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

Learning Python logging module

@dotecho2012/03/24

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

What's Logging?

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

使用 Logging模块的好处

无需安装任何第三方库 (logging在标准库里面 ) 很方便的为应用程序或模块或包记录日志 日志信息分级 成熟,众多使用者,稳定 定制自己所需的 handler

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

Logging模块的设计

Loggers提供应用程序直接使用的接口 Handlers发送日志到适当的位置 Filters提供过滤日志输出 Formatters指定具体日志的最终显示

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

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

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

a simple example

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

log to a file

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

logging from multiple modules

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

logging variable data

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

Changing the format of displayed messages

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

Displaying the date/time in messages

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

Logging Handlers

Filehandler StreamHandler WatchFileHandler SocketHandler

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

Logging Config

Directly in code File conf Dictconf

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

多进程日志处理

单进程 server处理 WatchedFileHandler + cron job

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

Logging in Flask

http://flask.pocoo.org/docs/quickstart/#logging http://flask.pocoo.org/docs/errorhandling/ extend log handler to tpage.

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

Logging in Dajngo

https://docs.djangoproject.com/en/1.4/topics/logging/

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

tlogserver: A simple logging sockethandler Server

简单及方便 日志集中化管理

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

Q&A

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

END