-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an artifact on Maven Central without kotlin-logger and logback dependencies #1875
Comments
Looks like the issue is solved by not importing The warnings seems to be a different issue. More info here: #1618 |
In case other people find this issue:
|
Hello @paul-dingemans, I have just upgraded to 0.49.0 and unfortunately this issue is back. After bumping the version I had to import this additional dependencies: ktlint-cli-ruleset-core = { module = "com.pinterest.ktlint:ktlint-cli-ruleset-core", version.ref = "ktlint" }
ktlint-rule-engine = { module = "com.pinterest.ktlint:ktlint-rule-engine", version.ref = "ktlint" } in order to be able to import these: import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3
import com.pinterest.ktlint.rule.engine.api.Code
import com.pinterest.ktlint.rule.engine.api.EditorConfigDefaults
import com.pinterest.ktlint.rule.engine.api.KtLintRuleEngine but now my logs are gone again, replaced by this:
I guess the source of the issue is here: The class needed are all inside the package |
I think this is not the same issue you had before. Previously, you received the Currently, the logger just requires any SLF4J implementation to be provided by the API Consumer. Apparently, your project does not provide such a dependency, and as of that it falls back to NOP logger which indeeds results in not displaying any logging. Please try to add any SLF4J logger of your choosing. See example api consumer. |
I'm a little confused: we are providing the following dependencies, shouldn't this be enough? log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" }
log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" }
log4j-slf4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j-impl", version.ref = "log4j" } https://gitlab.com/gtk-kn/gtk-kn/-/blob/feature/ktlint-0.49.0/gradle/libs.versions.toml#L47 Also, one thing that I do not understand is why, after adding the dependency to |
From what I see by running
Full log:
Could this be the issue?
|
Did you mean, that your entire project is missing the logs (e.g. not only ktlint logs are missing)?
Sorry, I don't know. But it would be interesting to know whether the issue is caused by a conflict by having both |
Yes.
I'll test and report back. |
Btw, using both versions shouldn't be in theory an issue: https://github.com/oshai/kotlin-logging#version-4x-vs-previous-versions |
I am not sure, but I have found two occurrences of logging dependencies that are unwanted and may or may not be related to your problem.
I will create a PR to resolve above and merge it to master. I will let you know when it is ready. Will you be able to validate against the snapshot build whether this solves your problem? |
Can you please check whether latest snapshot solves your problem? |
Hi @paul-dingemans, unfortunately not: even with the latest snapshot, logs are completely gone from my app, replaced by these messages:
I still believe that KtLint artifact should ship without dependencies on |
I believe that the way that logging is implemented in ktlint is correct. Ktlint implements logging without depending on a specific implementation of a logger so that the API consumer can freely choose what implementation to use. The last part of your logs includes following:
this matches with the dependency tree that you posted earlier:
This seems to match with the SLF4J FAQ I do not see the slf4j-api:1.7.x dependency in the dependency tree of the sample
Can you investigate why |
I'm not sure if I got the question right, but log4j is in our classpath because it's what we use as logger (see here) and it works fine with KtLint 0.48.0. |
To me it looks that According to https://logging.apache.org/log4j/2.x/log4j-slf4j-impl.html you also might need to replace |
Hey this actually seems to fix the issue! Now the application logs are back and I don't see any additional logs from KtLint 👍 Thanks! PS |
Expected Behavior
I would like to be able to use KtLint and
KtLintRuleEngine
in particular, to format some generated code via KotlinPoet without having the standard output of my application spammed with KtLint Logs or having the having the KtLint logging dependencies breaking the logging of my app.Current Behavior
Currently KtLint depends on
io.github.microutils:kotlin-logging-jvm:3.0.5
andch.qos.logback:logback-classic:1.3.5
, while my app is using the new version4.0.0-beta-23
ofkotlin-logging
andlog4j2
instead oflogback
.When I run
ktLintRuleEngine.format(file.toPath())
, the stdout of my app is spammed with the following logs, one per each file formatted (and I generate thousands of them):Additional information
I've tried to disable the logs with the following code:
This works for the logs form KtLint but, unfortunately, the transient dependencies for
kotlin-logging
andlogback
are still messing with the rest of the logs of the app (I thinkkotlin-logging
is just usinglogback
and ignoring my configuration forlog4j2
).Please consider providing an artifact that can be used to format files from a Java/Kotlin project and that doesn't come with logging dependencies.
EDIT:
I've downgraded
kotlin-logging
to the same version used by KtLint and the logs still don't work.I also get these warnings when I add KtLint as depedency:
The text was updated successfully, but these errors were encountered: