{"id":514,"date":"2026-02-26T08:04:14","date_gmt":"2026-02-26T08:04:14","guid":{"rendered":"https:\/\/iotnoob.com\/wordpress\/?p=514"},"modified":"2026-02-26T08:13:27","modified_gmt":"2026-02-26T08:13:27","slug":"logback-slf4j","status":"publish","type":"post","link":"https:\/\/iotnoob.com\/wordpress\/2026\/02\/26\/logback-slf4j\/","title":{"rendered":"Logback &#8211; SLF4J"},"content":{"rendered":"\n<p>simple project \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e17\u0e14\u0e25\u0e2d\u0e07\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 Logback \u0e1a\u0e19 simple log formatter for Java (SLF4J)<br>\u0e42\u0e14\u0e22\u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23 \u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19 SLF4J \u0e40\u0e1b\u0e47\u0e19\u0e21\u0e32\u0e15\u0e23\u0e32\u0e10\u0e32\u0e19 \u0e2a\u0e48\u0e27\u0e19 Logback \u0e19\u0e31\u0e1a\u0e40\u0e1b\u0e47\u0e19 implementor<\/p>\n\n\n\n<p>\u0e02\u0e31\u0e49\u0e19\u0e41\u0e23\u0e01 \u0e40\u0e23\u0e32\u0e01\u0e47 add dependencies \u0e40\u0e2b\u0e25\u0e48\u0e32\u0e19\u0e35\u0e49<\/p>\n\n\n\n<p>implementation &#8216;org.slf4j:slf4j-api:2.0.12&#8217;<br>\/\/ Logback (The Implementation &#8211; \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07 Binding)<br>implementation &#8216;ch.qos.logback:logback-classic:1.4.14&#8217;<br>\/\/ \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a Project \u0e40\u0e01\u0e48\u0e32\u0e17\u0e35\u0e48\u0e43\u0e0a\u0e49 Log4j 1.x (\u0e16\u0e49\u0e32\u0e21\u0e35) \u0e40\u0e1e\u0e37\u0e48\u0e2d Bridge \u0e44\u0e1b SLF4J<br>\/\/ implementation &#8216;org.slf4j:log4j-over-slf4j:2.0.12&#8217;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\n * This file was generated by the Gradle 'init' task.\n *\n * This generated file contains a sample Java application project to get you started.\n * For more details on building Java &amp; JVM projects, please refer to https:\/\/docs.gradle.org\/9.3.1\/userguide\/building_java_projects.html in the Gradle documentation.\n *\/\n\nplugins {\n    \/\/ Apply the application plugin to add support for building a CLI application in Java.\n    id 'application'\n    id(\"com.gradleup.shadow\") version \"9.3.1\"\n}\n\nrepositories {\n    \/\/ Use Maven Central for resolving dependencies.\n    mavenCentral()\n}\n\ndependencies {\n    \/\/ Use JUnit Jupiter for testing.\n    testImplementation libs.junit.jupiter\n\n    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'\n\n    \/\/ This dependency is used by the application.\n    implementation libs.guava\n\n    \/\/ SLF4J API (The Facade)\n    implementation 'org.slf4j:slf4j-api:2.0.12' \n    \n    \/\/ Logback (The Implementation - \u0e23\u0e27\u0e21\u0e16\u0e36\u0e07 Binding)\n    implementation 'ch.qos.logback:logback-classic:1.4.14' \n\n    \/\/ \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a Project \u0e40\u0e01\u0e48\u0e32\u0e17\u0e35\u0e48\u0e43\u0e0a\u0e49 Log4j 1.x (\u0e16\u0e49\u0e32\u0e21\u0e35) \u0e40\u0e1e\u0e37\u0e48\u0e2d Bridge \u0e44\u0e1b SLF4J\n    \/\/ implementation 'org.slf4j:log4j-over-slf4j:2.0.12'\n\n}\n\n\/\/ Apply a specific Java toolchain to ease working on different environments.\njava {\n    toolchain {\n        languageVersion = JavaLanguageVersion.of(21)\n    }\n}\n\napplication {\n    \/\/ Define the main class for the application.\n    mainClass = 'com.imm.UmgTest.App'\n}\n\ntasks.named('test') {\n    \/\/ Use JUnit Platform for unit tests.\n    useJUnitPlatform()\n}\n<\/pre>\n\n\n\n<p>\u0e08\u0e32\u0e01\u0e19\u0e31\u0e49\u0e19 \u0e43\u0e19\u0e2b\u0e49\u0e2d\u0e07 resource \u0e2a\u0e23\u0e49\u0e32\u0e07\u0e44\u0e1f\u0e25\u0e4c logback.xml<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?>\n&lt;configuration>\n\n    &lt;property name=\"LOG_PATTERN\" \n              value=\"[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{script.name}] [%X{username}] [%line] [%-5level] [%logger] -> %msg%n\" \/>\n\n    &lt;appender name=\"SIFTING_LOG\" class=\"ch.qos.logback.classic.sift.SiftingAppender\">\n\n        &lt;discriminator>\n            &lt;key>username&lt;\/key>\n            &lt;defaultValue>system&lt;\/defaultValue>\n        &lt;\/discriminator>\n\n        &lt;sift>\n            &lt;appender name=\"FILE-${username}\" class=\"ch.qos.logback.core.rolling.RollingFileAppender\">\n                \n                &lt;file>logs\/${username}\/${username}.log&lt;\/file> \n\n                &lt;rollingPolicy class=\"ch.qos.logback.core.rolling.TimeBasedRollingPolicy\">\n                    &lt;fileNamePattern>logs\/${username}\/archive\/${username}-%d{yyyy-MM-dd}.log&lt;\/fileNamePattern>\n                    &lt;maxHistory>30&lt;\/maxHistory>\n                &lt;\/rollingPolicy>\n\n                &lt;encoder>\n                    &lt;pattern>${LOG_PATTERN}&lt;\/pattern>\n                &lt;\/encoder>\n\n            &lt;\/appender>\n        &lt;\/sift>\n    &lt;\/appender>\n\n    &lt;root level=\"info\">\n        &lt;appender-ref ref=\"SIFTING_LOG\" \/>\n        &lt;\/root>\n\n&lt;\/configuration>\n<\/pre>\n\n\n\n<p>logs\/${username}\/${username}.log<br>\u0e0a\u0e37\u0e48\u0e2d log file \u0e16\u0e49\u0e32\u0e44\u0e21\u0e48\u0e01\u0e33\u0e2b\u0e19\u0e14 user \u0e43\u0e14\u0e46 \u0e21\u0e32 \u0e08\u0e30\u0e16\u0e39\u0e01\u0e40\u0e01\u0e47\u0e1a\u0e2d\u0e22\u0e39\u0e48\u0e17\u0e35\u0e48 logs\/system\/system.log<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"190\" src=\"https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-13.png\" alt=\"\" class=\"wp-image-516\" srcset=\"https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-13.png 725w, https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-13-300x79.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/figure>\n\n\n\n<p>\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07 logback configuration \u0e40\u0e01\u0e47\u0e1a\u0e44\u0e27\u0e49\u0e17\u0e35\u0e48\u0e2b\u0e49\u0e2d\u0e07 resource \u0e14\u0e49\u0e32\u0e19\u0e19\u0e2d\u0e01\u0e40\u0e25\u0e22<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"392\" height=\"254\" src=\"https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-12.png\" alt=\"\" class=\"wp-image-515\" srcset=\"https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-12.png 392w, https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-12-300x194.png 300w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/figure>\n\n\n\n<p>\u0e43\u0e19 file code java \u0e02\u0e2d\u0e07\u0e40\u0e23\u0e32 \u0e01\u0e47\u0e40\u0e23\u0e35\u0e22\u0e01\u0e43\u0e0a\u0e49\u0e44\u0e14\u0e49\u0e40\u0e25\u0e22<\/p>\n\n\n\n<p>private static final Logger logger = LoggerFactory.getLogger(App.class);<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\n * This source file was generated by the Gradle 'init' task\n *\/\npackage com.imm.UmgTest;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.slf4j.MDC;\n\npublic class App {\n    \n    private static final Logger logger = LoggerFactory.getLogger(App.class);\n    \n    public String getGreeting() {\n        logger.info(\"ABC {}, {}, {}\", \"a\", 2, 3);\n        return \"Hello World!\";\n    }\n\n    public static void main(String[] args) {\n        System.out.println(new App().getGreeting());\n    }\n}\n<\/pre>\n\n\n\n<p>[2026-02-26 14:34:05.905] [main] <strong>[] []<\/strong> [17] [INFO ] [com.imm.UmgTest.App] -> ABC a, 2, 3<\/p>\n\n\n\n<p>\u0e40\u0e23\u0e32\u0e22\u0e31\u0e07\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e40\u0e1e\u0e34\u0e48\u0e21 \u0e15\u0e31\u0e27\u0e41\u0e1b\u0e23 \u0e2b\u0e23\u0e37\u0e2d\u0e04\u0e48\u0e32\u0e40\u0e09\u0e1e\u0e32\u0e30\u0e1a\u0e32\u0e07\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e40\u0e02\u0e49\u0e32\u0e44\u0e1b\u0e43\u0e19 log \u0e44\u0e14\u0e49\u0e14\u0e49\u0e27\u0e22 MDC<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/*\n * This source file was generated by the Gradle 'init' task\n *\/\npackage com.imm.UmgTest;\n\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\nimport org.slf4j.MDC;\n\npublic class App {\n    \n    private static final Logger logger = LoggerFactory.getLogger(App.class);\n    \n    public String getGreeting() {\n        MDC.put(\"username\", \"Thada\"); \n        MDC.put(\"script.name\", \"output.drill\"); \n        logger.info(\"ABC {}, {}, {}\", \"a\", 2, 3);\n        MDC.remove(\"script.name\");\n        MDC.remove(\"username\"); \n        return \"Hello World!\";\n    }\n\n    public static void main(String[] args) {\n        System.out.println(new App().getGreeting());\n    }\n}\n<\/pre>\n\n\n\n<p>[2026-02-26 14:33:01.179] [main]<strong> [output.drill] [Thada] <\/strong>[17] [INFO ] [com.imm.UmgTest.App] -> ABC a, 2, 3<\/p>\n\n\n\n<p>\u0e40\u0e21\u0e37\u0e48\u0e2d\u0e21\u0e35\u0e01\u0e32\u0e23\u0e01\u0e33\u0e2b\u0e19\u0e14 \u0e0a\u0e37\u0e48\u0e2d username \u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e1f\u0e25\u0e4c\u0e41\u0e25\u0e30\u0e15\u0e33\u0e41\u0e2b\u0e19\u0e48\u0e07\u0e01\u0e47\u0e08\u0e30\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19 \u0e08\u0e32\u0e01 logs\/system\/system.log \u0e40\u0e1b\u0e47\u0e19 logs\/Thada\/Thada.log<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"162\" src=\"https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-14.png\" alt=\"\" class=\"wp-image-517\" srcset=\"https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-14.png 605w, https:\/\/iotnoob.com\/wordpress\/wp-content\/uploads\/2026\/02\/image-14-300x80.png 300w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/figure>\n\n\n\n<p>More info \u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a pattern \u0e02\u0e2d\u0e07 log \u0e41\u0e25\u0e30\u0e0a\u0e37\u0e48\u0e2d\u0e44\u0e1f\u0e25\u0e4c<br><a href=\"https:\/\/logback.qos.ch\/manual\/layouts.html\">https:\/\/logback.qos.ch\/manual\/layouts.html<\/a><br><a href=\"https:\/\/logback.qos.ch\/manual\/configuration.html\">https:\/\/logback.qos.ch\/manual\/configuration.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>simple project \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e17\u0e14\u0e25\u0e2d\u0e07\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19 Logback \u0e1a\u0e19 simple log formatter for Java (SLF4J)\u0e42\u0e14\u0e22\u0e2b\u0e25\u0e31\u0e01\u0e01\u0e32\u0e23 \u0e40\u0e2b\u0e21\u0e37\u0e2d\u0e19 SLF4J \u0e40\u0e1b\u0e47\u0e19\u0e21\u0e32\u0e15\u0e23\u0e32\u0e10\u0e32\u0e19 \u0e2a\u0e48\u0e27\u0e19&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-514","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts\/514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/comments?post=514"}],"version-history":[{"count":2,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts\/514\/revisions"}],"predecessor-version":[{"id":520,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/posts\/514\/revisions\/520"}],"wp:attachment":[{"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/media?parent=514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/categories?post=514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotnoob.com\/wordpress\/wp-json\/wp\/v2\/tags?post=514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}