【发布时间】:2017-12-06 08:53:26
【问题描述】:
我想将我的字符串作为前缀添加到应用程序中的每条日志消息。我的意思是,我有几个 Java 应用程序,我希望其中一个在消息中有一些前缀,例如:
DATE, INFO(or other), [sample] (-->this is my added string) , rest of standard message
我看过几个教程,但没有一个适合我。我已经在 pom 中包含了依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</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>
您对此有什么技巧或简单的解决方案吗?编写某种包装器或配置类?
【问题讨论】:
标签: java spring maven logging log4j