Log.py
import logging
import logging.handlers
class Log:
def __init__(self):
FILENAME='LOG'
logging.basicConfig(level=logging.INFO)
root_logger = logging.getLogger('')
logger = logging.handlers.TimedRotatingFileHandler(FILENAME,'midnight',1)
root_logger.addHandler(logger)
logging.getLogger('log')
Main.py
from Log import Log
import time
import logging
log_obj = Log()
log = logging.getLogger('log')
log.info("Service Started")
while 1:
t=1
setup.py
from cx_Freeze import setup, Executable
setup(
name = "Test",
version = "0.1",
description = "Test",
executables = [Executable("Main.py", base="Win32GUI")])
所以这是我正在使用的最终代码。 EXE文件已创建但我在运行时遇到错误。错误是“Nonetype对象没有属性类型'write'”
等你回复。
答案 0 :(得分:1)
如果没有堆栈跟踪,我只能建议您尝试使用base =“Console”。