python logging 问题
发布网友
发布时间:2022-04-07 11:26
我来回答
共1个回答
热心网友
时间:2022-04-07 12:56
请参考我下面的代码以及对应的 log,看上去没有问题,我怀疑是 log config 的问题
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(filename)s[line:%(lineno)d] %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='log.log',
filemode='w')
class A:
def __init__(self):
logging.info('A')
__c = C()
__d = D()
class B:
def __init__(self):
logging.info('B')
class C:
def __init__(self):
logging.info('C')
__e = E()
__f = F()
class D:
def __init__(self):
logging.info('D')
class E:
def __init__(self):
logging.info('E')
class F:
def __init__(self):
logging.info('F')
if __name__ == '__main__':
a = A()
b = B()