Title: Avoid the fat-slf4j-jar and solve the logging issue in a better way · Issue #202 · git-commit-id/git-commit-id-maven-plugin · GitHub
Open Graph Title: Avoid the fat-slf4j-jar and solve the logging issue in a better way · Issue #202 · git-commit-id/git-commit-id-maven-plugin
X Title: Avoid the fat-slf4j-jar and solve the logging issue in a better way · Issue #202 · git-commit-id/git-commit-id-maven-plugin
Description: Hi @ktoso, before I start working on this issue I wanted to recheck some couple of details. With Issue #191 we got the Request that the plugin ignores MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn I have introduced the slf4j-d...
Open Graph Description: Hi @ktoso, before I start working on this issue I wanted to recheck some couple of details. With Issue #191 we got the Request that the plugin ignores MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLog...
X Description: Hi @ktoso, before I start working on this issue I wanted to recheck some couple of details. With Issue #191 we got the Request that the plugin ignores MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLog...
Opengraph URL: https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/202
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Avoid the fat-slf4j-jar and solve the logging issue in a better way","articleBody":"Hi @ktoso,\nbefore I start working on this issue I wanted to recheck some couple of details.\nWith Issue https://github.com/ktoso/maven-git-commit-id-plugin/issues/191 we got the Request that the plugin ignores `MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn`\nI have introduced the slf4j-dependency with https://github.com/ktoso/maven-git-commit-id-plugin/pull/194.\nHowever we got some class loading issue with some of the maven versions (https://github.com/ktoso/maven-git-commit-id-plugin/issues/196, https://github.com/ktoso/maven-git-commit-id-plugin/issues/198), which we fixed by creating a uber-jar (https://github.com/ktoso/maven-git-commit-id-plugin/pull/197).\n\nI just want to quickly recap what I could figure out during the phase I reported this to Maven (https://issues.apache.org/jira/browse/MNG-5835)\nLet's start with the fact that `MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn mvn clean package` and `mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=warn` are two complete different things :-)\nThe main fact is that the `MavenCli` considers the `-D` arguments passed to Maven after the SLF4J logger has already been initialised.\n\nI think it's better to illustrate this with an example what the original problem was and what this all means:\nLet's start with a simple Mojo just using the `getLog()`-Method for logging.\nThis will take care for `MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn mvn clean package`. However it will ignore the `-D` arguments passed to Maven (so it will ignore `mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=warn`).\n`java\n// plugin one\npublic void execute() {\n getLog().info(\"Info-Message: Hello, world.\");\n}\n`\nLet's now move to a simple Mojo that create the `getLog()` outside the execute and will store it as a variable (that was the way the git-commit-id-plugin had done it's logging). The Problem here as outline in (https://issues.apache.org/jira/browse/MNG-5835)\n`\nIf you call getLog() in your constructor then you'll get an instance of SystemStreamLog that unconditionally logs to System.out. Your mojo will be wired with an SLF4J-backed logger after construction.\nCall getLog() during the execute() method, and don't cache the value.\n`\nSo in general this will ignore `MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn mvn clean package` (as reported). It will also ignore the `-D` arguments passed to Maven (so it will ignore `mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=warn`).\n\n`java\n// plugin two\nprivate final Log logger = getLog();\npublic void execute() {\n logger.info(\"Info-Message: Hello, world.\");\n}\n`\n\nWe currently have the third option available on the market.\nIt used the the slf4-dependencies and wires itself to the slfj-simple-logger.\nOur current solution takes care for `MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLogLevel=warn mvn clean package` and also takes care of `-D` arguments passed to Maven (so it will NOT ignore `mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=warn`).\n\nThe essence is if there is no one is using the `mvn clean package -Dorg.slf4j.simpleLogger.defaultLogLevel=warn`-Option we can just drop the fat-slf4j-jar and the dependencies to slf4j and will let `getLog` take care of the rest. However also outline in https://issues.apache.org/jira/browse/MNG-5835 it may be a bad idea to store to logger somewhere (in the LoggerBridge). I currently don't have a valid reason why not saving it somewhere, but this somehow we definitely need to test.\nQuestions/comments are welcome :-)\n","author":{"url":"https://github.com/TheSnoozer","@type":"Person","name":"TheSnoozer"},"datePublished":"2015-06-16T08:59:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/202/git-commit-id-maven-plugin/issues/202"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6b20ce6c-240c-63fe-f0eb-3dfe5304272b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B3A0:26FDC0:6EB12D:8C84E0:699004ED |
| html-safe-nonce | c23a06fa4547bc25346e34b7bee42ea51ec972af7897d69800ee8674c7d75fa0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0EwOjI2RkRDMDo2RUIxMkQ6OEM4NEUwOjY5OTAwNEVEIiwidmlzaXRvcl9pZCI6IjgyMjYzMzE1NjkwMTM0MDM5NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0888449876cd62ef1becda140379031d7479b5caaf41d90cdae38f6b190a7b57 |
| hovercard-subject-tag | issue:88664766 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/git-commit-id/git-commit-id-maven-plugin/202/issue_layout |
| twitter:image | https://opengraph.githubassets.com/16ba413435fbdd0553b1b9a2bc3859ec3ffb51701f90495b9ec2ed64079ba233/git-commit-id/git-commit-id-maven-plugin/issues/202 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/16ba413435fbdd0553b1b9a2bc3859ec3ffb51701f90495b9ec2ed64079ba233/git-commit-id/git-commit-id-maven-plugin/issues/202 |
| og:image:alt | Hi @ktoso, before I start working on this issue I wanted to recheck some couple of details. With Issue #191 we got the Request that the plugin ignores MAVEN_OPTS=-Dorg.slf4j.simpleLogger.defaultLog... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TheSnoozer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/git-commit-id/git-commit-id-maven-plugin git https://github.com/git-commit-id/git-commit-id-maven-plugin.git |
| octolytics-dimension-user_id | 43124426 |
| octolytics-dimension-user_login | git-commit-id |
| octolytics-dimension-repository_id | 1361792 |
| octolytics-dimension-repository_nwo | git-commit-id/git-commit-id-maven-plugin |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1361792 |
| octolytics-dimension-repository_network_root_nwo | git-commit-id/git-commit-id-maven-plugin |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width