<!-- Source: https://www.socsimulator.com/event-ids/4647 -->

4647SecurityLogon/LogoffSecurity tier 1

# Event ID 4647: User initiated logoff

Event ID 4647 records that a logoff was initiated for a Windows logon session, typically an interactive or Remote Desktop sign-out. It is written in addition to 4634, which records the session being destroyed. 4647 carries only the account and its LogonId, so join it to the 4624 to learn how the session began.

## What Triggers Event 4647 and What It Leaves Out

Event 4647 is written when a logoff is initiated. Microsoft's description adds that no further user-initiated activity can occur after it, so the event can be read as a logoff. It belongs to the Audit Logoff subcategory, which has a Success form and nothing else. Microsoft is blunt about the gap. Failed logoffs, such as a system shutting down abruptly, do not generate an audit record, and logoff events are not 100 percent reliable. A machine that loses power writes no 4647 and no 4634 for the sessions it held.

The sibling is 4634, and the two describe different facts. Per Microsoft, 4647 is generated when the logoff procedure was started by a specific account using the logoff function. 4634 shows the session was terminated and no longer exists. For a person who signs out in the normal way you will usually see both, 4647 first and 4634 after, and Microsoft says 4647 is more typical for Interactive and RemoteInteractive logons. 4634 also fires for network and service sessions, which is why it is the noisy half of the pair. Think of 4647 as the intent marker and 4634 as the end state.

The schema is tiny. The XML Microsoft shows has four fields: TargetUserSid, TargetUserName, TargetDomainName and TargetLogonId. There is no LogonType, no source address and no process. The prose in Microsoft's reference calls the block Subject and describes the account that requested the logoff, but the XML names it Target, and there is only one account block. So the event cannot tell a user signing out from someone else ending that user's session. The logoff command on a Remote Desktop Session Host lets anyone with Full Control log off other users, and it deletes the session and ends its processes. Microsoft does not say whether such a forced logoff writes a 4647, so test that in a lab before you build a rule on the difference.

Collection is a decision you have to make. Microsoft's table for Audit Logoff lists Success as No under its general recommendation and Yes under the stronger one, on domain controllers, member servers and workstations alike, because the subcategory mostly emits 4634 events of little security relevance. Its stated reason to turn Success on is the use case of this page, tracking how long a session was active and when a user logged off. If your baseline stops at the general column, 4647 does not exist in your logs and every query here returns nothing.

To learn how the session began, borrow from 4624. TargetLogonId is the join key, and Microsoft warns that logon IDs are only unique between reboots on the same computer. Always join on host as well, and keep the time window short enough that a reboot does not sit inside it.

Remote Desktop adds a trap. Closing the RDP window is not a logoff. It writes a 4779, which Microsoft describes as a user disconnecting from an existing Terminal Services session or switching away with Fast User Switching. The session still exists, and a later 4778 records the user reconnecting, with the client name and address. A sign-out, or an administrator running logoff, ends the session and produces the 4647 and 4634 pair. These two sit in Audit Other Logon/Logoff Events, where Microsoft rates the volume Low and recommends Success auditing. The same subcategory records the workstation being locked (4800) and unlocked (4801). So a missing 4647 does not mean the user is still working. They may be locked, disconnected, or gone with the session left behind.

## Event 4647 Fields

| Field              | What it tells you                                                                              | Simulated value        |
| ------------------ | ---------------------------------------------------------------------------------------------- | ---------------------- |
| `TargetUserSid`    | SID of the account whose logon session is being logged off.                                    | `S-1-5-21-424242-1203` |
| `TargetUserName`   | Name of the account being logged off.                                                          | `r.okafor`             |
| `TargetDomainName` | Domain or computer name of the account.                                                        | `CORP`                 |
| `TargetLogonId`    | Logon session ID; correlates to the 4624 that opened the session. Unique only between reboots. | `0x6a31c9`             |

## Inspect Event 4647 Values

Click a field to inspect the full simulated value, the way you would expand it in a SIEM event view.

* TargetUserSidSID of the account whose logon session is being logged off.
* TargetUserNameName of the account being logged off.
* TargetDomainNameDomain or computer name of the account.
* TargetLogonIdLogon session ID; correlates to the 4624 that opened the session. Unique only between reboots.

## Example Event 4647 Log

