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

Issues with setting log level #1183

Closed
juyoungjung0326 opened this issue Oct 2, 2021 · 2 comments
Closed

Issues with setting log level #1183

juyoungjung0326 opened this issue Oct 2, 2021 · 2 comments
Labels

Comments

@juyoungjung0326
Copy link

Hello, I am new to Java Spring Boot and Zalando Logbook and I am not sure if this is the place to post this. I am trying to change the log level of the logger to log at the DEBUG level. However, changing the log level in application.properties to logging.level.org.zalando.logbook: DEBUG the logs do not get recorded in my log file. I see that in the Logger section of the README it says the logger can be customized through:
Logbook logbook = Logbook.builder()
.sink(new DefaultSink(
new DefaultHttpLogFormatter(),
new DefaultHttpLogWriter()
))
.build();
but I am not sure where to go from there.
Is it possible to change the log level of the logger? If so, how would I be able to do this?

Thank you in advance!

@whiskeysierra
Copy link
Collaborator

You'd need to write your own version of DefaultHttpLogWriter which uses isDebugEnabled() and debug(..) respectively:

@Override
public boolean isActive() {
return log.isTraceEnabled();
}
@Override
public void write(final Precorrelation precorrelation, final String request) {
log.trace(request);
}
@Override
public void write(final Correlation correlation, final String response) {
log.trace(response);
}

@juyoungjung0326
Copy link
Author

I got it to work! Thank you so much for your help and fast response! :)

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

2 participants