I was once called in to help a firm of about sixty people that had found one of its servers encrypted on a Monday morning. They had backups, and within two days they were working again. Then came the questions from their insurer and their lawyer. How did the attacker get in? When? What else did they reach? Was any client data taken?
We could not answer one of them. The firewall kept logs for seven days and the attacker, it later emerged, had first connected about five weeks before. The server's own logs had been wiped. The email system had logging available, and nobody had turned it on.
The firm had to assume the worst and notify every client, because it could prove nothing. Recovering the systems cost them less than that did.
I have thought about that week often. This is the advice I would have given them a year earlier.
What logs are for
A log is a record, kept by a system, of things that happened: a login, a file opened, a connection made, an error. Each entry has a time, a source and a description.
Logs serve two purposes, and they are worth keeping apart.
Detection. Noticing that something is wrong while it is happening.
Investigation. Establishing afterwards what occurred.
Most small organisations will get little from the first without specialist staff. All of them need the second. Reports on breaches have found for years that the typical gap between an intrusion and its discovery is measured in days or weeks, and that many victims learn of it from someone outside. When that call comes, the logs are the only witness.
So the first aim is modest: have the evidence, kept somewhere the intruder cannot erase it.
Which logs matter
Almost everything can produce logs, and nobody can collect it all. For a small organisation, five sources answer most of the questions asked after an incident.
- Identity and sign-ins. Who logged in, from where, when, by what method, and whether it succeeded. Include the directory or identity provider, remote access and any single sign-on. Most intrusions involve a valid account being misused, and this is where it shows.
- Email and cloud services. Sign-ins, forwarding rules created, mailboxes accessed by someone else, files shared externally, administrative changes. In hosted office suites this is called the audit log. It may need to be switched on, and what is retained depends on the licence.
- Endpoints. Programs started, software installed, security tools' alerts.
- Network boundary. Connections allowed and blocked by the firewall, remote-access sessions, lookups of domain names.
- Administrative actions. Accounts created, privileges granted, security settings changed, logs cleared.
The last item deserves emphasis. "Audit log cleared" is among the most useful single events to record, provided the record is kept somewhere else.
Four properties
Central. Logs left on the machine that produced them are lost when that machine is compromised or rebuilt. Send copies to a separate system as they are generated. That can be a dedicated log server, a cloud logging service, or the security monitoring product included with many business software subscriptions.
Protected. Administrators of the ordinary systems should not be able to delete the central copy. An attacker who gains administrative control must not gain the logs with it.
Synchronised. Every system's clock should be set from the same time source, and logs should record the time zone, or better, use universal time throughout. Reconstructing a sequence across five systems whose clocks disagree by minutes is miserable. One whose clock is hours out makes it impossible.
Kept long enough. Seven days is useless. Given how long intrusions go unnoticed, ninety days is a minimum, and a year is better for sign-in and administrative records. Storage is cheap. Some regulations and insurers set their own minimums, and data protection law may limit how long personal data is kept, so write the period down with the reason.
Knowing what is normal
Here is where logs become more than an archive, without requiring a security operations centre.
An anomaly is a departure from normal. You cannot see one unless you know what normal is, and most organisations have no idea how many failed logins they have on an ordinary Tuesday.
So count a few things every week and write the numbers down.
| Measure | Typical week |
|---|---|
| Failed sign-ins | 140 to 220 |
| Sign-ins from outside the home country | 0 to 3 |
| Accounts locked out | 2 to 6 |
| New administrator accounts | 0 |
| Mail forwarding rules to external addresses | 0 to 1 |
| Outbound data volume | 30 to 45 GB |
| Programs blocked by endpoint protection | 1 to 4 |
| Sign-ins outside 06:00 to 22:00 | 5 to 15 |
After two months you have a baseline. It need not be sophisticated. A table like this, kept in a spreadsheet, will show you that 2,400 failed sign-ins is ten times the usual, or that the 180 GB sent out on a Saturday night has no precedent.
Machine-learning tools sold for detecting anomalies are doing the same thing with more variables. They learn what is usual and flag departures. They can be valuable. They also produce a great many alerts about things that are unusual and harmless, and they need someone to tune and read them. The table should come first, because it tells you what such a tool ought to find.
A short list of alerts
Collecting logs and alerting on them are separate decisions. A small team that alerts on everything is soon ignoring everything.
A better arrangement is to choose a few events that are both rare in normal operation and serious if they happen, and send only those to a person.
- A new account with administrative rights.
- A sign-in to an administrator account from a new device or country.
- Sign-ins by one user from two distant places within an hour.
- A mail rule that forwards or deletes messages automatically.
- Security logging or protection switched off.
- Logs cleared.
- Many failed sign-ins across many accounts from one source.
- A very large transfer outwards at an unusual hour.
- Use of an account that belongs to someone who has left.
Each should fire a few times a year at most. If one fires daily, it needs adjusting. Every alert should have an owner and one written line saying what to do first.
Rehearsing the questions
The real test of logging is whether it answers questions. Try it before it counts.
Once a quarter, pick a scenario and attempt to answer it from the logs, with a stopwatch running.
- An employee's laptop was stolen on Friday. What did that account do over the weekend?
- This invoice had its bank details changed. Who opened the mailbox it came through, and from where?
- Someone left last month. Has their account been used since?
- Which machines connected to this address in the past thirty days?
The first attempt generally fails in an instructive way. The log does not exist, or does not go back far enough, or nobody knows how to search it, or it lacks the field that was needed. Each failure costs an hour to discover in an exercise and would cost very much more to discover in an emergency.
Privacy and proportion
Logs record what people do. That raises obligations.
Be open with staff about what is recorded and why. In many jurisdictions this is a legal requirement, and employee monitoring may be subject to further rules or consultation. Limit who can read the logs. Use them for security and for the purposes you stated. Do not keep them for ever.
Keep the content in proportion as well. The fact that a user sent an email, to whom and when, is normally enough for security purposes. The text of the message is not needed.
The minimal version
For an organisation with no security staff, an afternoon will achieve most of this.
- Turn on audit logging in the email and office suite, and set retention as long as the licence permits.
- Make sure sign-in logs are kept for at least ninety days.
- Extend the firewall's retention, or send its logs somewhere that keeps them.
- Check that all clocks synchronise automatically.
- Set up the nine alerts above, or as many as the tools allow, to go to two named people.
- Start the weekly table.
- Put the first quarterly exercise in the calendar.
After the fact
The firm I mentioned did all of this within a month of its incident. Two years later an employee's mailbox was accessed by someone who had obtained her password through a fake login page.
This time an alert fired on a new forwarding rule within the hour. The logs showed exactly which messages the intruder had opened in the forty minutes before the account was locked: eleven, none containing client information. The firm notified one person and changed one password.
The two attacks were similar in kind. The second cost far less because the firm had ninety days of records and a table of normal figures to compare against.