A representative Security entry for Event 4647, generated deterministically by our telemetry engine so every field holds a realistic, internally consistent value.

Simulated example generated by SOCSimulator Research

```
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Microsoft-Windows-Security-Auditing" />
    <EventID>4647</EventID>
    <Version>0</Version>
    <Level>0</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8020000000000000</Keywords>
    <TimeCreated SystemTime="2025-07-23T12:51:34.000Z" />
    <EventRecordID>341412</EventRecordID>
    <Channel>Security</Channel>
    <Computer>WS-SIM-001.corp.socsimulator.example</Computer>
    <Security />
  </System>
  <EventData>
    <Data Name="TargetUserSid">S-1-5-21-424242-1203</Data>
    <Data Name="TargetUserName">r.okafor</Data>
    <Data Name="TargetDomainName">CORP</Data>
    <Data Name="TargetLogonId">0x6a31c9</Data>
  </EventData>
</Event>
```

## Detecting Event 4647

### Deliberate sign-out on a service or watchlisted account

4647 is mostly written for interactive and remote interactive sessions, so on an account that should only run services it means someone used it by hand. Replace the svc prefix with your naming convention or a watchlist. SPL assumes XML-rendered events: sourcetype XmlWinEventLog, source XmlWinEventLog:Security.

Splunk SPLMicrosoft KQLElastic Lucene

```
index=wineventlog sourcetype=XmlWinEventLog source="XmlWinEventLog:Security" EventCode=4647 TargetUserName="svc*"
| table _time, host, TargetUserName, TargetDomainName, TargetLogonId
```

### Sessions the user ended on purpose within a minute

Joins the logon (4624, types 2, 10 and 11) to the 4647 on host and logon ID. Logon IDs repeat after a reboot, so keep the time range short. Lucene is the base filter; the join runs in your SIEM.

Splunk SPLMicrosoft KQLElastic Lucene

```
index=wineventlog sourcetype=XmlWinEventLog source="XmlWinEventLog:Security" ((EventCode=4624 LogonType IN (2, 10, 11)) OR EventCode=4647)
| transaction host TargetLogonId startswith=eval(EventCode=4624) endswith=eval(EventCode=4647) maxspan=24h
| where duration < 60
| table _time, host, TargetUserName, duration
```

### Remote Desktop sessions disconnected more than eight hours ago and never signed out

4779 names the session in LogonID, and 4647 and 4634 use TargetLogonId, so the join key is the host plus the hex logon ID. Change the eight hours to your own policy. Lucene is the base filter; the missing-pair check runs in your SIEM.

Splunk SPLMicrosoft KQLElastic Lucene

```
index=wineventlog sourcetype=XmlWinEventLog source="XmlWinEventLog:Security" (EventCode=4779 OR EventCode=4647 OR EventCode=4634) earliest=-7d
| eval LogonKey=coalesce(TargetLogonId, LogonID)
| stats values(EventCode) as codes, latest(_time) as last_seen, values(AccountName) as account by host, LogonKey
| where isnotnull(mvfind(codes, "4779")) AND isnull(mvfind(codes, "4647")) AND isnull(mvfind(codes, "4634")) AND last_seen < relative_time(now(), "-8h")
| convert ctime(last_seen)
```

### Logoff initiated but the session was never destroyed

Microsoft says a user-initiated logoff normally produces both events. A 4647 with no 4634 after ten minutes is a question to answer on that host, not a finding. Lucene is the base filter; the missing-pair check runs in your SIEM.

Splunk SPLMicrosoft KQLElastic Lucene

```
index=wineventlog sourcetype=XmlWinEventLog source="XmlWinEventLog:Security" (EventCode=4647 OR EventCode=4634)
| stats values(EventCode) as codes, latest(_time) as last_seen by host, TargetLogonId
| where isnotnull(mvfind(codes, "4647")) AND isnull(mvfind(codes, "4634")) AND last_seen < relative_time(now(), "-10m")
| convert ctime(last_seen)
```

## True Positive vs False Positive

On its own a 4647 is almost never worth an alert. Its value is as a boundary and as proof of a kind of session, and the detections below use it that way.

