nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre Villard (JIRA)" <>
Subject [jira] [Created] (NIFI-4277) StandardLogRepository does not log exceptions
Date Wed, 09 Aug 2017 09:43:00 GMT
Pierre Villard created NIFI-4277:

             Summary: StandardLogRepository does not log exceptions
                 Key: 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

!Screen Shot 2017-08-08 at 2.48.33 PM.png|thumbnail!

That's because of:

    public void addLogMessage(final LogLevel level, final String format, final Object[] params)
        final String formattedMessage = MessageFormatter.arrayFormat(format, params).getMessage();
        addLogMessage(level, formattedMessage);

If the params object contains a Throwable object, it'll be removed from the array in the {{MessageFormatter}}:

    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);

Easy solution would be to change:

logger.debug("Failed to validate {} against schema due to {}", new Object[]{flowFile, e});


logger.debug("Failed to validate {} against schema due to {}", new Object[]{flowFile, e.getLocalizedMessage()});

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

View raw message