0

I used the Logback Audit to persist the entity object into database. It was success. But I want to add some audit information into a audit table without using a Entity class. I used the bellow code snippet to add some date into table, but it did not work out.

AuditorFactory.setApplicationName("AuditLogger");
new AuditorFacade("AAA", "BBB", "CCC").audit();

I want to use hibernate, but I am not sure how to do the hibernate configuration for this scenario. I just create the hibernate property file and put it in the class path, but it did not help me.

When we use the Logback audit functionality, please let me know what kind of configuration we have to do and how this application will communicate with database.

Java-Seekar
  • 1,720
  • 5
  • 30
  • 52

1 Answers1

0

I assume that you already deployed audit server war on a server and it is successfully running. For the client application, you need to have this dependency:

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>audit-client</artifactId>
    <version>0.6</version>
</dependency>

In your client's src/main/resources/AuditLogger (you need to create a folder with the application name you set in AuditorFactory), you should have logback-audit.xml with this content:

<auditor>
 <appender name="server" class="ch.qos.logback.audit.client.net.SocketAuditAppender">
   <!-- the host that you deployed the audit-server war -->
   <remoteHost>localhost</remoteHost>
   <!-- do not change this port -->
   <port>9630</port>
 </appender>
</auditor>

One more thing, use version 1.0.11 for other logback artifacts. I was getting an exception when I used a newer version.

logback-audit documentation (explains how you create audit-server war as well)

logback-audit source repository

burcakulug
  • 517
  • 6
  • 17