You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/11/04 06:50:00 UTC
[jira] [Commented] (LOG4J2-2428) Use the AuditExceptionHandler for
validation exceptions
[ https://issues.apache.org/jira/browse/LOG4J2-2428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16674316#comment-16674316 ]
ASF subversion and git services commented on LOG4J2-2428:
---------------------------------------------------------
Commit 06dbe88948259bff82ffe91a6feb62983adde10a in logging-log4j-audit's branch refs/heads/master from [~aivanov93]
[ https://git-wip-us.apache.org/repos/asf?p=logging-log4j-audit.git;h=06dbe88 ]
LOG4J2-2428: pass the event handler defined on the factory to the events
> Use the AuditExceptionHandler for validation exceptions
> -------------------------------------------------------
>
> Key: LOG4J2-2428
> URL: https://issues.apache.org/jira/browse/LOG4J2-2428
> Project: Log4j 2
> Issue Type: Improvement
> Components: Log4j-Audit
> Affects Versions: Log4j-Audit 1.0.0
> Reporter: Andrei Ivanov
> Priority: Major
>
> Since I don't want the audit exceptions to stop the execution of the application code, I've tried defining a simple {{AuditExceptionHandler}} that just logs the exceptions.
> The {{AuditExceptionHandler}} is invoked currently only to handle exceptions caused by the {{logEvent}} method, but it would be nice to use it for the validation exceptions as well.
> Otherwise my logging code looks like this:
> {code:java}
> try {
> logCashPaymentOut(result);
> } catch (Exception e) {
> // log exception here
> }
> private void logCashPaymentOut(SalesTransaction salesTransaction) {
> CashPaymentOut event = LogEventFactory.getEvent(CashPaymentOut.class);
> event.setSalesTransaction(salesTransaction.getUuid());
> event.setAmount(salesTransaction.getReturn().getAmount());
> event.setCurrency(salesTransaction.getReturn().getCurrency().name());
> event.setCurrency("Cash return");
> event.logEvent();
> }
> {code}
> And I want to get rid of the try/catch blocks that are now needed because the setters can trigger exceptions too.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)