Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用log4j2替代springboot自带的logback之后,log4j2.xml写的pattern是按照TraceEnvironmentPostProcessor#LEVEL_STR_ORIGINAL,运行时没有打印application name, X-B3-TraceId等信息 #5

Open
purgeyao opened this issue May 29, 2020 · 0 comments

Comments

@purgeyao
Copy link
Member

使用log4j2替代springboot自带的logback之后,log4j2.xml写的pattern是按照TraceEnvironmentPostProcessor#LEVEL_STR_ORIGINAL,运行时没有打印application name, X-B3-TraceId等信息

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency> <!-- 引入log4j2依赖 -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:52032,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -javaagent:/Users/purgeyao/Library/Caches/JetBrains/IntelliJIdea2020.1/captureAgent/debugger-agent.jar -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home/lib/tools.jar:/Volumes/CodeFile/GitHub/purgeteam/log-trace-spring-boot/log-trace-spring-boot-demo/log-trace-demo/log-trace-springboot-2.1.x-demo/log-trace-service-a-demo/target/classes:/Volumes/Code/maven-jar/alibaba/repository/com/purgeteam/log-trace-spring-boot-starter/0.1.2.RELEASE/log-trace-spring-boot-starter-0.1.2.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/slf4j/slf4j-api/1.7.28/slf4j-api-1.7.28.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-starter-web/2.1.8.RELEASE/spring-boot-starter-web-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-starter/2.1.8.RELEASE/spring-boot-starter-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot/2.1.8.RELEASE/spring-boot-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-autoconfigure/2.1.8.RELEASE/spring-boot-autoconfigure-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/javax/annotation/javax.annotation-api/1.3.2/javax.annotation-api-1.3.2.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-core/5.1.9.RELEASE/spring-core-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-jcl/5.1.9.RELEASE/spring-jcl-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/yaml/snakeyaml/1.23/snakeyaml-1.23.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-starter-json/2.1.8.RELEASE/spring-boot-starter-json-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/jackson/core/jackson-databind/2.9.9.3/jackson-databind-2.9.9.3.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/jackson/core/jackson-core/2.9.9/jackson-core-2.9.9.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.9.9/jackson-datatype-jdk8-2.9.9.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.9.9/jackson-datatype-jsr310-2.9.9.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.9.9/jackson-module-parameter-names-2.9.9.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-starter-tomcat/2.1.8.RELEASE/spring-boot-starter-tomcat-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.24/tomcat-embed-core-9.0.24.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.24/tomcat-embed-el-9.0.24.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.24/tomcat-embed-websocket-9.0.24.jar:/Volumes/Code/maven-jar/alibaba/repository/org/hibernate/validator/hibernate-validator/6.0.17.Final/hibernate-validator-6.0.17.Final.jar:/Volumes/Code/maven-jar/alibaba/repository/javax/validation/validation-api/2.0.1.Final/validation-api-2.0.1.Final.jar:/Volumes/Code/maven-jar/alibaba/repository/org/jboss/logging/jboss-logging/3.3.3.Final/jboss-logging-3.3.3.Final.jar:/Volumes/Code/maven-jar/alibaba/repository/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-web/5.1.9.RELEASE/spring-web-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-beans/5.1.9.RELEASE/spring-beans-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-webmvc/5.1.9.RELEASE/spring-webmvc-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-context/5.1.9.RELEASE/spring-context-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-expression/5.1.9.RELEASE/spring-expression-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-starter-log4j2/2.1.8.RELEASE/spring-boot-starter-log4j2-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/logging/log4j/log4j-api/2.11.2/log4j-api-2.11.2.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/logging/log4j/log4j-core/2.11.2/log4j-core-2.11.2.jar:/Volumes/Code/maven-jar/alibaba/repository/org/apache/logging/log4j/log4j-jul/2.11.2/log4j-jul-2.11.2.jar:/Volumes/Code/maven-jar/alibaba/repository/org/slf4j/jul-to-slf4j/1.7.28/jul-to-slf4j-1.7.28.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-starter-aop/2.1.8.RELEASE/spring-boot-starter-aop-2.1.8.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/spring-aop/5.1.9.RELEASE/spring-aop-5.1.9.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/aspectj/aspectjweaver/1.9.4/aspectjweaver-1.9.4.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-starter-openfeign/2.1.0.RELEASE/spring-cloud-starter-openfeign-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-starter/2.1.0.RELEASE/spring-cloud-starter-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-context/2.1.0.RELEASE/spring-cloud-context-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/security/spring-security-rsa/1.0.7.RELEASE/spring-security-rsa-1.0.7.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/bouncycastle/bcpkix-jdk15on/1.60/bcpkix-jdk15on-1.60.jar:/Volumes/Code/maven-jar/alibaba/repository/org/bouncycastle/bcprov-jdk15on/1.60/bcprov-jdk15on-1.60.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-openfeign-core/2.1.0.RELEASE/spring-cloud-openfeign-core-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-netflix-ribbon/2.1.0.RELEASE/spring-cloud-netflix-ribbon-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-netflix-archaius/2.1.0.RELEASE/spring-cloud-netflix-archaius-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/io/github/openfeign/form/feign-form-spring/3.5.0/feign-form-spring-3.5.0.jar:/Volumes/Code/maven-jar/alibaba/repository/io/github/openfeign/form/feign-form/3.5.0/feign-form-3.5.0.jar:/Volumes/Code/maven-jar/alibaba/repository/commons-fileupload/commons-fileupload/1.3.3/commons-fileupload-1.3.3.jar:/Volumes/Code/maven-jar/alibaba/repository/commons-io/commons-io/2.2/commons-io-2.2.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/cloud/spring-cloud-commons/2.1.0.RELEASE/spring-cloud-commons-2.1.0.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/security/spring-security-crypto/5.1.6.RELEASE/spring-security-crypto-5.1.6.RELEASE.jar:/Volumes/Code/maven-jar/alibaba/repository/io/github/openfeign/feign-core/10.1.0/feign-core-10.1.0.jar:/Volumes/Code/maven-jar/alibaba/repository/io/github/openfeign/feign-slf4j/10.1.0/feign-slf4j-10.1.0.jar:/Volumes/Code/maven-jar/alibaba/repository/io/github/openfeign/feign-hystrix/10.1.0/feign-hystrix-10.1.0.jar:/Volumes/Code/maven-jar/alibaba/repository/com/netflix/archaius/archaius-core/0.7.6/archaius-core-0.7.6.jar:/Volumes/Code/maven-jar/alibaba/repository/com/google/code/findbugs/jsr305/3.0.1/jsr305-3.0.1.jar:/Volumes/Code/maven-jar/alibaba/repository/commons-configuration/commons-configuration/1.8/commons-configuration-1.8.jar:/Volumes/Code/maven-jar/alibaba/repository/commons-lang/commons-lang/2.6/commons-lang-2.6.jar:/Volumes/Code/maven-jar/alibaba/repository/com/google/guava/guava/16.0/guava-16.0.jar:/Volumes/Code/maven-jar/alibaba/repository/com/netflix/hystrix/hystrix-core/1.5.18/hystrix-core-1.5.18.jar:/Volumes/Code/maven-jar/alibaba/repository/io/reactivex/rxjava/1.3.8/rxjava-1.3.8.jar:/Volumes/Code/maven-jar/alibaba/repository/org/hdrhistogram/HdrHistogram/2.1.9/HdrHistogram-2.1.9.jar:/Volumes/Code/maven-jar/alibaba/repository/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar:/Volumes/Code/maven-jar/alibaba/repository/org/springframework/boot/spring-boot-configuration-processor/2.1.8.RELEASE/spring-boot-configuration-processor-2.1.8.RELEASE.jar:/Users/purgeyao/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/201.6668.121/IntelliJ IDEA.app/Contents/lib/idea_rt.jar com.purgeteam.log.trace.service.a.demo.TraceServiceASpringBootApplication
Connected to the target VM, address: '127.0.0.1:52032', transport: 'socket'
2020-05-29 10:29:19.482  INFO 98017 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$55559813] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2020-05-29 10:29:19.610  INFO 98017 --- [           main] s.a.d.TraceServiceASpringBootApplication : No active profile set, falling back to default profiles: default
2020-05-29 10:29:20.058  INFO 98017 --- [           main] o.s.c.c.s.GenericScope                   : BeanFactory id=0d902bca-fa5c-3361-8b7b-c87fb115eee4
2020-05-29 10:29:20.064  INFO 98017 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.purgerteam.log.trace.starter.instrument.resttemplate.TraceRestTemplateConfiguration' of type [com.purgerteam.log.trace.starter.instrument.resttemplate.TraceRestTemplateConfiguration$$EnhancerBySpringCGLIB$$92d19ba6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-29 10:29:20.077  INFO 98017 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.purgeteam.log.trace.service.a.demo.TestFeign' of type [org.springframework.cloud.openfeign.FeignClientFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-29 10:29:20.078  INFO 98017 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.purgerteam.log.trace.starter.TraceAutoConfiguration' of type [com.purgerteam.log.trace.starter.TraceAutoConfiguration$$EnhancerBySpringCGLIB$$93de17ac] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-29 10:29:20.081  INFO 98017 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'traceContentUtil' of type [com.purgerteam.log.trace.starter.TraceContentFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-29 10:29:20.166  INFO 98017 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$55559813] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-29 10:29:20.414  INFO 98017 --- [           main] o.s.b.w.e.t.TomcatWebServer              : Tomcat initialized with port(s): 8081 (http)
2020-05-29 10:29:20.434  INFO 98017 --- [           main] o.a.c.c.StandardService                  : Starting service [Tomcat]
2020-05-29 10:29:20.434  INFO 98017 --- [           main] o.a.c.c.StandardEngine                   : Starting Servlet engine: [Apache Tomcat/9.0.24]
2020-05-29 10:29:20.519  INFO 98017 --- [           main] o.a.c.c.C.[.[.[/]                        : Initializing Spring embedded WebApplicationContext
2020-05-29 10:29:20.519  INFO 98017 --- [           main] o.s.w.c.ContextLoader                    : Root WebApplicationContext: initialization completed in 887 ms
2020-05-29 10:29:20.842  WARN 98017 --- [           main] c.n.c.s.URLConfigurationSource           : No URLs will be polled as dynamic configuration sources.
2020-05-29 10:29:20.842  INFO 98017 --- [           main] c.n.c.s.URLConfigurationSource           : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-05-29 10:29:20.846  WARN 98017 --- [           main] c.n.c.s.URLConfigurationSource           : No URLs will be polled as dynamic configuration sources.
2020-05-29 10:29:20.846  INFO 98017 --- [           main] c.n.c.s.URLConfigurationSource           : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-05-29 10:29:20.978  INFO 98017 --- [           main] o.s.s.c.ThreadPoolTaskExecutor           : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-29 10:29:21.223  INFO 98017 --- [           main] o.s.b.w.e.t.TomcatWebServer              : Tomcat started on port(s): 8081 (http) with context path ''
2020-05-29 10:29:21.226  INFO 98017 --- [           main] s.a.d.TraceServiceASpringBootApplication : Started TraceServiceASpringBootApplication in 2.613 seconds (JVM running for 3.505)
2020-05-29 10:29:21.227  INFO 98017 --- [           main] s.a.d.TraceServiceASpringBootApplication : 启动

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant