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

SLF4J_MANUALLY_PROVIDED_MESSAGE should be ignored for TRACE and DEBUG #31

Closed
melloware opened this issue Jan 7, 2014 · 4 comments
Closed
Assignees
Milestone

Comments

@melloware
Copy link

In certain scenarios we want to log a DEBUG of just the localized message and not the full stack trace...

  } catch (BusinessException e) {
     final String localizedMessage = e.getLocalizedMessage();
     LOG.debug("Reporting BusinessException for method {}: {}", new Object[] { methodName, localizedMessage });

We are getting the SLF4J_MANUALLY_PROVIDED_MESSAGE error. Maybe that should only be for INFO and higher or WARN and higher?

@KengoTODA
Copy link
Owner

Hi @melloware, thanks for your contribution and sorry for my delay.

Could you explain why you don't log stacktrace of e? To keep your log short? It might help me to understand your request.

I will consider how to support this case, but I think, switching by log level isn't cool because logging policy (when/how to use each level) depends on project. Currently I think it is better to switch by existence of e like below.

// invalid: duplicated message will be logged.
LOG.debug("Reporting BusinessException for method {}: {}", new Object[] { methodName, localizedMessage, e });
// valid: message will be logged only once.
LOG.debug("Reporting BusinessException for method {}: {}", new Object[] { methodName, localizedMessage });

@melloware
Copy link
Author

My thought was this was an Exception that the user is going to have displayed as some sort of ValidationException or BusinessException. I want to log a single line in the log file just to let the log know this error is going back to the user but since its not a "true" exception I don't want the whole stack trace. Because then the logs get filled with stacktraces for basically validation errors.

That was my only thought.

@KengoTODA KengoTODA self-assigned this Feb 18, 2014
@KengoTODA
Copy link
Owner

OK, I got it. Then it is better to switch by existence of e.
Thanks for your feedback, I'll try to implement it.

@KengoTODA KengoTODA added this to the 1.2.0 milestone Jul 18, 2015
@KengoTODA
Copy link
Owner

@melloware
Today I have released version 1.2.0 and it will be deployed onto Maven central soon.
Could you try this version? It should be solution for your case.

Note that I tested 1.2.0 on Java 8. If your product depends on Java 7 or older one, it might have problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants