{"id":131806,"date":"2025-02-26T10:12:00","date_gmt":"2025-02-26T08:12:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=131806"},"modified":"2025-02-25T10:29:24","modified_gmt":"2025-02-25T08:29:24","slug":"spring-boot-centralize-http-logging-example","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html","title":{"rendered":"Spring Boot Centralize HTTP Logging Example"},"content":{"rendered":"<p>Effective logging is essential for debugging, monitoring, and maintaining applications. Let us delve into understanding how Spring Boot can centralize HTTP logging and how it helps track requests, responses, and exceptions effectively.<\/p>\n<h2><a name=\"section-1\"><\/a>1. Introduction<\/h2>\n<p><a href=\"https:\/\/logging.apache.org\/\" target=\"_blank\" rel=\"noopener\">Logging<\/a> is a crucial part of any application. It helps developers track HTTP requests, responses, and exceptions to debug issues effectively. Proper logging ensures better maintainability and faster issue resolution.<\/p>\n<ul>\n<li>Spring Boot Actuator: Provides built-in request logging and monitoring features.<\/li>\n<li>Custom Filter: Implements a filter to log incoming requests and outgoing responses.<\/li>\n<li>Global Exception Handler: Captures and logs exceptions across the application.<\/li>\n<\/ul>\n<h2>1.1 Best Practices for Effective Logging<\/h2>\n<ul>\n<li>Use appropriate log levels: <code>TRACE<\/code>, <code>DEBUG<\/code>, <code>INFO<\/code>, <code>WARN<\/code>, and <code>ERROR<\/code>.<\/li>\n<li>Do not log sensitive information (e.g., passwords, tokens).<\/li>\n<li>Implement structured logging for easy parsing and analysis.<\/li>\n<li>Use external log aggregation tools like ELK (Elasticsearch, Logstash, Kibana) or Loki with Grafana.<\/li>\n<li>Enable asynchronous logging to avoid performance bottlenecks.<\/li>\n<\/ul>\n<h3>1.2 What is Spring Boot Actuator?<\/h3>\n<p><a href=\"https:\/\/docs.spring.io\/spring-boot\/docs\/current\/reference\/html\/actuator.html\" target=\"_blank\" rel=\"noopener\">Spring Boot Actuator<\/a> provides production-ready features such as monitoring and logging. It offers various built-in endpoints to track application health, performance, and runtime configurations.<\/p>\n<h4>1.2.1 Common Actuator Endpoints<\/h4>\n<ul>\n<li><code>\/actuator\/health<\/code> &#8211; Displays the application&#8217;s health status.<\/li>\n<li><code>\/actuator\/loggers<\/code> &#8211; Allows dynamic configuration of logging levels at runtime.<\/li>\n<li><code>\/actuator\/httptrace<\/code> &#8211; Logs recent HTTP requests and responses (needs to be enabled in properties).<\/li>\n<li><code>\/actuator\/metrics<\/code> &#8211; Provides application metrics such as memory usage, CPU load, and active threads.<\/li>\n<li><code>\/actuator\/info<\/code> &#8211; Displays custom application information (can be configured in <code>application.properties<\/code>).<\/li>\n<li><code>\/actuator\/env<\/code> &#8211; Shows the environment properties of the application.<\/li>\n<\/ul>\n<h4>1.2.2 Benefits of Using Spring Boot Actuator<\/h4>\n<ul>\n<li>Provides real-time insights into application performance.<\/li>\n<li>Helps in proactive monitoring and debugging.<\/li>\n<li>Supports integration with monitoring tools like Prometheus and Grafana.<\/li>\n<li>Enables runtime configuration of logging levels without restarting the application.<\/li>\n<\/ul>\n<p>Spring Boot Actuator is a powerful tool that enhances observability, making it easier to manage and debug applications in production.<\/p>\n<h2><a name=\"section-2\"><\/a>2. Code Example<\/h2>\n<h3>2.1 Maven Dependencies<\/h3>\n<p>To enable Actuator, add the following dependency in your <code>pom.xml<\/code>:<\/p>\n<pre class=\"brush:xml; wrap-lines:false;\">&lt;dependencies&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n        &lt;artifactId&gt;spring-boot-starter-actuator&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n    &lt;dependency&gt;\n        &lt;groupId&gt;ch.qos.logback&lt;\/groupId&gt;\n        &lt;artifactId&gt;logback-classic&lt;\/artifactId&gt;\n    &lt;\/dependency&gt;\n&lt;\/dependencies&gt;\n<\/pre>\n<h3>2.2 Enable Actuator in application.properties<\/h3>\n<p>To expose all Actuator endpoints for monitoring and debugging, add the following configuration to your <code>application.properties<\/code> or <code>application.yml<\/code> file:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:plain; wrap-lines:false;\"># Expose all actuator endpoints\nmanagement.endpoints.web.exposure.include=*\n# Enable the \/actuator\/loggers endpoint for runtime logging level changes\nmanagement.endpoint.loggers.enabled=true\n# Enable detailed request logging for debugging\nlogging.level.org.springframework.web.filter.CommonsRequestLoggingFilter=DEBUG\n<\/pre>\n<p>With this setup, Spring Boot will log incoming requests at the DEBUG level.<\/p>\n<h3>2.3 Create a Custom Logging Filter<\/h3>\n<p>To log requests and responses in detail, create a custom filter:<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">import org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.stereotype.Component;\n\nimport javax.servlet.Filter;\nimport javax.servlet.FilterChain;\nimport javax.servlet.ServletException;\nimport javax.servlet.ServletRequest;\nimport javax.servlet.ServletResponse;\nimport javax.servlet.http.HttpServletRequest;\nimport javax.servlet.http.HttpServletResponse;\nimport java.io.IOException;\n\n@Component\npublic class LoggingFilter implements Filter {\n    private static final Logger logger = LoggerFactory.getLogger(LoggingFilter.class);\n\n    @Override\n    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)\n            throws IOException, ServletException {\n        HttpServletRequest httpRequest = (HttpServletRequest) request;\n        HttpServletResponse httpResponse = (HttpServletResponse) response;\n\n        logger.info(\"Incoming Request: [{}] {}\", httpRequest.getMethod(), httpRequest.getRequestURI());\n\n        chain.doFilter(request, response);\n\n        logger.info(\"Outgoing Response: Status={}\", httpResponse.getStatus());\n    }\n}\n<\/pre>\n<h4>2.3.1 Code Explanation<\/h4>\n<p>The <code>LoggingFilter<\/code> class is a Spring Boot component that implements the <code>Filter<\/code> interface to log incoming HTTP requests and outgoing responses. Annotated with <code>@Component<\/code>, it is automatically detected as a Spring-managed bean. Inside the <code>doFilter<\/code> method, the request and response objects are cast to <code>HttpServletRequest<\/code> and <code>HttpServletResponse<\/code>, respectively. Before forwarding the request down the filter chain using <code>chain.doFilter(request, response)<\/code>, it logs the HTTP method and request URI using SLF4J&#8217;s logger. After the request is processed, it logs the HTTP response status, helping with debugging and monitoring API traffic.<\/p>\n<h3>2.4 Create a Global Exception Handler<\/h3>\n<p>To log exceptions globally, create an exception handler using <code>@ControllerAdvice<\/code>:<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">import org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.springframework.http.HttpStatus;\nimport org.springframework.http.ResponseEntity;\nimport org.springframework.web.bind.annotation.ExceptionHandler;\nimport org.springframework.web.bind.annotation.RestControllerAdvice;\n\n@RestControllerAdvice\npublic class GlobalExceptionHandler {\n\n    private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);\n\n    @ExceptionHandler(Exception.class)\n    public ResponseEntity&lt;String&gt; handleException(Exception e) {\n        logger.error(\"Exception occurred: {}\", e.getMessage());\n        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)\n                .body(\"An error occurred: \" + e.getMessage());\n    }\n}\n<\/pre>\n<h4>2.4.1 Code Explanation<\/h4>\n<p>The <code>GlobalExceptionHandler<\/code> class is a centralized exception-handling component in a Spring Boot application, annotated with <a href=\"https:\/\/docs.spring.io\/spring-framework\/docs\/current\/javadoc-api\/org\/springframework\/web\/bind\/annotation\/RestControllerAdvice.html\" target=\"_blank\" rel=\"noopener\">@RestControllerAdvice<\/a> to provide global exception handling for all controllers. It defines a method <code>handleException<\/code>, which is annotated with <code>@ExceptionHandler(Exception.class)<\/code> to catch all exceptions of type <code>Exception<\/code>. When an exception occurs, it logs the error message using SLF4J&#8217;s logger and returns a <code>ResponseEntity<\/code> with an HTTP 500 (Internal Server Error) status and a response body containing the error message. This approach ensures consistent error responses and improves debugging by capturing exceptions centrally.<\/p>\n<h3>2.5 Testing the Implementation<\/h3>\n<p>Create a sample controller with an endpoint that triggers an exception:<\/p>\n<pre class=\"brush:java; wrap-lines:false;\">import org.springframework.web.bind.annotation.GetMapping;\nimport org.springframework.web.bind.annotation.RequestMapping;\nimport org.springframework.web.bind.annotation.RestController;\n\n@RestController\n@RequestMapping(\"\/api\")\npublic class TestController {\n\n    @GetMapping(\"\/test\")\n    public String testEndpoint() {\n        return \"Hello, World!\";\n    }\n\n    @GetMapping(\"\/error\")\n    public String errorEndpoint() {\n        throw new RuntimeException(\"Test Exception\");\n    }\n}\n<\/pre>\n<h4>2.5.1 Code Explanation<\/h4>\n<p>The <code>TestController<\/code> class is a Spring Boot REST controller, indicated by the <code>@RestController<\/code> annotation, which handles HTTP requests under the base path <code>\/api<\/code> as defined by <code>@RequestMapping(\"\/api\")<\/code>. It defines two endpoints: <code>\/test<\/code> and <code>\/error<\/code>. The <code>testEndpoint<\/code> method, mapped to <code>GET \/api\/test<\/code> using <code>@GetMapping(\"\/test\")<\/code>, returns a simple &#8220;Hello, World!&#8221; response. The <code>errorEndpoint<\/code> method, mapped to <code>GET \/api\/error<\/code>, intentionally throws a <code>RuntimeException<\/code> with the message &#8220;Test Exception,&#8221; which would trigger global exception handling if configured, making this controller useful for testing request handling and error management in a Spring Boot application.<\/p>\n<h3>2.6 Output<\/h3>\n<h4>2.6.1 Successful Request<\/h4>\n<p>When a request is made to the <code>\/api\/test<\/code> endpoint, the application logs an incoming request message, indicating that a <code>GET<\/code> request was received for <code>\/api\/test<\/code>. Since this endpoint successfully returns a &#8220;Hello, World!&#8221; response, the system logs an outgoing response message with an HTTP status code <code>200<\/code> (OK), signifying a successful request.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">INFO  Incoming Request: [GET] \/api\/test\nINFO  Outgoing Response: Status=200\n<\/pre>\n<h4>2.6.2 Unsuccessful Request<\/h4>\n<p>When a request is made to the <code>\/api\/error<\/code> endpoint, the application logs an incoming request message, showing that a <code>GET<\/code> request was received for <code>\/api\/error<\/code>. However, since this endpoint deliberately throws a <code>RuntimeException<\/code> with the message &#8220;Test Exception,&#8221; the global exception handler catches the error and logs an exception message. As a result, the system logs an outgoing response message with an HTTP status code <code>500<\/code> (Internal Server Error), indicating that an error occurred while processing the request.<\/p>\n<pre class=\"brush:plain; wrap-lines:false;\">INFO  Incoming Request: [GET] \/api\/error\nERROR Exception occurred: Test Exception\nINFO  Outgoing Response: Status=500\n<\/pre>\n<p>This logging output is useful for debugging and monitoring API behavior, as it provides clear visibility into both successful and failed request handling. By analyzing these logs, developers can quickly identify issues, trace errors, and ensure the application is functioning correctly.<\/p>\n<h2><a name=\"section-3\"><\/a>3. Conclusion<\/h2>\n<p>By integrating Spring Boot Actuator, a custom logging filter, and a global exception handler, we can centralize logging for all requests, responses, and errors. This enhances observability, simplifies debugging, and ensures better monitoring for production-ready applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Effective logging is essential for debugging, monitoring, and maintaining applications. Let us delve into understanding how Spring Boot can centralize HTTP logging and how it helps track requests, responses, and exceptions effectively. 1. Introduction Logging is a crucial part of any application. It helps developers track HTTP requests, responses, and exceptions to debug issues effectively. &hellip;<\/p>\n","protected":false},"author":26931,"featured_media":121875,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[246,1114],"class_list":["post-131806","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-logback","tag-spring-zh-hans"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Boot Centralize HTTP Logging Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Spring boot centralize http logging: Learn how to centralize HTTP logging in Spring Boot using filters, Actuator, and exception handling.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot Centralize HTTP Logging Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Spring boot centralize http logging: Learn how to centralize HTTP logging in Spring Boot using filters, Actuator, and exception handling.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-26T08:12:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/spring-boot-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin Batra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin Batra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html\"},\"author\":{\"name\":\"Yatin Batra\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\"},\"headline\":\"Spring Boot Centralize HTTP Logging Example\",\"datePublished\":\"2025-02-26T08:12:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html\"},\"wordCount\":838,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/spring-boot-logo.jpg\",\"keywords\":[\"Logback\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html\",\"name\":\"Spring Boot Centralize HTTP Logging Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/spring-boot-logo.jpg\",\"datePublished\":\"2025-02-26T08:12:00+00:00\",\"description\":\"Spring boot centralize http logging: Learn how to centralize HTTP logging in Spring Boot using filters, Actuator, and exception handling.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/spring-boot-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2024\\\/04\\\/spring-boot-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/spring-boot-centralize-http-logging-example.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Boot Centralize HTTP Logging Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/cda31a4c1965373fed40c8907dc09b8d\",\"name\":\"Yatin Batra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/Yatin.batra_.jpg\",\"caption\":\"Yatin Batra\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\\\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\\\/\\\/www.javacodegeeks.com\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/yatin-batra\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot Centralize HTTP Logging Example - Java Code Geeks","description":"Spring boot centralize http logging: Learn how to centralize HTTP logging in Spring Boot using filters, Actuator, and exception handling.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html","og_locale":"en_US","og_type":"article","og_title":"Spring Boot Centralize HTTP Logging Example - Java Code Geeks","og_description":"Spring boot centralize http logging: Learn how to centralize HTTP logging in Spring Boot using filters, Actuator, and exception handling.","og_url":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2025-02-26T08:12:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/spring-boot-logo.jpg","type":"image\/jpeg"}],"author":"Yatin Batra","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin Batra","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html"},"author":{"name":"Yatin Batra","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d"},"headline":"Spring Boot Centralize HTTP Logging Example","datePublished":"2025-02-26T08:12:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html"},"wordCount":838,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/spring-boot-logo.jpg","keywords":["Logback","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html","url":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html","name":"Spring Boot Centralize HTTP Logging Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/spring-boot-logo.jpg","datePublished":"2025-02-26T08:12:00+00:00","description":"Spring boot centralize http logging: Learn how to centralize HTTP logging in Spring Boot using filters, Actuator, and exception handling.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/spring-boot-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/04\/spring-boot-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/spring-boot-centralize-http-logging-example.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Boot Centralize HTTP Logging Example"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/cda31a4c1965373fed40c8907dc09b8d","name":"Yatin Batra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/12\/Yatin.batra_.jpg","caption":"Yatin Batra"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/www.javacodegeeks.com\/author\/yatin-batra"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/131806","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/26931"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=131806"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/131806\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/121875"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=131806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=131806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=131806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}