文件结构

- run.py

- b

-- __init__.py

run.py

 import logging

 import b

 log = logging.getLogger("")

 tmp = logging.FileHandler('log.txt')
log.addHandler(tmp) log.warning("") sample = b.b()
print sample.foo()

__init__.py

 import logging

 log = logging.getLogger("b")

 class b:
def __init__(self):
pass def foo(self):
log.warning(1111)
return "Foo in class b"

run.py 中的 addHandler 可以作用到 package b 下的文件,因为 getLogger("b) 也会 getLogger(""), 如果 run.py 中定义为 getLogger("a") 就获取不到了

Logger对象组织为一种层次结构 如 app.net.client 会有三个不同的 logger 对象 -- app || app.net || app.net.client

python log 层次结构的更多相关文章

  1. python log

    python的日志模块为logging,它可以将我们想要的信息输出保存到一个日志文件中. # cat log import logging logging.debug('This is debug m ...

  2. python log的处理方式

    python log的处理方式 配置文件 #! /usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "Q1mi" ...

  3. Python log 模块介绍

    刚用Python log模块写了一个例子,记录一下. import logging import logging.handlers import os from datetime import dat ...

  4. python log封装

    # _*_ coding:utf-8 _*_ import logging import os import sys import time log_path = os.path.dirname(sy ...

  5. Python log() 函数

    描述 log() 方法返回x的自然对数,x > 0. 语法 以下是 log() 方法的语法: import math math.log( x ) 注意:log()是不能直接访问的,需要导入 ma ...

  6. python - log日志

    # -*- coding:utf-8 -*- ''' @project: jiaxy @author: Jimmy @file: study_logging.py @ide: PyCharm Comm ...

  7. python log 设置

    # -*- coding: utf-8 -*- import loggingfrom logging.handlers import TimedRotatingFileHandler  # 按时间处理 ...

  8. python log装饰器

    def log(func): #将原函数对象的指定属性复制给包装函数对象, 默认有 module.name.doc,或者通过参数选择 @functools.wraps(func) def wrappe ...

  9. Python Log Viewer

    https://pythonhosted.org/logview/

随机推荐

  1. [001]const和指针

    很经典的: const int* p: int* const p: 前者表示指针指向的值是const,指向的值不可变,但是指针本身是可变的:后者表示改指针是const,指针不可变,但是指向的值是可变的 ...

  2. PAT 1005

    1005. Spell It Right (20) Given a non-negative integer N, your task is to compute the sum of all the ...

  3. Linux 服务器相关的一下链接

    Apache 虚拟主机 VirtualHost 配置 以下是各操作系统的配置方法. Redhat Enterprise Linux Ubuntu Linux Windows Mac OS http:/ ...

  4. linux之ubuntu下php环境配置

    本文主要说明如何在Ubuntu下配置PHP开发环境LAMP.   Ubuntu 搭建 php 环境   所谓LAMP:Linux,Apache,Mysql,PHP   安装 Apache2:(注意可以 ...

  5. Linux 学习笔记 基本的bash shell命令

    Linux 文件系统 Linux讲文件存储在单个目录结构(虚拟目录)中,虚拟目录包含了安装在PC上的所有存储设备的文件路径. Linux虚拟目录中比较复杂的部分是它如何来协调管理各个存储设备.Linu ...

  6. WinServer 之 发布WebService后调用出现" The test form is only available for requests from the local machine. "

    当您尝试从远程计算机访问 Web 服务时,不会显示“调用”按钮.并且,您会收到以下错误信息: The test form is only available for requests from the ...

  7. Java基础知识强化之IO流笔记68:Properties和IO流集合使用

    1. Properties和IO流集合使用 这里的集合必须是Properties集合:  public void load(Reader reader):把文件中的数据读取到集合中  public v ...

  8. iOS-label出现未知边框线的bug

    在前段时间碰到了一个问题  label上出现了一个位置的右边框  仔细查看代码发现没有指定边框 而且奇怪的是只显示右边框  其他边框没有显示 需求效果图: 实际效果图: 结构图: 通过查看结构图  可 ...

  9. ADO和ADO.NET有什么不同?

    1.一些ADO中常见的类型比如RecordSet在ADO.NET中已经没有了,而且在ADO.NET中也新增了许多在传统ADO中找不到的直接对应的新类型(如数据适配器): 2.传统的ADO主要针对紧密连 ...

  10. h2database源码浅析:事务、两阶段提交

    Transaction Isolation Transaction isolation is provided for all data manipulation language (DML) sta ...