DEV Community

Ed Legaspi
Ed Legaspi

Posted on

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

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

Top comments (1)

Collapse
 
buildbasekit profile image
buildbasekit

This hits a very real pain.

Audit logs are one of those things that start simple with Envers… and then turn into repeated setup, messy queries, and scattered logic across services.

I’ve seen the same pattern with auth and multi-tenancy too — every project ends up rebuilding the same backend foundation.

Feels like we’re slowly moving toward extracting these “repeatable backend layers” into reusable modules instead of rewriting them each time.

Curious — did you consider going beyond Envers and owning the full audit pipeline, or was keeping it as a layer on top a deliberate choice?