Чтобы однозначно идентифицировать мои журналы выполнения приложения, я попытался добавить один uuid, для этого я изменил log4j2.xml .
Код: Выделить всё
file path:- src/main/resources/log4j2.xml
Код: Выделить всё
info-log
./
Код: Выделить всё
2024-09-23 11:55:57.631 [thread - main] [WARN ] | uuid='5ed72e5b-c6b4-44c1-b9ce-dbd59bc6bd09' | [Method Name - openEntityManagerInViewInterceptor] -- org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration$JpaWebConfiguration - spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2024-09-23 11:55:58.599 [thread - main] [INFO ] | uuid='5ed72e5b-c6b4-44c1-b9ce-dbd59bc6bd09' | [Method Name - log] -- org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8080"] 2024-09-23 11:55:58.674 [thread - main] [INFO ] | uuid='5ed72e5b-c6b4-44c1-b9ce-dbd59bc6bd09' | [Method Name - start] -- org.springframework.boot.web.embedded.tomcat.TomcatWebServer - Tomcat started on port(s): 8080 (http) with context path '' 2024-09-23 11:55:58.687 [thread - main] [INFO ] | **uuid='5ed72e5b-c6b4-44c1-b9ce-dbd59bc6bd09'** | [Method Name - logStarted] -- com.example.DemoApplication - Started DemoApplication in 10.893 seconds (JVM running for 13.985) 2024-09-23 11:56:29.092 [thread - http-nio-8080-exec-2] [INFO ] | **uuid=''** | [Method Name - log] -- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet' 2024-09-23 11:56:29.092 [thread - http-nio-8080-exec-2] [INFO ] | uuid='' | [Method Name - initServletBean] -- org.springframework.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet' 2024-09-23 11:56:29.100 [thread - http-nio-8080-exec-2] [INFO ] | uuid='' | [Method Name - initServletBean] -- org.springframework.web.servlet.DispatcherServlet - Completed initialization in 8 ms 2024-09-23 11:56:29.341 [thread - http-nio-8080-exec-2] [INFO ] | uuid='' | [Method Name - createDepartment] -- com.example.controller.DepartmentController - Entering createDepartment method with request: /departments 2024-09-23 11:56:29.342 [thread - http-nio-8080-exec-2] [INFO ] | uuid='' | [Method Name - createDepartment] -- com.example.controller.DepartmentController - Request Parameter: Computer 2024-09-23 11:56:29.521 [thread - http-nio-8080-exec-2] [INFO ] | uuid='' | [Method Name - writeLog] -- net.ttddyy.dsproxy.listener.logging.CommonsQueryLoggingListener - Name:Proxy DataSource, Connection:4, Time:8, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["insert into department (id, name) values (default, ?)"], Params:[(Computer)]
Код: Выделить всё
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
String uuid = java.util.UUID.randomUUID().toString();
// Put the UUID value into the ThreadContext map
ThreadContext.put("uuid", uuid);
SpringApplication.run(DemoApplication.class, args);
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... ain-thread