{"id":8112,"date":"2024-10-13T13:30:02","date_gmt":"2024-10-13T17:30:02","guid":{"rendered":"https:\/\/springframework.guru\/?p=8112"},"modified":"2024-10-20T08:11:36","modified_gmt":"2024-10-20T12:11:36","slug":"json-logging-with-spring-boot","status":"publish","type":"post","link":"https:\/\/springframework.guru\/json-logging-with-spring-boot\/","title":{"rendered":"JSON Logging with Spring Boot Made Easy"},"content":{"rendered":"\n<p>JSON Logging is easy to setup with Spring Boot. Frequently, Spring Boot applications are deployed in distributed environments such as Kubernetes. In these deployments, you will likely be setting up consolidated logging.<\/p>\n\n\n\n<p>With consolidated logging, the log output of many applications is consolidated into a single source. To be useful, the consolidated logs need to be searchable. To aid in searching, often the logs are formatted to JSON.<\/p>\n\n\n\n<p>There are several options to use, one of them is Logstash. Logstash is widely accepted and is easy to configure with Spring Boot. Below, I&#8217;ll show you how easy this is to setup with Spring Boot.<\/p>\n\n\n\n<p>The examples used in this post are <a href=\"https:\/\/github.com\/spring-framework-guru\/sfg-blog-posts\/tree\/master\/json-logging\" target=\"_blank\" rel=\"noopener\" title=\"\">available here <\/a>on GitHub.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">JSON Logging Project Dependencies<\/h2>\n\n\n\n<p>First we need to add the required dependencies to our project. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Maven<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#fff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;dependency&gt;\n    &lt;groupId&gt;net.logstash.logback&lt;\/groupId&gt;\n    &lt;artifactId&gt;logstash-logback-encoder&lt;\/artifactId&gt;\n    &lt;version&gt;8.0&lt;\/version&gt;\n&lt;\/dependency&gt;\" style=\"color:#24292e;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-light\" style=\"background-color: #fff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #24292E\">&lt;<\/span><span style=\"color: #22863A\">dependency<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">    &lt;<\/span><span style=\"color: #22863A\">groupId<\/span><span style=\"color: #24292E\">&gt;net.logstash.logback&lt;\/<\/span><span style=\"color: #22863A\">groupId<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">    &lt;<\/span><span style=\"color: #22863A\">artifactId<\/span><span style=\"color: #24292E\">&gt;logstash-logback-encoder&lt;\/<\/span><span style=\"color: #22863A\">artifactId<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">    &lt;<\/span><span style=\"color: #22863A\">version<\/span><span style=\"color: #24292E\">&gt;8.0&lt;\/<\/span><span style=\"color: #22863A\">version<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">&lt;\/<\/span><span style=\"color: #22863A\">dependency<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Gradle<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#fff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'\" style=\"color:#24292e;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-light\" style=\"background-color: #fff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #24292E\">implementation <\/span><span style=\"color: #005CC5\">group<\/span><span style=\"color: #24292E\">: <\/span><span style=\"color: #032F62\">&#39;net.logstash.logback&#39;<\/span><span style=\"color: #24292E\">, <\/span><span style=\"color: #005CC5\">name<\/span><span style=\"color: #24292E\">: <\/span><span style=\"color: #032F62\">&#39;logstash-logback-encoder&#39;<\/span><span style=\"color: #24292E\">, <\/span><span style=\"color: #005CC5\">version<\/span><span style=\"color: #24292E\">: <\/span><span style=\"color: #032F62\">&#39;8.0&#39;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Logback Configuration for JSON Logging<\/h2>\n\n\n\n<p>Spring Boot uses Logback for its logging configuration. To configure Logback to support JSON logging, add the following file to your resources directory. By default, Spring Boot will look for a configuration file called <code>logback-spring.xml<\/code> for the logback configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">logback-spring.xml<\/h2>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#fff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"&lt;configuration&gt;\n\n   &lt;include resource=&quot;org\/springframework\/boot\/logging\/logback\/defaults.xml&quot;\/&gt;\n   &lt;include resource=&quot;org\/springframework\/boot\/logging\/logback\/console-appender.xml&quot; \/&gt;\n\n   &lt;springProperty scope=&quot;context&quot; name=&quot;appName&quot; source=&quot;spring.application.name&quot;\/&gt;\n\n   &lt;springProfile name=&quot;!json-logs&quot;&gt;\n      &lt;include resource=&quot;org\/springframework\/boot\/logging\/logback\/base.xml&quot; \/&gt;\n   &lt;\/springProfile&gt;\n\n   &lt;springProfile name=&quot;json-logs&quot;&gt;\n         &lt;appender name=&quot;jsonConsoleAppender&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&gt;\n            &lt;encoder class=&quot;net.logstash.logback.encoder.LogstashEncoder&quot; \/&gt;\n          &lt;\/appender&gt;\n          \n          &lt;format&gt;\n             &lt;label&gt;\n               &lt;pattern&gt;app=${appName},host=${HOSTNAME},traceID=%X{traceId:-NONE},level=%level&lt;\/pattern&gt;\n           &lt;\/label&gt;\n            &lt;message&gt;\n                &lt;pattern&gt;${FILE_LOG_PATTERN}&lt;\/pattern&gt;\n            &lt;\/message&gt;\n            &lt;sortByTime&gt;true&lt;\/sortByTime&gt;\n        &lt;\/format&gt;\n        \n        &lt;root level=&quot;INFO&quot;&gt;\n            &lt;appender-ref ref=&quot;jsonConsoleAppender&quot; \/&gt;\n        &lt;\/root&gt;\n   &lt;\/springProfile&gt;\n&lt;\/configuration&gt;\" style=\"color:#24292e;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-light\" style=\"background-color: #fff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #24292E\">&lt;<\/span><span style=\"color: #22863A\">configuration<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;<\/span><span style=\"color: #22863A\">include<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">resource<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;org\/springframework\/boot\/logging\/logback\/defaults.xml&quot;<\/span><span style=\"color: #24292E\">\/&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;<\/span><span style=\"color: #22863A\">include<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">resource<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;org\/springframework\/boot\/logging\/logback\/console-appender.xml&quot;<\/span><span style=\"color: #24292E\"> \/&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;<\/span><span style=\"color: #22863A\">springProperty<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">scope<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;context&quot;<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">name<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;appName&quot;<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">source<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;spring.application.name&quot;<\/span><span style=\"color: #24292E\">\/&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;<\/span><span style=\"color: #22863A\">springProfile<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">name<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;!json-logs&quot;<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">      &lt;<\/span><span style=\"color: #22863A\">include<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">resource<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;org\/springframework\/boot\/logging\/logback\/base.xml&quot;<\/span><span style=\"color: #24292E\"> \/&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;\/<\/span><span style=\"color: #22863A\">springProfile<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;<\/span><span style=\"color: #22863A\">springProfile<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">name<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;json-logs&quot;<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">         &lt;<\/span><span style=\"color: #22863A\">appender<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">name<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;jsonConsoleAppender&quot;<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">class<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;ch.qos.logback.core.ConsoleAppender&quot;<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">            &lt;<\/span><span style=\"color: #22863A\">encoder<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">class<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;net.logstash.logback.encoder.LogstashEncoder&quot;<\/span><span style=\"color: #24292E\"> \/&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">          &lt;\/<\/span><span style=\"color: #22863A\">appender<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">          <\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">          &lt;<\/span><span style=\"color: #22863A\">format<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">             &lt;<\/span><span style=\"color: #22863A\">label<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">               &lt;<\/span><span style=\"color: #22863A\">pattern<\/span><span style=\"color: #24292E\">&gt;app=${appName},host=${HOSTNAME},traceID=%X{traceId:-NONE},level=%level&lt;\/<\/span><span style=\"color: #22863A\">pattern<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">           &lt;\/<\/span><span style=\"color: #22863A\">label<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">            &lt;<\/span><span style=\"color: #22863A\">message<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">                &lt;<\/span><span style=\"color: #22863A\">pattern<\/span><span style=\"color: #24292E\">&gt;${FILE_LOG_PATTERN}&lt;\/<\/span><span style=\"color: #22863A\">pattern<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">            &lt;\/<\/span><span style=\"color: #22863A\">message<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">            &lt;<\/span><span style=\"color: #22863A\">sortByTime<\/span><span style=\"color: #24292E\">&gt;true&lt;\/<\/span><span style=\"color: #22863A\">sortByTime<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        &lt;\/<\/span><span style=\"color: #22863A\">format<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        &lt;<\/span><span style=\"color: #22863A\">root<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">level<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">            &lt;<\/span><span style=\"color: #22863A\">appender-ref<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">ref<\/span><span style=\"color: #24292E\">=<\/span><span style=\"color: #032F62\">&quot;jsonConsoleAppender&quot;<\/span><span style=\"color: #24292E\"> \/&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        &lt;\/<\/span><span style=\"color: #22863A\">root<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">   &lt;\/<\/span><span style=\"color: #22863A\">springProfile<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">&lt;\/<\/span><span style=\"color: #22863A\">configuration<\/span><span style=\"color: #24292E\">&gt;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This configuration does the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Imports the Spring Boot default logback configuration<\/li>\n\n\n\n<li>Sets the application name<\/li>\n\n\n\n<li>Uses normal console output if the profile <code>json-logs<\/code> is not active<\/li>\n\n\n\n<li>Uses Logstash JSON output is the profile `json-logs is active<\/li>\n<\/ul>\n\n\n\n<p>Having the profile property is handy for development. JSON logs are hard to read in the console, thus you can use normal log output in development. And then use JSON output when the application is deployed.<\/p>\n\n\n\n<p>You can learn more about Logback configuration in my <a href=\"https:\/\/springframework.guru\/logback-enterprise-logging-framework-2\/\" target=\"_blank\" rel=\"noopener\" title=\"\">previous blog post<\/a> about Logback.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Try it out!<\/h2>\n\n\n\n<p>To test out the log output, add the following class to your Spring Boot project. This will just generate some log messages we can see in the output.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#fff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"@Slf4j\n@Component\npublic class BootStrap implements CommandLineRunner {\n\n    @Override\n    public void run(String... args) throws Exception {\n        log.debug(&quot;Debugging log&quot;);\n        log.info(&quot;Info log&quot;);\n        log.warn(&quot;Warning log&quot;);\n        log.error(&quot;Error log&quot;);\n    }\n}\" style=\"color:#24292e;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-light\" style=\"background-color: #fff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #24292E\">@<\/span><span style=\"color: #D73A49\">Slf4j<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">@<\/span><span style=\"color: #D73A49\">Component<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D73A49\">public<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #D73A49\">class<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">BootStrap<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #D73A49\">implements<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">CommandLineRunner<\/span><span style=\"color: #24292E\"> {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">    @<\/span><span style=\"color: #D73A49\">Override<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">    <\/span><span style=\"color: #D73A49\">public<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #D73A49\">void<\/span><span style=\"color: #24292E\"> <\/span><span style=\"color: #6F42C1\">run<\/span><span style=\"color: #24292E\">(String... <\/span><span style=\"color: #E36209\">args<\/span><span style=\"color: #24292E\">) <\/span><span style=\"color: #D73A49\">throws<\/span><span style=\"color: #24292E\"> Exception {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        log.<\/span><span style=\"color: #6F42C1\">debug<\/span><span style=\"color: #24292E\">(<\/span><span style=\"color: #032F62\">&quot;Debugging log&quot;<\/span><span style=\"color: #24292E\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        log.<\/span><span style=\"color: #6F42C1\">info<\/span><span style=\"color: #24292E\">(<\/span><span style=\"color: #032F62\">&quot;Info log&quot;<\/span><span style=\"color: #24292E\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        log.<\/span><span style=\"color: #6F42C1\">warn<\/span><span style=\"color: #24292E\">(<\/span><span style=\"color: #032F62\">&quot;Warning log&quot;<\/span><span style=\"color: #24292E\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">        log.<\/span><span style=\"color: #6F42C1\">error<\/span><span style=\"color: #24292E\">(<\/span><span style=\"color: #032F62\">&quot;Error log&quot;<\/span><span style=\"color: #24292E\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In a minimal Spring Boot application, this will produce the following output. <\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#fff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"  .   ____          _            __ _ _\n \/\\\\ \/ ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\n( ( )\\___ | '_ | '_| | '_ \\\/ _` | \\ \\ \\ \\\n \\\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\n  '  |____| .__|_| |_|_| |_\\__, | \/ \/ \/ \/\n =========|_|==============|___\/=\/_\/_\/_\/\n\n :: Spring Boot ::                (v3.3.4)\n\n2024-10-13T12:56:05.655-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.JsonLoggingApplication   : Starting JsonLoggingApplication using Java 21.0.4 with PID 95924 (\/Users\/jt\/src\/springframework.guru\/sfg-blog-posts\/json-logging\/target\/classes started by jt in \/Users\/jt\/src\/springframework.guru\/sfg-blog-posts)\n2024-10-13T12:56:05.657-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.JsonLoggingApplication   : No active profile set, falling back to 1 default profile: &quot;default&quot;\n2024-10-13T12:56:06.108-04:00  INFO 95924 --- [json-logging] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)\n2024-10-13T12:56:06.115-04:00  INFO 95924 --- [json-logging] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2024-10-13T12:56:06.116-04:00  INFO 95924 --- [json-logging] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat\/10.1.30]\n2024-10-13T12:56:06.137-04:00  INFO 95924 --- [json-logging] [           main] o.a.c.c.C.[Tomcat].[localhost].[\/]       : Initializing Spring embedded WebApplicationContext\n2024-10-13T12:56:06.137-04:00  INFO 95924 --- [json-logging] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 458 ms\n2024-10-13T12:56:06.322-04:00  INFO 95924 --- [json-logging] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '\/'\n2024-10-13T12:56:06.327-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.JsonLoggingApplication   : Started JsonLoggingApplication in 0.946 seconds (process running for 1.268)\n2024-10-13T12:56:06.328-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.boot.BootStrap           : Info log\n2024-10-13T12:56:06.328-04:00  WARN 95924 --- [json-logging] [           main] g.s.jsonlogging.boot.BootStrap           : Warning log\n2024-10-13T12:56:06.328-04:00 ERROR 95924 --- [json-logging] [           main] g.s.jsonlogging.boot.BootStrap           : Error log\" style=\"color:#24292e;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-light\" style=\"background-color: #fff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #24292e\">  .   ____          _            __ _ _<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\"> \/\\\\ \/ ___&#39;_ __ _ _(_)_ __  __ _ \\ \\ \\ \\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">( ( )\\___ | &#39;_ | &#39;_| | &#39;_ \\\/ _` | \\ \\ \\ \\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\"> \\\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">  &#39;  |____| .__|_| |_|_| |_\\__, | \/ \/ \/ \/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\"> =========|_|==============|___\/=\/_\/_\/_\/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\"><\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\"> :: Spring Boot ::                (v3.3.4)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\"><\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:05.655-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.JsonLoggingApplication   : Starting JsonLoggingApplication using Java 21.0.4 with PID 95924 (\/Users\/jt\/src\/springframework.guru\/sfg-blog-posts\/json-logging\/target\/classes started by jt in \/Users\/jt\/src\/springframework.guru\/sfg-blog-posts)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:05.657-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.JsonLoggingApplication   : No active profile set, falling back to 1 default profile: &quot;default&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.108-04:00  INFO 95924 --- [json-logging] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.115-04:00  INFO 95924 --- [json-logging] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.116-04:00  INFO 95924 --- [json-logging] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat\/10.1.30]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.137-04:00  INFO 95924 --- [json-logging] [           main] o.a.c.c.C.[Tomcat].[localhost].[\/]       : Initializing Spring embedded WebApplicationContext<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.137-04:00  INFO 95924 --- [json-logging] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 458 ms<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.322-04:00  INFO 95924 --- [json-logging] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path &#39;\/&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.327-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.JsonLoggingApplication   : Started JsonLoggingApplication in 0.946 seconds (process running for 1.268)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.328-04:00  INFO 95924 --- [json-logging] [           main] g.s.jsonlogging.boot.BootStrap           : Info log<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.328-04:00  WARN 95924 --- [json-logging] [           main] g.s.jsonlogging.boot.BootStrap           : Warning log<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292e\">2024-10-13T12:56:06.328-04:00 ERROR 95924 --- [json-logging] [           main] g.s.jsonlogging.boot.BootStrap           : Error log<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>When you set the profile <code>json-logs<\/code> active, you will receive the following output.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#fff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"  .   ____          _            __ _ _\n \/\\\\ \/ ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\n( ( )\\___ | '_ | '_| | '_ \\\/ _` | \\ \\ \\ \\\n \\\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\n  '  |____| .__|_| |_|_| |_\\__, | \/ \/ \/ \/\n =========|_|==============|___\/=\/_\/_\/_\/\n\n :: Spring Boot ::                (v3.3.4)\n\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:44.931694-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Starting JsonLoggingApplication using Java 21.0.4 with PID 95967 (\/Users\/jt\/src\/springframework.guru\/sfg-blog-posts\/json-logging\/target\/classes started by jt in \/Users\/jt\/src\/springframework.guru\/sfg-blog-posts)&quot;,&quot;logger_name&quot;:&quot;guru.springframework.jsonlogging.JsonLoggingApplication&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:44.937666-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;The following 1 profile is active: \\&quot;json-logs\\&quot;&quot;,&quot;logger_name&quot;:&quot;guru.springframework.jsonlogging.JsonLoggingApplication&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.412153-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Tomcat initialized with port 8080 (http)&quot;,&quot;logger_name&quot;:&quot;org.springframework.boot.web.embedded.tomcat.TomcatWebServer&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.419088-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Starting service [Tomcat]&quot;,&quot;logger_name&quot;:&quot;org.apache.catalina.core.StandardService&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.419294-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Starting Servlet engine: [Apache Tomcat\/10.1.30]&quot;,&quot;logger_name&quot;:&quot;org.apache.catalina.core.StandardEngine&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.440523-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Initializing Spring embedded WebApplicationContext&quot;,&quot;logger_name&quot;:&quot;org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[\/]&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.440674-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Root WebApplicationContext: initialization completed in 476 ms&quot;,&quot;logger_name&quot;:&quot;org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.610566-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Tomcat started on port 8080 (http) with context path '\/'&quot;,&quot;logger_name&quot;:&quot;org.springframework.boot.web.embedded.tomcat.TomcatWebServer&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.615642-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Started JsonLoggingApplication in 1.039 seconds (process running for 1.364)&quot;,&quot;logger_name&quot;:&quot;guru.springframework.jsonlogging.JsonLoggingApplication&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.617424-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Info log&quot;,&quot;logger_name&quot;:&quot;guru.springframework.jsonlogging.boot.BootStrap&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;INFO&quot;,&quot;level_value&quot;:20000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.617536-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Warning log&quot;,&quot;logger_name&quot;:&quot;guru.springframework.jsonlogging.boot.BootStrap&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;WARN&quot;,&quot;level_value&quot;:30000,&quot;appName&quot;:&quot;json-logging&quot;}\n{&quot;@timestamp&quot;:&quot;2024-10-13T13:01:45.617564-04:00&quot;,&quot;@version&quot;:&quot;1&quot;,&quot;message&quot;:&quot;Error log&quot;,&quot;logger_name&quot;:&quot;guru.springframework.jsonlogging.boot.BootStrap&quot;,&quot;thread_name&quot;:&quot;main&quot;,&quot;level&quot;:&quot;ERROR&quot;,&quot;level_value&quot;:40000,&quot;appName&quot;:&quot;json-logging&quot;}\n\" style=\"color:#24292e;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-light\" style=\"background-color: #fff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #24292E\">  .   ____          _            __ _ _<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\"> \/\\\\ \/ ___&#39;_ __ _ _(_)_ __  __ _ \\ \\ \\ \\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">( ( )\\___ | &#39;_ | &#39;_| | &#39;_ \\\/ _` | \\ \\ \\ \\<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\"> \\\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">  &#39;  |____| .__|_| |_|_| |_\\__, | \/ \/ \/ \/<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\"> =========|_|==============|___\/=\/_\/_\/_\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\"> :: Spring Boot ::                (v<\/span><span style=\"color: #005CC5\">3.3<\/span><span style=\"color: #24292E\">.<\/span><span style=\"color: #005CC5\">4<\/span><span style=\"color: #24292E\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:44.931694-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Starting JsonLoggingApplication using Java 21.0.4 with PID 95967 (\/Users\/jt\/src\/springframework.guru\/sfg-blog-posts\/json-logging\/target\/classes started by jt in \/Users\/jt\/src\/springframework.guru\/sfg-blog-posts)&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;guru.springframework.jsonlogging.JsonLoggingApplication&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:44.937666-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;The following 1 profile is active: <\/span><span style=\"color: #005CC5\">\\&quot;<\/span><span style=\"color: #032F62\">json-logs<\/span><span style=\"color: #005CC5\">\\&quot;<\/span><span style=\"color: #032F62\">&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;guru.springframework.jsonlogging.JsonLoggingApplication&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.412153-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Tomcat initialized with port 8080 (http)&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;org.springframework.boot.web.embedded.tomcat.TomcatWebServer&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.419088-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Starting service [Tomcat]&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;org.apache.catalina.core.StandardService&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.419294-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Starting Servlet engine: [Apache Tomcat\/10.1.30]&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;org.apache.catalina.core.StandardEngine&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.440523-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Initializing Spring embedded WebApplicationContext&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[\/]&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.440674-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Root WebApplicationContext: initialization completed in 476 ms&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.610566-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Tomcat started on port 8080 (http) with context path &#39;\/&#39;&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;org.springframework.boot.web.embedded.tomcat.TomcatWebServer&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.615642-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Started JsonLoggingApplication in 1.039 seconds (process running for 1.364)&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;guru.springframework.jsonlogging.JsonLoggingApplication&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.617424-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Info log&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;guru.springframework.jsonlogging.boot.BootStrap&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;INFO&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">20000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.617536-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Warning log&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;guru.springframework.jsonlogging.boot.BootStrap&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;WARN&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">30000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #24292E\">{<\/span><span style=\"color: #005CC5\">&quot;@timestamp&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;2024-10-13T13:01:45.617564-04:00&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;@version&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;1&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;message&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;Error log&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;logger_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;guru.springframework.jsonlogging.boot.BootStrap&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;thread_name&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;main&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;ERROR&quot;<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;level_value&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #005CC5\">40000<\/span><span style=\"color: #24292E\">,<\/span><span style=\"color: #005CC5\">&quot;appName&quot;<\/span><span style=\"color: #24292E\">:<\/span><span style=\"color: #032F62\">&quot;json-logging&quot;<\/span><span style=\"color: #24292E\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>As you can see, it is very easy to add JSON logging to your Spring Boot Application. <\/p>\n\n\n\n<p>This is a very simple example of using JSON logging. The new <a href=\"https:\/\/spring.io\/blog\/2024\/08\/23\/structured-logging-in-spring-boot-3-4\" target=\"_blank\" rel=\"noopener\" title=\"\">Structured Logging feature of Spring Boot<\/a> 3.4.0 is much more robust in capabilities. <\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JSON Logging in Spring Boot simplifies setup, especially for applications in distributed environments like Kubernetes. Consolidated logging requires searchable logs, often formatted in JSON. Logstash is a popular choice. A basic Logback configuration supports JSON logging, aiding development with profile flexibility. Testing can be done by generating log messages easily.<\/p>\n","protected":false},"author":1,"featured_media":8114,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[162,104,1],"tags":[163,29],"class_list":["post-8112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-logback","category-spring-boot","category-uncategorized","tag-logback","tag-spring-boot"],"jetpack_publicize_connections":[],"aioseo_notices":[],"modified_by":"jt","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/springframework.guru\/wp-content\/uploads\/2024\/10\/image.png","jetpack_shortlink":"https:\/\/wp.me\/p5BZrZ-26Q","_links":{"self":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/8112"}],"collection":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/comments?post=8112"}],"version-history":[{"count":4,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/8112\/revisions"}],"predecessor-version":[{"id":8193,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/8112\/revisions\/8193"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/media\/8114"}],"wp:attachment":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/media?parent=8112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/categories?post=8112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/tags?post=8112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}