I Got Tired of Rewriting Audit Logs in Spring Boot — So I Built nerv-audit

java dev.to

Every backend system eventually hits this moment:

“Who changed this record?”
“What was the previous value?”
“When did it happen?”

Simple questions… until you actually need answers in production.


⚠️ Note: The core module is commercial, but you can explore the public modules and examples here:
👉 https://github.com/czetsuyatech/nerv-audit
👉 https://github.com/czetsuyatech/nerv-examples


The Problem

In most of my Spring Boot projects, I relied on Hibernate Envers.

It works—but in real systems, it starts to hurt:

  • You repeat the same setup across services
  • Audit queries are hard to read and maintain
  • Business-level audit logic gets scattered
  • Small mistakes become painful in production

After a few projects, I realized:

I wasn’t building features anymore—I was rebuilding audit infrastructure.


What I Actually Wanted

Not a replacement for Envers.

Just something that:

  • Standardizes audit handling
  • Reduces boilerplate
  • Makes queries readable
  • Works consistently across projects

So I Built nerv-audit

nerv-audit is a lightweight layer on top of Envers that focuses on developer experience.

Instead of wiring everything manually, you get a cleaner way to work with audit data.


Example

Without nerv-audit

You end up dealing with low-level Envers APIs and custom query logic.

With nerv-audit

service.getVerticalAudits(entity, criteria);
Enter fullscreen mode Exit fullscreen mode

That’s it.


Want to see how it's implemented in a real project?
👉 https://github.com/czetsuyatech/nerv-audit
👉 https://github.com/czetsuyatech/nerv-examples


What It Improves

1. Consistent Audit Handling

Define audit behavior once, reuse everywhere.

@AuditedEntity
public class Order {
    private String status;
}
Enter fullscreen mode Exit fullscreen mode

2. Cleaner Queries

No more complex Envers query construction.

You focus on:

  • What changed
  • When it changed

Not how to retrieve it.


3. Less Repetition

Across projects, the pattern is always the same.

nerv-audit abstracts that pattern so you don’t rewrite it every time.


Why I Built This

This came from real production work:

  • Multiple systems
  • Repeated audit requirements
  • Real incidents where audit data mattered

At some point, it made more sense to abstract the solution than keep rebuilding it.


About the Model (Transparency)

nerv-audit is not fully open-source.

  • There is a free tier you can use
  • Some advanced capabilities are part of a paid core

⚠️ Note: The core module is commercial, but you can explore the public modules and examples here:
👉 https://github.com/czetsuyatech/nerv-audit
👉 https://github.com/czetsuyatech/nerv-examples

I chose this approach to:

  • Keep the project sustainable
  • Continue improving it over time
  • Focus on real-world use cases

Who This Is For

This might be useful if you:

  • Build Spring Boot applications
  • Use Hibernate Envers (or plan to)
  • Want a cleaner way to handle audit logs

I’d Like Your Input

How are you handling audit logs today?

  • Pure Envers?
  • Custom implementation?
  • Something else?

I’m especially interested in:

  • Pain points
  • Query challenges
  • Scaling issues

If you're working with Envers, try it out and let me know what breaks—or what works better.


🔗 Resources

Source: dev.to

arrow_back Back to Tutorials