The first use is accounts that should never be driven by hand. Because 4647 is typical for interactive and remote interactive sessions, a 4647 for a service account tells you someone signed in as it with a keyboard or an RDP client. Check the matching 4624 for LogonType 2, 10 or 11 and for the source address. The second is session length. Pair the logon with the deliberate logoff and sort the short ones to the top. On a server, an interactive session that lasts a minute is a check-and-leave, which is fine for an administrator on a ticket and worth a question when the account is unexpected.

The third use is the opposite problem, sessions that never end. A disconnect with no later sign-out leaves the session and its processes in place on the host until something ends them. On a server, that is a hygiene problem at best, and a place where an intruder's tools could keep running at worst. The fourth is a 4647 with no 4634 after it. Microsoft says a user-initiated logoff normally produces both, so a missing 4634 means the session may still exist. Treat that as a question to answer on that host.

False positives are mostly routine. Kiosks, shared workstations and VDI pools log people off all day. Scheduled or scripted logoffs look like deliberate ones. Baseline per host before you pick a threshold, and exclude the accounts and machines where constant sign-outs are the job.

During an investigation, 4647 is the cleanest way to close a session timeline. Put the 4624, any 4779 and 4778 pairs, the 4647 and the 4634 on one line for the same host and logon ID, and you can state when the session ended and whether the user ended it.

## Where 4647 Sits in an RDP Session

| Step          | Event                  | What it tells you                                |
| ------------- | ---------------------- | ------------------------------------------------ |
| Connect       | 4624 with LogonType 10 | The session starts, with the source address      |
| Window closed | 4779                   | The user disconnected; the session still exists  |
| Reconnect     | 4778                   | The user came back, with client name and address |
| Screen locked | 4800                   | The workstation was locked                       |
| Sign out      | 4647                   | A logoff was initiated                           |
| Session gone  | 4634                   | The session no longer exists                     |

## The Simulated Logoff

The simulated event shows r.okafor in the CORP domain with TargetLogonId 0x6a31c9. That is all it carries. To say how that session started, find the 4624 with the same TargetLogonId on the same host and read its LogonType and source address. To see whether the session ended cleanly, look for the 4634 that follows.

If the 4624 turns out to be LogonType 10 from an address you do not recognize, the 4647 is the moment the session ended, and everything between the two is the window to review.

## Practice Investigating Event 4647

No published room targets Event 4647 directly yet. The detection skills transfer, though: practice alert triage on realistic consoles across 73 free rooms in SOCSimulator Operations.

[Browse free operations](/explore/operations)

## Frequently Asked Questions

* What does event ID 4647 mean?

  It means a logoff was initiated for a logon session, usually by the user signing out of an interactive or Remote Desktop session. The event holds only the account SID, name, domain and TargetLogonId. It belongs to Audit Logoff and has a Success form only.

* What is the difference between event 4647 and event 4634?

  4647 says a logoff was initiated by an account. 4634 says the session was terminated and no longer exists. A normal sign-out usually writes both, 4647 first. 4634 also appears for network and service sessions, and it carries LogonType, which 4647 does not.

* Does closing a Remote Desktop window write a 4647?

  No. Closing the window disconnects the session, which writes event 4779, and the session stays on the host. A 4647 and then a 4634 appear only when the user signs out or an administrator runs logoff against the session.

* Can I use event 4647 to measure how long a user was logged on?

  Yes, for sessions the user ended on purpose. Join the 4624 and the 4647 on host and TargetLogonId and subtract the times. Sessions that were disconnected, locked or cut off by a power loss have no 4647, so the measurement covers only deliberate sign-outs.

## Sources

> “4647 description, four-field XML, difference from 4634, typical for Interactive and RemoteInteractive, logon IDs unique only between reboots”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4647)

> “4634 shows the session was terminated; carries LogonType; both events usually appear for a user-initiated logoff”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4634)

> “Audit Logoff has no failure event, abrupt shutdowns write no record, logoff events are not fully reliable, enable Success to track session length”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-logoff)

> “4779 session disconnected from a Terminal Services session or by Fast User Switching; fields AccountName, LogonID, SessionName, ClientName, ClientAddress”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4779)

> “4778 session reconnected, with client name and address”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4778)

> “Audit Other Logon/Logoff Events covers RDP connect and disconnect and workstation lock and unlock; volume Low, Success recommended”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-other-logonlogoff-events)

> “4624 logon types and the TargetLogonId used to correlate with logoff events”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4624)

