You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Pierre Villard (JIRA)" <ji...@apache.org> on 2017/08/09 09:43:00 UTC
[jira] [Created] (NIFI-4277) StandardLogRepository does not log
exceptions
Pierre Villard created NIFI-4277:
------------------------------------
Summary: StandardLogRepository does not log exceptions
Key: NIFI-4277
URL: https://issues.apache.org/jira/browse/NIFI-4277
Project: Apache NiFi
Issue Type: Bug
Components: Core Framework
Affects Versions: 1.3.0
Reporter: Pierre Villard
Assignee: Pierre Villard
Attachments: Screen Shot 2017-08-08 at 2.48.33 PM.png
When logging a message, it is logged with the SLF4J logger and also stored in the standard log repository (for the bulletins). However if the array of objects contains the exception (and not the message of the exception), this exception won't be displayed in the bulletin message.
!Screen Shot 2017-08-08 at 2.48.33 PM.png|thumbnail!
That's because of:
{code:title=StandardLogRepository.java|borderStyle=solid}
@Override
public void addLogMessage(final LogLevel level, final String format, final Object[] params) {
final String formattedMessage = MessageFormatter.arrayFormat(format, params).getMessage();
addLogMessage(level, formattedMessage);
}
{code}
If the params object contains a Throwable object, it'll be removed from the array in the {{MessageFormatter}}:
{code:title=MessageFormatter.java|borderStyle=solid}
final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray) {
Throwable throwableCandidate = getThrowableCandidate(argArray);
Object[] args = argArray;
if (throwableCandidate != null) {
args = trimmedCopy(argArray);
}
return arrayFormat(messagePattern, args, throwableCandidate);
}
{code}
Easy solution would be to change:
{noformat}
logger.debug("Failed to validate {} against schema due to {}", new Object[]{flowFile, e});
{noformat}
into:
{noformat}
logger.debug("Failed to validate {} against schema due to {}", new Object[]{flowFile, e.getLocalizedMessage()});
{noformat}
However this pattern can be found in quite a large number of places... And it'd be certainly better to provide a permanent solution supporting the existing pattern. Suggestion is to modify the method in {{StandardLogRepository}} to go through all the items of the array and for each Throwable object, replace it by the localized message.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)