logging.conf:
---------------------------
# logging.conf
[loggers]
keys=root,test,test2
[handlers]
keys=consoleHandler,rotateFileHandler
[formatters]
keys=simpleFormatter
[formatter_simpleFormatter]
format=[%(asctime)s](%(levelname)s)%(name)s : %(message)s
[logger_root]
level=DEBUG
handlers=consoleHandler,rotateFileHandler
[logger_test]
level=DEBUG
handlers=consoleHandler,rotateFileHandler
qualname=test
propagate=0
[logger_test2]
level=DEBUG
handlers=consoleHandler,rotateFileHandler
qualname=test2
propagate=0
[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)
[handler_rotateFileHandler]
class=handlers.RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('test.log', 'a', 20000, 9)
----------------------------------------------
my_test:
----------------------------------------------
#python33
from tkinter import *
import logging
import logging.config
def Log(text):
logging.config.fileConfig("logging.conf")
logger = loggong.getLogger("test")
logger.info(text)
def Test():
Log("Test")
if __name__=="__main__":
root = Tk()
btn1 = Button(root, text='test', command=Test)
btn1.grid()
root.mainloop()
交互式爱情
相关分类