Java springboot&x2B;尤里卡+;log4j2空日志文件
我按照这里的教程创建了一个基本的Eureka注册表jar应用程序。下一步是将日志记录更改为log4j2,这样我就可以使用这里的指南获得一个滚动文件 我遇到的问题是,当我运行应用程序时,没有抛出错误,但是Java springboot&x2B;尤里卡+;log4j2空日志文件,java,spring,maven,log4j2,netflix-eureka,Java,Spring,Maven,Log4j2,Netflix Eureka,我按照这里的教程创建了一个基本的Eureka注册表jar应用程序。下一步是将日志记录更改为log4j2,这样我就可以使用这里的指南获得一个滚动文件 我遇到的问题是,当我运行应用程序时,没有抛出错误,但是 eureka服务器日志仍会输出到控制台 已创建自定义日志输出文件“eureka.log”,但该文件为空 我编写的任何自定义日志,例如logger.info(“启动Eureka注册表服务器…”)不会显示在任何位置,不会显示在日志文件或控制台日志中。它们只是在记忆中的某个地方被吞没了 因此,spri
logger.info(“启动Eureka注册表服务器…”)代码>不会显示在任何位置,不会显示在日志文件或控制台日志中。它们只是在记忆中的某个地方被吞没了
@EnableEurekaServer
@SpringBootApplication
public class Main {
public static void main(String[] args) {
Logger logger = LogManager.getLogger(Main.class.getSimpleName());
logger.info("Starting Eureka Registry server..."); //Log message disappears
logger.info("Starting Eureka Registry server..."); //Log message disappears
logger.info("Starting Eureka Registry server..."); //Log message disappears
logger.info("Starting Eureka Registry server..."); //Log message disappears
SpringApplication.run(Main.class, args);
}
}
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
最后,我得到一个空的eureka.log文件,控制台日志输出如下所示
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)
2017-06-18 16:25:48.349 INFO 2601 --- [ main] c.g.c.s.Main : No active profile set, falling back to default profiles: default
2017-06-18 16:25:48.362 INFO 2601 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2783717b: startup date [Sun Jun 18 16:25:48 EDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5a56cdac
2017-06-18 16:25:48.812 WARN 2601 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2017-06-18 16:25:48.953 INFO 2601 --- [ main] o.s.c.c.s.GenericScope : BeanFactory id=7bcf4003-cc89-31c0-9a0e-e63326839222
2017-06-18 16:25:48.966 INFO 2601 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-06-18 16:25:49.039 INFO 2601 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$25365eb7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-06-18 16:25:49.197 INFO 2601 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8761 (http)
.
.
.
2017-06-18 16:25:51.733 INFO 2601 --- [ Thread-11] o.s.c.n.e.s.EurekaServerBootstrap : isAws returned false
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] o.s.c.n.e.s.EurekaServerBootstrap : Initialized server context
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2017-06-18 16:25:51.739 INFO 2601 --- [ Thread-11] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2017-06-18 16:25:51.792 INFO 2601 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8761 (http)
2017-06-18 16:25:51.793 INFO 2601 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8761
2017-06-18 16:25:51.795 INFO 2601 --- [ main] c.g.c.s.Main : Started Main in 4.286 seconds (JVM running for 4.924)
2017-06-18 16:25:56.788 INFO 2601 --- [ Thread-13] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2783717b: startup date [Sun Jun 18 16:25:48 EDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5a56cdac
2017-06-18 16:25:56.790 INFO 2601 --- [ Thread-13] c.n.e.EurekaDiscoveryClientConfiguration : Unregistering application CiveMicroserviceRegistry with eureka with status DOWN
2017-06-18 16:25:56.791 INFO 2601 --- [ Thread-13] c.n.d.DiscoveryClient : Shutting down DiscoveryClient ...
2017-06-18 16:25:56.791 INFO 2601 --- [ Thread-13] c.n.d.DiscoveryClient : Completed shut down of DiscoveryClient
我怀疑我可能遗漏了什么,我一直在寻找其他解决方案,但在两天没有运气之后,我想最好还是寻求帮助。欢迎提供任何建议或提示。在
应用程序.properties
中,您可以指定:
- 日志记录路径
- 日志文件
- 日志记录.level
应用程序.properties
中,您可以指定:
- 日志记录路径
- 日志文件
- 日志记录.level
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.2.RELEASE)
2017-06-18 16:25:48.349 INFO 2601 --- [ main] c.g.c.s.Main : No active profile set, falling back to default profiles: default
2017-06-18 16:25:48.362 INFO 2601 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2783717b: startup date [Sun Jun 18 16:25:48 EDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5a56cdac
2017-06-18 16:25:48.812 WARN 2601 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance @Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2017-06-18 16:25:48.953 INFO 2601 --- [ main] o.s.c.c.s.GenericScope : BeanFactory id=7bcf4003-cc89-31c0-9a0e-e63326839222
2017-06-18 16:25:48.966 INFO 2601 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-06-18 16:25:49.039 INFO 2601 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$25365eb7] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-06-18 16:25:49.197 INFO 2601 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8761 (http)
.
.
.
2017-06-18 16:25:51.733 INFO 2601 --- [ Thread-11] o.s.c.n.e.s.EurekaServerBootstrap : isAws returned false
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] o.s.c.n.e.s.EurekaServerBootstrap : Initialized server context
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2017-06-18 16:25:51.734 INFO 2601 --- [ Thread-11] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2017-06-18 16:25:51.739 INFO 2601 --- [ Thread-11] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2017-06-18 16:25:51.792 INFO 2601 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8761 (http)
2017-06-18 16:25:51.793 INFO 2601 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8761
2017-06-18 16:25:51.795 INFO 2601 --- [ main] c.g.c.s.Main : Started Main in 4.286 seconds (JVM running for 4.924)
2017-06-18 16:25:56.788 INFO 2601 --- [ Thread-13] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2783717b: startup date [Sun Jun 18 16:25:48 EDT 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5a56cdac
2017-06-18 16:25:56.790 INFO 2601 --- [ Thread-13] c.n.e.EurekaDiscoveryClientConfiguration : Unregistering application CiveMicroserviceRegistry with eureka with status DOWN
2017-06-18 16:25:56.791 INFO 2601 --- [ Thread-13] c.n.d.DiscoveryClient : Shutting down DiscoveryClient ...
2017-06-18 16:25:56.791 INFO 2601 --- [ Thread-13] c.n.d.DiscoveryClient : Completed shut down of DiscoveryClient