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
Ensure Logback is refreshed before application starts #8238
Conversation
I believe this will be fixed by #8235 which moves logback to runtime intiailization |
@graemerocher , with this modification you can keep build time initialization, it just resets all internal logback caches when Micronaut Inits. The issue is that Logback is initialized when JVM Starts. The |
This seems safe enough to target 3.8.x branch, can you do that? |
Done. Can you unblock the CI? I suspect that the test will fail |
not sure why it is blocked 🤔 |
@n0tl3ss this might help with the logging issue for AWS/OCI |
Is there any ETA on this? |
waiting for feedback from @n0tl3ss |
@n0tl3ss , can you help out here? This is currently the only blocker we have to go live with Micronaut |
@driverpt from the looks of the change it seems like you could wire this into your existing application without a new version of Micronaut necessarily blocking you? |
@n0tl3ss , fixed checkstyle issue |
I tried but without success |
please fix the broken tests |
I will, but at the end of the day |
@graemerocher @n0tl3ss , GitHub Workflow needs a maintainers approval to run |
String logbackXml = logbackXmlLocation.orElse(DEFAULT_LOGBACK_LOCATION); | ||
|
||
try { | ||
URL resource = getClass().getClassLoader().getResource(logbackXml); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@graemerocher @n0tl3ss , please review this part. I need your opinion on this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like
@Override
public void refresh() {
getLoggerContext().reset();
try {
new ContextInitializer(getLoggerContext()).autoConfig();
} catch (JoranException e) {
throw new LoggingSystemException("Error while refreshing Logback", e);
}
}
would do a trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is io.micronaut.management.endpoint.loggers.impl.LogbackLoggingSystem
class that might replace io.micronaut.logging.impl.LogbackLoggingSystem
. Should it also override refresh() method?
String logbackXml = logbackXmlLocation.orElse(DEFAULT_LOGBACK_LOCATION); | ||
|
||
try { | ||
URL resource = getClass().getClassLoader().getResource(logbackXml); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like
@Override
public void refresh() {
getLoggerContext().reset();
try {
new ContextInitializer(getLoggerContext()).autoConfig();
} catch (JoranException e) {
throw new LoggingSystemException("Error while refreshing Logback", e);
}
}
would do a trick.
I'm not a fan of copy + paste the same code in 2 classes. What do you suggest? |
@n0tl3ss , were you able to get this "Fix" running smoothly? I've been testing this and it seems like after I call |
@n0tl3ss , can you please test if the logging works in AWS/OCI ? Thanks |
UPDATE: This seems to work in AWS Environment. But the downside is that we will need to add a E.g.: In my case, the |
5430f64
to
fb7eafe
Compare
@graemerocher @n0tl3ss , Checkstyle is failing due to NettyServer.java issue |
Thanks for the contribution! |
Attempts to fix #8139