frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Ask HN: How do you handle audit logs in your systems?

16•efeoge•1d ago
I'm working on designing audit logging for a system that needs to track actions like data changes, user access, and administrative operations. The goal is to ensure traceability, support compliance, and assist with incident response.

I'm curious how others handle this in production:

- What data do you log?

- How do you structure audit logs (JSON, text, DB records)?

- How do you ensure logs are immutable/tamper-evident?

- Do you store them separately from application logs?

- What tooling or patterns have worked well (or poorly) for you?

Any war stories, best practices, or pitfalls to avoid would be really appreciated.

Comments

journal•1d ago
log minimum most important first. timestamp, path, user, and exception messages. don't implement update or delete. prefer storing logs outside the system. are you logging for debugging or audit purposes? can you do both in one place? and log the response code.
mrkeen•1d ago
First hypothetical: If your "audit" logging suggests a different reality than your database, which one should you trust?
tianqi•1d ago
I personally would not assume that there is a question of ‘which one to trust’. In this case I would know that something has gone wrong and use both of these two as clues only to find the root cause which made them different.
ravshan•1d ago
We store in mongodb, we just store api calls as: RequestId, Date, UserId, UserIP, UserRole, HandlerMachineIP, TheRequestBody, TheResponseBody/Error(if anything happened)
gethly•1d ago
I use event sourcing so that itself serves as audit log.
mrngm•1d ago
Relatable recent thread https://news.ycombinator.com/item?id=44602532 "When root meets immutable: OpenBSD chflags vs. log tampering" (153 points, 45 comments).

Not to necessarily focus on the operating system used, but think of the attacker model and risk appetite of the organisation. What are the required integrity goals? What retention do you (legally) require? Who should be able to access those logs; on their own, or n-eye principle? Do such accesses need to be logged as well? What are the requirements from the users of the audit log?

The things you'll need to log will become clear after answering such questions. How you structure them depends on the required access patterns. Tamper evidence can be achieved in many ways, but that depends on the integrity requirements; is an empty log line where one should have been enough "tamper evident"? Do you need some sort of verification mechanism that confirms the log lines you see were stored in that order?

If your log only persists on the machine where it originated, does that satisfy integrity requirements?

BrunoBernardino•6h ago
Here's a redacted example interface in TypeScript for something important. It's added to a PostgreSQL database. The "extra" field is a common pattern I use, with JSON, for fields that are frequently added later that don't require indexes or as much data integrity as the other fields, so a migration isn't necessary:

https://gist.github.com/BrunoBernardino/df806e3e902017308abf...

Hope it helps!

_kb•3h ago
I can’t help with all those queries, but a nice pattern I was introduced to a while back for integrity checks is to have the logging service embed a hash of message N in message N+1. This creates a simple Merkle tree that you can use to detect any omissions or manipulation of and flag. It’s minimal overhead and trivial to implement in any logging backend.

Ask HN: How will the OSA affect small Mastadon instances?

6•Digit-Al•56m ago•0 comments

Claude Code weekly rate limits

567•thebestmoshe•19h ago•647 comments

Ask HN: Does Claude AI run locally?

2•kvthweatt•2h ago•1 comments

Ask HN: What are you working on? (July 2025)

251•david927•1d ago•814 comments

Have We Stopped Inventing Futures Worth Predicting?

4•squarekernels•5h ago•1 comments

How do I get a paid internship as a 16yo developer?

8•uint23•12h ago•18 comments

Drafting Software Recommendation

15•morpheos137•4d ago•16 comments

Warp.dev Terminal – Overpriced, Buggy, and AI-Sabotaged My Code

53•MistermanX•1d ago•37 comments

Ask HN: How many of you are working in tech without a STEM degree?

51•zebproj•6d ago•77 comments

My Theory: Advertising is a lot like capitalism itself

8•cm2012•18h ago•9 comments

Ask HN: Has your opinion on AI changed over the past year?

4•atleastoptimal•15h ago•11 comments

Ask HN: Is there any LLM provider that is GDPR compliant?

6•pera•15h ago•1 comments

Are we building AI coding assistants wrong?

2•anaempromptu•19h ago•3 comments

Ask HN: How do you handle audit logs in your systems?

16•efeoge•1d ago•8 comments

Ask HN: Have you ever waited for a project to be launched but it never did?

3•alganet•20h ago•3 comments

How to prioritize marketing when attribution is broken and AI is changing rules?

3•ivanmarketingua•1d ago•1 comments

Ask HN: What is Lex Fridman's association with MIT?

11•chirau•9h ago•7 comments

Ask HN: Do You Block DigitalOcean?

10•sugarpimpdorsey•1d ago•8 comments

Ask HN: Will I get left behind if I don't jump on AI train?

21•LLcolD•2d ago•32 comments

Ask HN: How do you build B2B software that pays living expenses?

10•architectofsw•1d ago•7 comments

Ask HN: Why do Cursor, Windsurf and Claude Code dominate the conversation?

28•bluelightning2k•1w ago•38 comments

Ask HN: What is so good about MCP servers?

43•metadat•4d ago•38 comments

FreeToolSuite – 200 growing collection of genuinely useful free online tools

25•mviradia•2d ago•4 comments

Ask HN: Are we pretending RAG is ready, when it's barely out of demo phase?

11•TXTOS•2d ago•10 comments

Ask HN: Discrete Mathematics Preriquisites for Data Structures?

3•shivajikobardan•2d ago•1 comments

I'm Peter Roberts, immigration attorney who does work for YC and startups. AMA

164•proberts•1w ago•266 comments

Ask HN: What's your uv exit strategy?

12•ctoth•1d ago•8 comments

Ask HN: Engineers deserve better recognition. Can a protocol change that?

7•mzk_pi•1d ago•16 comments

Ask HN: Why is virtualization still not solved?

16•prmph•3d ago•30 comments

Ask HN: Who is looking for a cofounder in London?

10•warthog•2d ago•4 comments