You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Andrei Ivanov (JIRA)" <ji...@apache.org> on 2018/11/04 17:50:00 UTC

[jira] [Closed] (LOG4J2-2428) Use the AuditExceptionHandler for validation exceptions

     [ https://issues.apache.org/jira/browse/LOG4J2-2428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrei Ivanov closed LOG4J2-2428.
---------------------------------

Seems fine, thank you :)

> 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
>             Fix For: Log4j-Audit 1.0.1
>
>
> 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)