Hi @stephenb
We tried above shared configuration by you and we are able to get the logs in Json format but it is not exactly same log what it is storing in Json log file named app.log.json which is generated after configuring log correlation in application properties as below
application.properties
server.port=8013
logging.level.org.springframework.context=INFO
#admin.baseurl.path = ${EMP_ADMIN_BASE_URL}
#elastic.apm.server-url= ${APM_SERVICE_URL}
admin.baseurl.path = http://localhost:8001/admin
elastic.apm.server-url=https://34.173.47.87:8200/
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=admin
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
elastic.apm.enabled=true
elastic.apm.service-name=spring-boot-consumer
elastic.apm.environment=dev
elastic.apm.application-packages=net.javaguides.springboot.config
elastic.apm.log-level=ERROR
elastic.apm.enable_log_correlation=true
elastic.apm.verify_server_cert=false
spring.application.name=employee-management-webapp
logging.file.name=logs/ECS-consumer.log
spring.devtools.add-properties=false
logging.level.web=DEBUG
# Set the logging level for the root logger
logging.level.root=INFO
# Use Logback as the logging system
#logging.config=classpath:logback-spring.xml
#
## Configure the Elasticsearch client
#elasticsearch.host=34.173.47.87
#elasticsearch.port=9201
#elasticsearch.scheme=http
#elasticsearch.username=elastic
#elasticsearch.password=elastic
Logback-spring.xml configuration below
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<include resource="co/elastic/logging/logback/boot/ecs-file-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ECS_JSON_FILE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
After performing above configuration able to get the logs in custom json file as below
{"@timestamp":"2023-04-20T09:24:45.456Z","log.level": "WARN","message":"Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [168] milliseconds.","ecs.version": "1.2.0","service.name":"employee-management-webapp","event.dataset":"employee-management-webapp","process.thread.name":"http-nio-8013-exec-1","log.logger":"org.apache.catalina.util.SessionIdGeneratorBase","transaction.id":"c5ad4dabf07c348f","trace.id":"3314291be4ed035a74d22f53ff5e59b5"}
{"@timestamp":"2023-04-20T09:25:07.476Z","log.level": "INFO","message":"Details entered in employee form.","ecs.version": "1.2.0","service.name":"employee-management-webapp","event.dataset":"employee-management-webapp","process.thread.name":"http-nio-8013-exec-9","log.logger":"net.javaguides.springboot.controller.EmployeeController","transaction.id":"0ab254641be66797","trace.id":"d87403c0f01d91eacf75e4555568cb77","TransactionId":"34FF46F0369D4D4B97EEC40D45042A33"}
But in console the logs are printing as below where it is missing many information such as trace id, transaction id
2023-03-30 10:03:13.655 DEBUG 7392 --- [http-nio-8013-exec-5] o.s.web.servlet.DispatcherServlet : GET "/login", parameters={}
2023-03-30 10:03:13.656 DEBUG 7392 --- [http-nio-8013-exec-5] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to net.javaguides.springboot.controller.MainController#login()
2023-03-30 10:03:13.658 DEBUG 7392 --- [http-nio-8013-exec-5] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.7, */*;q=0.8]
2023-03-30 10:03:13.662 DEBUG 7392 --- [http-nio-8013-exec-5] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2023-03-30 10:03:18.884 DEBUG 7392 --- [http-nio-8013-exec-7] o.s.web.servlet.DispatcherServlet : GET "/", parameters={}
2023-03-30 10:03:18.885 DEBUG 7392 --- [http-nio-8013-exec-7] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to net.javaguides.springboot.controller.EmployeeController#viewHomePage(Model)
2023-03-30 10:03:18.940 DEBUG 7392 --- [http-nio-8013-exec-7] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, application/signed-exchange;v=b3;q=0.7, */*;q=0.8]
2023-03-30 10:03:18.993 DEBUG 7392 --- [http-nio-8013-exec-7] o.s.web.servlet.DispatcherServlet : Completed 200 OK
2023-03-30 10:03:22.656 DEBUG 7392 --- [http-nio-8013-exec-8] o.s.web.servlet.DispatcherServlet : GET "/showNewEmployeeForm", parameters={}
2023-03-30 10:03:22.657 DEBUG 7392 --- [http-nio-8013-exec-8] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to net.javaguides.springboot.controller.EmployeeController#showNewEmployeeForm(Model)
2023-03-30 10:03:22.659 INFO 7392 --- [http-nio-8013-exec-8] n.j.s.controller.EmployeeController : Details entered in employee form.
has context menu
Compose