> “The logoff command logs a user off a Remote Desktop Session Host session, deletes the session and ends its processes; Full Control is needed to log off other users”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/logoff)

> “SecurityEvent columns used in the KQL (TargetLogonId, TargetUserName, LogonType, IpAddress, AccountName, LogonID, SessionName, ClientName)”
>
> — [learn.microsoft.com (accessed 2026-10-19)](https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/securityevent)

## Related SOC Training Resources

[Event ID](/event-ids/4648)

### [Event ID 4648: Logon Attempted Using Explicit Credentials](/event-ids/4648)

[Event ID 4648, "A logon was attempted using explicit credentials": runas and scheduled task triggers, the three identiti…](/event-ids/4648)

[Read more ](/event-ids/4648)[Event ID](/event-ids/4672)

### [Event ID 4672: Special Logon Privileges, Codes & Queries](/event-ids/4672)

[Event ID 4672 fields, the 13 sensitive privileges, TP/FP triage, and SPL/KQL/Lucene detection queries for SOC analysts, …](/event-ids/4672)

[Read more ](/event-ids/4672)[Event ID](/event-ids/4624)

### [Event ID 4624: Successful Logon, Codes & Queries](/event-ids/4624)

[Event ID 4624 logs every successful Windows logon. SOCSimulator breaks down the logon type codes, TP/FP triage, and SPL/…](/event-ids/4624)

[Read more ](/event-ids/4624)[Glossary](/glossary/brute-force)

### [What is Brute Force Attack? SOC Glossary](/glossary/brute-force)

[A brute force attack is password guessing at scale: a tool submits candidate passwords, or encryption keys, until one wo…](/glossary/brute-force)

[Read more ](/glossary/brute-force)[Glossary](/glossary/lateral-movement)

### [What is Lateral Movement? SOC Glossary](/glossary/lateral-movement)

[Lateral movement is the attack phase where adversaries expand access from an initial foothold to additional systems, usi…](/glossary/lateral-movement)

[Read more ](/glossary/lateral-movement)[Glossary](/glossary/mfa)

### [What is MFA? SOC Glossary](/glossary/mfa)

[MFA (multi-factor authentication) is a sign-in check that asks for two or more different kinds of proof before granting …](/glossary/mfa)

[Read more ](/glossary/mfa)[Glossary](/glossary/siem)

### [What is SIEM? SOC Glossary](/glossary/siem)

[Security Information and Event Management (SIEM) is a platform that aggregates, normalizes, and correlates log data from…](/glossary/siem)

[Read more ](/glossary/siem)[Career Path](/careers/paths/soc-analyst-tier-1)

### [SOC Analyst (Tier 1) Career Guide: Salary & Skills](/careers/paths/soc-analyst-tier-1)

[Tier 1 SOC Analysts are the front line. You monitor alert queues, triage incoming detections, classify them as true or f…](/careers/paths/soc-analyst-tier-1)

[Read more ](/careers/paths/soc-analyst-tier-1)[Career Path](/careers/paths/soc-analyst-tier-2)

### [SOC Analyst (Tier 2) Career Guide: Salary & Skills](/careers/paths/soc-analyst-tier-2)

[Tier 2 SOC Analysts handle the investigations that Tier 1 escalates. You dig into multi-stage attacks, coordinate contai…](/careers/paths/soc-analyst-tier-2)

[Read more ](/careers/paths/soc-analyst-tier-2)[Comparison](/compare/vs-letsdefend)

### [SOCSimulator vs. LetsDefend: Platform Comparison](/compare/vs-letsdefend)

[SOCSimulator wins on operational realism. You get multi-tool shift simulation with SLA pressure, noise injection, and al…](/compare/vs-letsdefend)

[Read more ](/compare/vs-letsdefend)[Event ID](/event-ids)

### [Windows Event ID Library: SOC Reference](/event-ids)

[Windows Security and Sysmon event IDs with simulated log samples, field tables, and tested detection queries.](/event-ids)

[Read more ](/event-ids)[Feature](/features/shift-mode)

### [Shift Mode: Real-Time SOC Simulation](/features/shift-mode)

[Practice alert triage under realistic time pressure with SLA timers and noise injection.](/features/shift-mode)

[Read more](/features/shift-mode)
