Skip to content
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

Logback config not properly referenced for a self-containing JAR #2256

Closed
MarcelHB opened this issue Feb 16, 2021 · 3 comments
Closed

Logback config not properly referenced for a self-containing JAR #2256

MarcelHB opened this issue Feb 16, 2021 · 3 comments
Labels
Milestone

Comments

@MarcelHB
Copy link

MarcelHB commented Feb 16, 2021

Hello,

When I started to run my Jooby application as a standalone, fat JAR, I noticed that any logging configuration seems to be lost completely. I have something boring as this in the docs:

conf/
  application.conf
  application.prod.conf
  logback.prod.xml
  logback.dev.xml

All files are included in the JAR file and configured as classpath. Anyway, no luck. So I debugged the loading into the respective section of LogConfigurer:

Path userdir = Paths.get(System.getProperty("user.dir"));
Map<String, List<Path>> options = new LinkedHashMap<>();
options.put("logback.configurationFile", logbackFiles(userdir, names));

We see that the files are expected inside of a user.dir location. This is somewhat conflicting to my idea of a self-containing JAR package. I wrote this kind of workaround before initializing the Logger in the Jooby body:

System.setProperty("logback.configurationFile", String.format("logback.%s.xml", getEnvironment().getActiveNames().get(0)));

That's OK for now but I'm wondering whether I've missed something, or if it's worth noting in the docs?

Regards

@MarcelHB MarcelHB changed the title Logback config not properly referenced for a self-containig JAR Logback config not properly referenced for a self-containing JAR Feb 16, 2021
@agentgt
Copy link
Contributor

agentgt commented Sep 9, 2022

It is somewhat documented: https://jooby.io/#configuration-default-environment
Could be better.

And it is definitely documented in the Javadoc.

The reason is probably to allow changing the configuration on the fly as both logback and log4j2 have that ability if it's an actual file and not a classpath resource (well there is some ability in servlet containers but lets ignore that).

It probably should fallback to classpath.

@MarcelHB
Copy link
Author

MarcelHB commented Sep 9, 2022

It is somewhat documented: https://jooby.io/#configuration-default-environment Could be better.

This only mentions application.conf explicitly, and this works as expected by case 3 I guess. That's what made me question why we cannot simply have this for these log configs as well.

@agentgt
Copy link
Contributor

agentgt commented Sep 9, 2022

Oh should probably emphasize more that I agree with you.

Let me inject a mostly postive rant:

If anything I think Jooby should not be in the business of trying to guess logging config like "spring-boot" particularly if it is going to do it its own way.

In fact I have mentioned this once or twice to @jknack how I hope 3.0 just focuses on being the best HTTP REST/MVC library and not "Spring Boot lite". At least 2.0 does not have or depend on an injection framework.

Providing all this support for modules (regardless of how thin they are) as well as even custom logging config brings along technical debt and distraction. Many of the issues are about random modules or extensions.

However I realize there are great merits for the modules/extensions as well as an opinionated convention over configuration particularly for attracting new developers (e.g improving network effect).

@jknack jknack added the bug label Dec 28, 2022
@jknack jknack added this to the 3.0.0.M2 milestone Dec 28, 2022
@jknack jknack closed this as completed in 7d2c463 Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants