【问题标题】:Intermittent exception Could not initialize class org.apache.logging.log4j.LogManager when start docker container on AWS Fargate在 AWS Fargate 上启动 docker 容器时,间歇性异常无法初始化类 org.apache.logging.log4j.LogManager
【发布时间】:2019-04-10 09:10:05
【问题描述】:

运行 Fargate 任务时间歇性出现“无法初始化类 org.apache.logging.log4j.LogManager”异常。

春季启动应用程序 Java基础镜像

应用程序在 90% 的时间里运行完美,但时不时地对存储在 ECR 中的图像进行零更改,它会失败并显示

Instantiation of bean failed; nested exception is 
java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.logging.log4j.LogManager

我已在本地运行该应用程序,但从未出现此问题。

我如何创建记录器

 private static Logger LOGGER = LogManager.getLogger(CollectorController.class);

【问题讨论】:

    标签: java spring amazon-web-services docker log4j


    【解决方案1】:

    在您的主应用程序中

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
        @SpringBootApplication
        public class CollectorController {
            private static final Logger logger = LoggerFactory.getLogger(CollectorController.class);
    
            public static void main(String[] args) {
                SpringApplication.run(IslandgreenApplication.class, args);
            }
    
        }
    

    在你的 application.properties 文件中添加这个

    logging.file=C:/Users/A Majutharan/Documents/sun3/island_green/islandgreen/src/main/resources/\
      LogFiles/app.log(this is the storing path)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-10-27
      • 1970-01-01
      • 1970-01-01
      • 2019-12-15
      • 2018-09-18
      • 1970-01-01
      • 2021-12-30
      相关资源
      最近更新 更多