Windows Servers
Windows Event Viewer Logs: How to Find What Went Wrong
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيAlmost everything that happens on a Windows server leaves a trace in the event logs: services that crash, unexpected reboots, failed logons, driver problems, updates that did not install. Event Viewer is where those traces live. The trouble is volume: a busy server writes thousands of events a day, most of them harmless. This guide shows how the logs are organised, which event IDs deserve attention, and how to filter quickly from both the console and PowerShell.
How the logs are organised
Open Event Viewer with eventvwr.msc. In the left pane you will find:
- Windows Logs
- Application: events written by programs and some services. - Security: logons, privilege use and audit events. Only administrators can read it. - Setup: role, feature and update installation events. - System: the operating system itself, drivers and the Service Control Manager. - Forwarded Events: events collected from other machines, if you configure forwarding.
- Applications and Services Logs: detailed per-component logs, for example
Microsoft > Windows > TerminalServices-LocalSessionManager > Operationalfor RDP sessions.
Each event has a level (Critical, Error, Warning, Information, or Audit Success/Failure for Security), a source, an event ID, a timestamp and a description. The combination of source and ID is what you search for; the description text can vary between versions.
Event IDs worth knowing
| Log | Event ID | Meaning |
|---|---|---|
| System | 41 (Kernel-Power) | The system rebooted without a clean shutdown |
| System | 6008 | The previous shutdown was unexpected |
| System | 1074 | A user or process initiated a restart or shutdown, with the reason |
| System | 6005 / 6006 | Event Log service started / stopped (roughly boot and shutdown) |
| System | 7034 | A service terminated unexpectedly |
| System | 7036 | A service changed state (started or stopped) |
| Security | 4624 | Successful logon |
| Security | 4625 | Failed logon |
| Security | 4672 | Logon with administrative privileges |
| Security | 4720 | A user account was created |
| Security | 4740 | A user account was locked out |
| Security | 1102 | The Security log was cleared |
For logon events, the Logon Type field matters: type 2 is interactive at the console, type 3 is network (file shares, for example), and type 10 is RemoteInteractive, meaning Remote Desktop.
Filtering in the console
Right-click a log and choose Filter Current Log. You can restrict by time range, level, event source and a list of IDs (for example 41,6008,1074). For filters you reuse, create a Custom View from the Action menu instead; it can span several logs at once and stays in the tree under Custom Views.
Two other features are underused:
- Attach Task To This Event: right-click an event to run a program or script whenever that event recurs, such as a script that sends you a notification.
- Save All Events As: exports to
.evtxso you can analyse the log on another machine or keep it as evidence.
Faster searching with PowerShell
Get-WinEvent with -FilterHashtable filters at the source, which is much faster than piping everything through Where-Object:
# Unexpected reboots in the last 7 days
Get-WinEvent -FilterHashtable @{LogName='System'; Id=41,6008; StartTime=(Get-Date).AddDays(-7)}
# Who restarted the server and why
Get-WinEvent -FilterHashtable @{LogName='System'; Id=1074} -MaxEvents 10 | Format-List TimeCreated, Message
# Errors from the last 24 hours
Get-WinEvent -FilterHashtable @{LogName='Application','System'; Level=1,2; StartTime=(Get-Date).AddDays(-1)}Level 1 is Critical and level 2 is Error. The classic wevtutil tool is still useful for exporting and sizing logs:
wevtutil epl Security C:\Logs\security-backup.evtx
wevtutil gl Security
wevtutil sl Security /ms:209715200The last command raises the Security log's maximum size to 200 MB, which helps on servers where the default size rolls over within hours.
Spotting RDP brute-force attempts
Any Windows VPS with Remote Desktop open to the whole internet will receive automated password guessing. You can measure it from the Security log:
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddDays(-1)} |
ForEach-Object { ([xml]$_.ToXml()).Event.EventData.Data | Where-Object Name -eq 'IpAddress' | Select-Object -ExpandProperty '#text' } |
Group-Object | Sort-Object Count -Descending | Select-Object -First 10 Count, NameThis lists the source addresses with the most failed logons in the last day. Successful RDP sessions appear as 4624 with logon type 10, and in the TerminalServices-LocalSessionManager/Operational log as event 21 (logon), 24 (disconnect) and 25 (reconnect).
If the numbers are high, the fix is not reading logs more often. Restrict port 3389 to your own IP addresses with a firewall, use strong unique passwords, enable an account lockout policy, and keep Network Level Authentication on. A cloud firewall in front of the server stops the traffic before Windows has to process it.
A practical routine
- After any unexplained restart, check 41, 6008 and 1074 first.
- When a service stops working, filter System for 7034 and 7036 and Application for errors from that service's source.
- Once a week, review failed logons and new accounts (4625, 4720, 4740).
- Treat 1102 (log cleared) as a security incident unless you cleared it yourself.
- Increase log sizes on busy servers so you do not lose history.
When an error lines up with a performance problem, correlate the timestamps with counter data; our Performance Monitor guide covers recording a baseline. If you want a clean test server to practise on, you can deploy a Windows VPS in a few minutes.
FAQ
Why can I not see the Security log?
Reading the Security log requires administrative rights or membership in the Event Log Readers group with the right permissions. Open Event Viewer from an elevated session, and make sure auditing is enabled for the categories you need.
How long do Windows event logs keep history?
There is no fixed time. Each log has a maximum size, and when it is full the oldest events are overwritten by default. On busy servers that can mean only hours or days of Security history, so raise the size or forward events elsewhere.
Is it safe to clear event logs?
Clearing does not harm Windows, but you lose the history you may need for troubleshooting or investigating an incident. Export the log to an .evtx file first, and remember that clearing the Security log is itself recorded as event 1102.