Security Logging for Incident Investigation: The Logs You Need Before You Need Them
The first hour of an incident is full of questions. When did it start? Which accounts were used? Which servers did the attacker touch? Did any data leave? Every one of those questions is answered with logs, and if the logs were never collected, were kept for too short a time or were deleted by the attacker, the honest answer is "we don't know".
That answer is expensive. It turns a contained incident into a broad one, because you have to assume the worst for every system you cannot clear. A recent software supply chain incident made the point plainly: the vendor told customers that a missing log entry did not prove a server was unaffected. Without evidence, "probably fine" is not a conclusion you can defend.
This guide covers which logs matter most for incident investigation, how long to keep them, how to protect them and how to test that they will actually help on the day you need them.
Why logs decide the investigation
Attackers rarely announce themselves on day one. Mandiant's M-Trends 2026 report puts the global median dwell time, the time between intrusion and detection, at 14 days, up from 11 the year before. And that is the median: plenty of intrusions last much longer.
Two practical consequences follow:
- Your retention has to reach back further than the intrusion. If you keep seven days of authentication logs and the attacker arrived three weeks ago, the most important evidence is already gone.
- Scoping depends on coverage. To say "this server was not affected" you need logs from that server. Every gap becomes a system you have to treat as compromised, rebuild or explain to a regulator.
Logs are also what turns a vague alert into a confirmed incident. Without them, the decisions in your severity and escalation model are made on guesswork.
Which logs answer the most questions
You cannot log everything at full detail forever, so start with the sources that answer the questions investigators always ask.
Identity
Sign-ins (successful and failed), MFA events, password resets, new accounts, group and role changes, and new application consents or API tokens. Most intrusions involve valid credentials at some point, and identity logs show who did what, from where.
Endpoints and servers
Process creation with command lines, script execution (PowerShell, shell history where available), new services and scheduled tasks or cron jobs, and changes to local accounts and SSH keys. EDR telemetry usually covers much of this; on servers without EDR, make sure the operating system's own audit logging is enabled.
Network edge
VPN and remote access gateways, firewalls, DNS queries and web proxy logs. These show where an attacker came from and where data went. Internet-facing devices are a frequent initial access point, so their logs are often the first ones an investigator asks for.
Cloud and SaaS control planes
Administrative activity in your cloud providers and in core SaaS platforms such as email and collaboration suites. In many cloud incidents there is no malware at all: the attacker uses the console or the API with stolen credentials.
Critical applications and data stores
Access to sensitive data, administrative actions, bulk exports and database authentication. These are the logs that answer "did data leave?", which is the question that drives notification duties.
Change and software updates
Software installs, updates and configuration changes on critical systems. When a trusted update channel is abused, the record of what was installed, when and where is how you find the affected machines.
How long to keep them
There is no single right number, but there is a useful rule: keep searchable logs longer than a realistic dwell time, and archive them for longer than a realistic investigation.
Regulation sets some floors. PCI DSS v4.0, for example, requires organizations to retain audit log history for at least 12 months, with at least the most recent three months immediately available for analysis (requirement 10.5.1). That split between "hot" searchable storage and cheaper archive is a sensible pattern even outside payment environments.
If you are in a regulated sector, check your own obligations as well: frameworks such as NIS2 and DORA expect you to report incidents quickly, which you cannot do accurately without evidence.
The four principles from CISA and partners
In August 2024, the Australian Signals Directorate, CISA and international partners published Best practices for event logging and threat detection. It is organized around four key factors:
- An enterprise-approved logging policy. Decide what is logged, where and for how long, and get it approved so it survives budget reviews.
- Centralized log collection and correlation. Logs scattered across devices are hard to search and easy to lose. Send them to a central platform, such as a SIEM, where they can be correlated.
- Log integrity, including secure storage. Protect logs from tampering and deletion.
- A detection strategy for relevant threats. Collecting logs is not the goal; using them to detect and investigate is.
Protect the logs from the attacker
An attacker with administrative access will often try to clear logs. A few measures make that much harder:
- Forward logs off the host as they are generated, so a local wipe does not erase the central copy.
- Store the central copy with separate credentials and, where possible, immutable or write-once retention.
- Alert on logging being disabled, audit policies changing or log volume from a source suddenly dropping to zero.
Get the time right
An investigation is a timeline. If one server is four minutes ahead and another uses local time without a time zone, correlating events becomes slow and error-prone. Synchronize clocks from designated time servers and record timestamps in UTC; PCI DSS requirement 10.6 sets out the same expectation.
Test before the incident
The cheapest way to find gaps is to ask the questions now. In your next tabletop exercise, pick a real server and a real user and try to answer:
- Who signed in to this server in the last 30 days, and from where?
- What software was installed or updated on it last month?
- Which commands ran with administrative rights yesterday?
- Did this account access sensitive data or create new credentials?
If any answer is "we can't tell", you have found your next logging task. Add the exercise to your incident response plan so it is repeated.
Common pitfalls
- Logging only what the tool enables by default. Many defaults leave out command lines, script execution or administrative actions.
- Short hot retention to save cost, with no archive. Cheap archive storage is far less expensive than an investigation without evidence.
- Logs nobody reads. Without a detection strategy, logs only help after the fact.
- No owner. Logging coverage decays as systems change unless someone is responsible for it.
Frequently asked questions
How long should we keep security logs? Longer than a realistic dwell time for searchable logs, and long enough for investigations and legal or regulatory needs in archive. PCI DSS's 12 months, with three months immediately available, is a common reference point.
Do we need a SIEM? You need centralized, searchable and protected logs. A SIEM is the most common way to get there, but the policy, coverage and retention matter more than the product.
What if we discover a gap during an incident? Document it, scope conservatively and treat systems you cannot clear as potentially compromised. Then fix the gap; it is one of the most useful post-incident lessons.
How priorIQ.ai helps
SentinelIQ works as an AI triage layer on top of the SIEM or XDR you already have, such as Microsoft Sentinel, Splunk, Elastic, QRadar or Wazuh. It enriches and analyzes relevant alerts automatically, discards false positives, surfaces confirmed incidents with context and lets your team query alerts in natural language. Confirmed incidents feed PriorIQ Core, so the vulnerabilities on attacked assets move up the remediation queue. ScannerIQ and CloudIQ discover and inventory endpoints, servers and cloud resources, which helps you see which assets exist before you decide what each of them should log.