我在AWS Elastic beantalk上部署了一个Web应用程序。简单地说,我有两个不同的python文件,它们将日志写入同一日志文件(“ implementation.log”)
scriptA.py
logger = logging.getLogger('LGB_Implementation')
logger.setLevel(logging.DEBUG)
logger_handler = logging.FileHandler('implementation.log')
logger_formatter = logging.Formatter('%(name)s- %(asctime)s - %(levelname)s - %(message)s')
logger_handler.setFormatter(logger_formatter)
logger.addHandler(logger_handler)
logger.info('Completed configuring logger() for back-end')
def A():
logger.info('Entered method A()', exc_info=1)
logger.info('Exiting method A()', exc_info=1)
def B():
logger.info('Entered method B()', exc_info=1)
logger.info('Exiting method B()', exc_info=1)
scriptB.py
logger = logging.getLogger('LGB_Implementation')
logger.setLevel(logging.DEBUG)
logger_handler = logging.FileHandler('implementation.log')
logger_formatter = logging.Formatter('%(name)s- %(asctime)s - %(levelname)s - %(message)s')
logger_handler.setFormatter(logger_formatter)
logger.addHandler(logger_handler)
logger.info('Completed configuring logger() for back-end')
def C():
logger.info('Entered method C()', exc_info=1)
logger.info('Exiting method C()', exc_info=1)
def D():
logger.info('Entered method D()', exc_info=1)
logger.info('Exiting method D()', exc_info=1)
在本地进行测试时,记录器将完全按照预期的方式运行-在访问方法A,B,C和D时,日志将写入“ implementation.log”。但是,在AWS EBS上运行时,“ implementation.log” “即使我们进入方法B,C和D,该文件也只有方法A的日志。有人知道为什么或如何解决此问题?
编辑:方法A是Web应用程序启动时访问的第一种方法。