[
https://issues.apache.org/jira/browse/NIFI-4277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16122095#comment-16122095
]
ASF subversion and git services commented on NIFI-4277:
-------------------------------------------------------
Commit 18c82eb6af6648460365f8db286729629258e95c in nifi's branch
refs/heads/master from [~pvillard]
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=18c82eb ]
NIFI-4277 Fixed exception logging in StandardLogRepository
This closes #2068.
Signed-off-by: Andy LoPresto <[email protected]>
> 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.
> 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)