logging.basicConfig配置日志记录到文件A后,再使用logging.FileHandler生成记录到文件B的logger

在使用此logger记录日志时,会同时记录的文件A和文件B,感觉这个机制还是比较出乎意料的

# -*- coding: utf8 -*-
import logging logging.basicConfig(
level=logging.DEBUG,
format='[%(asctime)s][%(process)d:%(thread)d][%(levelname)s] %(message)s',
filename="main.log",
filemode='a+') _logger = logging.getLogger('aaa.log')
fh = logging.FileHandler('aaa.log')
fh.setLevel(logging.DEBUG)
formatter1 = logging.Formatter('[%(asctime)s][%(process)d:%(thread)d][%(levelname)s] %(message)s')
fh.setFormatter(formatter1)
_logger.addHandler(fh) _logger.debug('aaa')
_logger.debug('bbb')

[Python]logging模块使用basicConfig后记录日志重复问题的更多相关文章

  1. 读懂掌握 Python logging 模块源码 (附带一些 example)

    搜了一下自己的 Blog 一直缺乏一篇 Python logging 模块的深度使用的文章.其实这个模块非常常用,也有非常多的滥用.所以看看源码来详细记录一篇属于 logging 模块的文章. 整个 ...

  2. Python logging模块无法正常输出日志

    废话少说,先上代码 File:logger.conf [formatters] keys=default [formatter_default] format=%(asctime)s - %(name ...

  3. python logging模块可能会令人困惑的地方

    python logging模块主要是python提供的通用日志系统,使用的方法其实挺简单的,这块就不多介绍.下面主要会讲到在使用python logging模块的时候,涉及到多个python文件的调 ...

  4. python logging模块使用

    近来再弄一个小项目,已经到收尾阶段了.希望加入写log机制来增加程序出错后的判断分析.尝试使用了python logging模块. #-*- coding:utf-8 -*- import loggi ...

  5. (转)python logging模块

    python logging模块 原文:http://www.cnblogs.com/dahu-daqing/p/7040764.html 1 logging模块简介 logging模块是Python ...

  6. Python logging 模块学习

    logging example Level When it's used Numeric value DEBUG Detailed information, typically of interest ...

  7. python logging—模块

    python logging模块 python logging提供了标准的日志接口,python logging日志分为5个等级: debug(), info(), warning(), error( ...

  8. 0x03 Python logging模块之Formatter格式

    目录 logging模块之Formatter格式 Formater对象 日志输出格式化字符串 LogRecoder对象 时间格式化字符串 logging模块之Formatter格式 在记录日志是,日志 ...

  9. 0x01 Python logging模块

    目录 Python logging 模块 前言 logging模块提供的特性 logging模块的设计过程 logger的继承 logger在逻辑上的继承结构 logging.basicConfig( ...

随机推荐

  1. Eclipse WTP Tomcat hot deploy

    转自: http://ducquoc.wordpress.com/2010/11/06/eclipse-wtp-tomcat-hot-deploy/ One of the reasons why Ja ...

  2. dos2unix 命令

    最近在学习shell编程,可是在<Linux程序设计>指定的网站上下载了源码,使用的时候却一直出问题.提示:"bash: ./here1:/bin/sh^M:损坏的解释器: 没有 ...

  3. Android应用中MVP开发模式

    所谓MVP(Model-View-Presenter)模式.是将APP的结构分为三层: view - UI显示层 view 层主要负责: 提供UI交互 在presenter的控制下修改UI. 将业务事 ...

  4. final发布评语

    final发布评语: 1.约跑(nice!)发布者:组长李权以及组员刘芳芳和于淼,对于约跑APP,final发布主要完成对于用户提出的(1.对话字数多导致头像被挤掉2.返回时没有完全退出)问题修改成功 ...

  5. SpringMVC拦截器(资源和权限管理)

    1.DispatcherServlet SpringMVC具有统一的入口DispatcherServlet,所有的请求都通过DispatcherServlet.    DispatcherServle ...

  6. VPS/云主机 如何试用远程连接登录主机服务器_

    1.windows主机如何远程登录 点本地电脑开始>运行(或者按"window+R")>输入mstsc点确定 弹出远程连接的框输入IP连接,  如果是VPS,直接输入I ...

  7. Lamp(Ubuntu 12.04 LTS) 之 htaccess的使用

    环境说明:Ubuntu 12.04 LTS Lamp (以apt方式分别安装) 一.明确目标:要确保.htaccess文件起作用,只需要三个重要点: 1.开启apache rewrite模块: (1) ...

  8. 转: Redis基础总结

    转文:http://blog.csdn.net/basycia/article/details/52175429 1.redis是什么 2.redis的作者何许人也 3.谁在使用redis 4.学会安 ...

  9. continue用法

    之前,一直没搞懂continue的用法,现在知道其中一个了: continue语句用于终止本轮循环,返回循环头部,开始下一轮循环 var i = 0; while (i < 10){ i++; ...

  10. 坑备忘error: expected class-name before '{' token

    今日重构之前的代码,修改了命名空间,然后一处派生的子类定义处总是总是报error: expected class-name before '{' token,网上查了查原因,出现这种情况大致有两种情况 ...