# -*- coding: utf-8 -*-
import logging
import sys
import os
import xlrd

from UtilAzxu import Properties

# 获取logger实例,如果参数为空则返回root logger
log = logging.getLogger("AppName")

# 指定logger输出格式
formatter = logging.Formatter('%(asctime)s %(levelname)-8s: %(message)s')

# 文件日志
file_handler = logging.FileHandler("test.log")
file_handler.setFormatter(formatter) # 可以通过setFormatter指定输出格式

# 控制台日志
console_handler = logging.StreamHandler(sys.stdout)
console_handler.formatter = formatter # 也可以直接给formatter赋值

# 为logger添加的日志处理器
log.addHandler(file_handler)
log.addHandler(console_handler)

# 指定日志的最低输出级别,默认为WARN级别
log.setLevel(logging.DEBUG)

python logs的更多相关文章

  1. Appnium-API-Session

    Session Create New Session Java: DesiredCapabilities desiredCapabilities = new DesiredCapabilities() ...

  2. 神经网络一(用tensorflow搭建简单的神经网络并可视化)

    import tensorflow as tf import numpy as np import matplotlib.pyplot as plt #创建一个input数据,-1到1之间300个数, ...

  3. Beats: 使用 Filebeat 进行日志结构化

    文章转载自:https://blog.csdn.net/UbuntuTouch/article/details/106688240 生产一个叫做 json_logs 的文件: {"user_ ...

  4. 使用 Elastic Agents 把定制的日志摄入到 Elasticsearch 中

    转载自:https://mp.weixin.qq.com/s/QQxwYh1uLCkKn1LK72ojJA 在以前的系统中,我们可以使用如下的几种方式来采集日志: 1.我们可以直接使用 Beats 把 ...

  5. --- no python application found, check your startup logs for errors

    --- no python application found, check your startup logs for errors 碰到这个问题,请留意下系统执行的python版本和自己的djan ...

  6. centos 7.3 安装 mysqldb 报错 EnvironmentError: mysql_config not found ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

    ERROR: Command errored : command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] ...

  7. python 删除/app/*/logs/*/*.logs指定多少天的文件

    # encoding: utf-8 import sys import getopt import os import glob import time import datetime def rem ...

  8. [bigdata] 使用Redis队列来实现与机器无关的Job提交与执行 (python实现)

    用例场景: 定时从远程多台机器上下载文件存入HDFS中.一开始采用shell 一对一的方式实现,但对于由于网络或者其他原因造成下载失败的任务无法进行重试,且如果某台agent机器down机,将导致它对 ...

  9. Python检测服务端口存活状态并报警

    最近发现公司的测试环境中有个Socket服务的端口总是莫名其妙Down掉,但是服务却正常运行着,看样子是僵死了... 虽然是测试环境,但是也不能这样放着不管,于是连夜写了一个简单的监控脚本.因为服务器 ...

随机推荐

  1. 由设置body线性背景色引发的问题-----当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡

    问题:当声明文档类型时,对body设置线性背景色,页面背景色无法整体线性过渡 不声明文档类型时,对body设置线性背景色 <HTML> <head> <meta char ...

  2. Java java.lang.SecurityException: Prohibited package name

    java.lang.SecurityException: Prohibited package name 提示java错误: Exception in thread "main" ...

  3. Vs自定nuget push菜单

    1.需要准备 nuget.exe 和 nuget-push.cmd 命名行 nuget.ext 下载地址:https://files.cnblogs.com/files/liuxiaoji/nuget ...

  4. [转][linux]简单的linux下的tcp/udp

    转自:https://blog.csdn.net/cabing2005/article/details/53068880 详细函数以及参数解释请看原链接. windows下的tcp/udp参考:htt ...

  5. openmodelica警告及错误

    Warning: The initial conditions are not fully specified. simulate(TCS.TCS,startTime=0,stopTime=200.0 ...

  6. 《剑指offer》第五十五题(二叉树的深度)

    // 面试题55(一):二叉树的深度 // 题目:输入一棵二叉树的根结点,求该树的深度.从根结点到叶结点依次经过的 // 结点(含根.叶结点)形成树的一条路径,最长路径的长度为树的深度. //如果左右 ...

  7. x1c 2018 莫名卡顿

    win10不知更新了什么,x1c非常卡一跳一跳的,很多年没见过了-_-!! CPU占用低,但是特别之卡…… (也许是Lenovo的更新,反正是在window update里一起的 —————————— ...

  8. Lab 1-4

    Analyze the file Lab01-04.exe. Questions and Short Answers Upload the Lab01-04.exe file to http://ww ...

  9. LeetCode--242--有效的字母异位词

    问题描述: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s = "anagram", t = "nagara ...

  10. linux进程管理之信号控制

    使用信号控制进程 ====================================================================================kill,ki ...