What logs should a D2C brand keep, and for how long?
Which logs a small D2C brand needs from its apps and AWS account, how long to keep them, how to search them during incidents, and how to control logging costs.
Anadoris Digital · · 4 min read

Logs are the record of what your systems did. They are also often the only evidence you have when talking to a payment gateway, a courier or a marketplace about a disputed transaction. When an order goes missing, a customer says they were charged twice, or a login looks suspicious, logs are how you find out what happened. Without them, investigations turn into guesswork and blame.
The challenge for small brands is balance. Log too little and you cannot answer questions. Log everything forever and the bill grows quietly while personal data piles up in places it should not be.
The logs worth keeping
- Application errors: exceptions and failures from your apps, with enough context to reproduce them.
- Business events: order received, order synced, courier booked, refund issued, each with an order number.
- Integration logs: requests to and responses from payment, courier, ERP and marketplace APIs.
- AWS CloudTrail: who did what in your AWS account, including logins and changes to resources.
- Access logs: requests to your CDN, load balancer or APIs, useful for spotting attacks and bots.
- Firewall logs: what AWS WAF or similar tools blocked and why.
- Database logs: slow queries and errors.
How long to keep them
There are two different needs. For troubleshooting, you need recent logs that are fast to search, typically covering the last few weeks. For security investigations, disputes and compliance, you need older logs that can be cheaper and slower to search. In India, CERT-In directions require organisations to maintain certain logs and report certain cyber incidents promptly; check the current directions and take advice on how they apply to your business.
- Set a retention period on every CloudWatch log group; by default logs are kept indefinitely.
- Turn on a CloudTrail trail that stores logs in a dedicated S3 bucket, ideally in a separate account.
- Move older logs to cheaper S3 storage classes with lifecycle rules.
- Delete logs that have passed their retention period, rather than keeping them by default.
- Write your retention choices down so they can be explained to auditors or partners.
Keep personal data out of logs
Logs often capture more than intended: full request bodies with names, phone numbers, addresses, and sometimes tokens or passwords. That turns logs into a store of personal data with weaker protection than your database. Mask or omit sensitive fields at the source, never log passwords, card details or full API keys, and restrict who can read logs. This also supports your obligations under the Digital Personal Data Protection Act.
Make logs useful during an incident
Logs are only valuable if you can find things in them quickly. Write logs in a structured format such as JSON, include an order number or request ID in every relevant line, and use consistent field names across apps. Record times in a single time zone and say which one, because mixing UTC and Indian time is a common source of confusion when comparing logs from different systems. CloudWatch Logs Insights lets you query logs with simple commands. Practise answering a real question, such as 'what happened to order 10234?', so the steps are familiar before you need them under pressure.
Controlling logging costs
Logging costs come from the volume ingested, the volume stored and the queries run. Debug-level logging left on in production is a common cause of surprise bills. Review which apps produce the most log data, reduce noisy messages, and set sensible retention. Check current AWS pricing for log ingestion and storage, and include log groups in your monthly bill review. Sampling can help for very high-volume access logs: keeping a representative share of routine successful requests while recording every error usually preserves what you need for troubleshooting at a fraction of the volume.
Protect the logs themselves
Security logs are only trustworthy if attackers cannot alter or delete them. Send CloudTrail logs to an S3 bucket in a separate account, turn on log file validation, and limit who can change the trail or the bucket's policy. Consider S3 Object Lock for logs you must keep unaltered for a set period.
Restrict access to application logs as well. Developers may need to read them, but very few people need to delete them or change retention. Review that access during your quarterly access review, alongside your other AWS permissions. If you use an outside logging service, apply the same rules there and make sure the account is owned by the brand.
Where to start
Open CloudWatch and check the retention setting on every log group; set one where it says 'never expire'. Confirm CloudTrail is on and saving to S3. Then pick your most important app and make sure every log line about an order includes the order number. Finally, test whether you can trace one recent order from website to warehouse using logs alone. Wherever the trail goes cold, add the missing log line.
Related service: AWS & Cloud Management · More on this topic: AWS & Cloud Management articles
