您的位置:首页 > 编程语言 > Python开发

python logging使用

2016-06-06 15:06 337 查看
#coding:utf-8

import logging

def initLogging():

logpath=”%s/log/input_version.log” %(os.getcwd())

logging.basicConfig(filename=os.path.join(os.getcwd(),logpath),

filemode=’a’,

format=’%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s %(message)s’,

datefmt=’%Y-%m-%d %H:%M:%S’,

level = logging.DEBUG)

console=logging.StreamHandler()

console.setLevel(logging.DEBUG)

formatter=logging.Formatter(‘%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s %(message)s’)

console.setFormatter(formatter)

logging.getLogger(”).addHandler(console)

参考:http://blog.csdn.net/azhao_dn/article/details/7320186
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: