Enable DNS Logging and Diagnostics in Wi·续

| 263 | Update in | Dynamic update | Informational | DYN_UPDATE_RECV: TCP=%1; InterfaceIP=%2; Source=%3; QNAME=%4; XID=%5; Port=%6; Flags=%7; SECURE=%8; PacketData=%10 |

| 264 | Update response | Dynamic Update | Informational | DYN_UPDATE_RESPONSE: TCP=%1; InterfaceIP=%2; Destination=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8; PolicyName=%9; PacketData=%11 |

| 265 | IXFR request out | Zone XFR | Informational | IXFR_REQ_OUT: TCP=%1; InterfaceIP=%2; Source=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; PacketData=%9 |

| 266 | IXFR request in | Zone XFR | Informational | IXFR_REQ_RECV: TCP=%1; InterfaceIP=%2; Source=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; PacketData=%9 |

| 267 | 267 IXFR response out | Zone XFR | Informational | IXFR_RESP_OUT: TCP=%1; InterfaceIP=%2; Destination=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8; PacketData=%10 |

| 268 | IXFR response in | Zone XFR | Informational | IXFR_RESP_RECV: TCP=%1; InterfaceIP=%2; Destination=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8; PacketData=%10 |

| 269 | AXFR request out | Zone XFR | Informational | AXFR_REQ_OUT: TCP=%1; Source=%2; InterfaceIP=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; PacketData=%9 |

| 270 | AXFR request in | Zone XFR | Informational | AXFR_REQ_RECV: TCP=%1; Source=%2; InterfaceIP=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; PacketData=%9 |

| 271 | AXFR response out | Zone XFR | Informational | AXFR_RESP_OUT: TCP=%1; InterfaceIP=%2; Destination=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8 |

| 272 | AXFR response in | Zone XFR | Informational | AXFR_RESP_RECV: TCP=%1; InterfaceIP=%2; Destination=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8 |

| 273 | XFR notification in | Zone XFR | Informational | XFR_NOTIFY_RECV: Source=%1; InterfaceIP=%2; QNAME=%3; ZoneScope=%4; Zone=%5; PacketData=%7 |

| 274 | XFR notification out | Zone XFR | Informational | XFR_NOTIFY_OUT: Destination=%1; InterfaceIP=%2; QNAME=%3; ZoneScope=%4; Zone=%5; PacketData=%7 |

| 275 | XFR notify ACK in | Zone XFR | Informational | XFR_NOTIFY_ACK_IN: Source=%1; InterfaceIP=%2; PacketData=%4 |

| 276 | XFR notify ACK out | Zone XFR | Informational | XFR_NOTIFY_ACK_OUT: Destination=%1; InterfaceIP=%2; Zone=%3; PacketData=%5 |

| 277 | Update forward | Dynamic update | Informational | DYN_UPDATE_FORWARD: TCP=%1; ForwardInterfaceIP=%2; Destination=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8; PacketData=%10 |

| 278 | Update response in | Dynamic update | Informational | DYN_UPDATE_RESPONSE_IN: TCP=%1; InterfaceIP=%2; Source=%3; QNAME=%4; XID=%5; ZoneScope=%6; Zone=%7; RCODE=%8; PacketData=%10 |

| 279 | Internal lookup CNAME | Lookup | Informational | INTERNAL_LOOKUP_CNAME: TCP=%1; InterfaceIP=%2; Source=%3; RD=%4; QNAME=%5; QTYPE=%6; Port=%7; Flags=%8; XID=%9; PacketData=%11 |

| 280 | Internal lookup | Lookup | Informational | INTERNAL_LOOKUP_ADDITIONAL: TCP=%1; InterfaceIP=%2; Source=%3; RD=%4; QNAME=%5; QTYPE=%6; Port=%7; Flags=%8; XID=%9; PacketData=%11 |

Event Tracing

DNS logs are compatible with Event Tracing for Windows (ETW) consumer applications such as logman, tracelog, and message analyzer. For more information about using event tracing, see About Event Tracing.

You can use ETW consumers such as tracelog.exe with DNS server audit and analytic events by specifying a GUID of {EB79061A-A566-4698-9119-3ED2807060E7}.

You can get tracelog.exe by downloading and installing the Windows Driver Kit (WDK). Tracelog.exe is included when you install the WDK, Visual Studio, and the Windows SDK for desktop apps. For information about downloading the kits, see Windows Hardware Downloads. For example, when you download and install Windows Driver Kit (WDK) and accept the default installation path, tracelog.exe is available at: C:\Program Files (x86)\WindowsKits\10\bin\10.0.26100.0\x64\tracelog.exe.

For more information about using tracelog.exe, see Tracelog Command Syntax.

The following examples demonstrate how to use tracelog.exe with DNS audit and analytic event logs:

The following command enables both analytical and audit logging:


tracelog.exe -start Dns -guid #{EB79061A-A566-4698-9119-3ED2807060E7} -level 5 -matchanykw 0xFFFFFFFF -f C:\analytic_audit.etl

While the trace is active, all analytical and audit events are recorded in the C:\analytic_audit.etl file that was specified on the command line. You can stop tracing by issuing a stop command:


tracelog –stop Dns

After stopping the trace, you can view the .etl file in Event Viewer by selecting Action and then selecting Open Saved Log.

A screenshot showing Event Viewer DNS server logs with details on zone delegation, including event IDs, task categories, and specific DNS query information.

The following example enables only the analytical channel and matches only the keywords to 0x7FFFF:


tracelog.exe -start Dns -guid #{EB79061A-A566-4698-9119-3ED2807060E7} -level 5 -matchanykw 0x7FFFF -f C:\analytic.etl

A logging level of 5 is used in the previous examples. The following table shows the available logging levels.

| Logging level | Description |

| --- | --- |

| 0 (None) | Logging OFF |

| 1 (Critical) | Only critical events are logged, for example process exit or termination. If no logging level is given, level 1 is used by default. |

| 2 (Error) | Only severe error events are logged, for example failures to complete a required task. |

| 3 (Warning) | Errors that can cause a service issue, but are acceptable or recoverable. For example, the first attempt to contact a forwarder fails. |

| 4 (Informational) | High-level events are recorded in the event log. These events might include one message for each major task performed by the service. Use this setting to begin an investigation when the location of the problem is in doubt. For example, a scavenger thread was started. |

| 5 (Verbose) | All events are logged. Level 5 provides a complete log of the operation of the service. Use this level when the problem is traced to a particular category or a small set of categories. |

Performance considerations

DNS server performance can be affected when logging is enabled, however the enhanced DNS logging and diagnostics feature in Windows Server is designed to lower the impact on performance. This article discusses DNS server performance considerations when logging is enabled.

Debug logging

Before the introduction of DNS analytic logs, DNS debug logging was an available method to monitor DNS transactions. DNS debug logging isn't the same as the enhanced DNS logging and diagnostics feature discussed in this article. Debug logging is a tool that also can be used for DNS logging and diagnostics. The DNS debug log provides detailed data about all DNS information sent and received by the DNS server. The information gathered is similar to the data that can be gathered using packet capture tools such as network monitor.

By default, all debug logging options are disabled. When selectively enabled, the DNS Server service can perform trace-level logging of selected types of events or messages for general troubleshooting and debugging of the server.

Debug logging can be resource intensive, affecting overall server performance, and consuming disk space. Therefore, it should only be used temporarily when more detailed information about server performance is needed.

Tip

Dns.log contains debug logging activity. By default, the DNS debug log is located in the %windir%\system32\dns directory.

You can enable debug logging using the Desktop Experience or PowerShell. Use the following methods to enable diagnostic event logging and change other event log parameters. Select the method that best fits your needs.

Desktop Experience

The following steps show how to enable debug logging using the Desktop Experience. To select and enable debug logging options on the DNS server, follow these steps:

  1. Select Start, type DNS Manager, and then select DNS Manager from the best match list.

  2. In the console tree, right-click the applicable DNS server, then select Properties.

  3. Select the Debug Logging tab.

  4. From the Properties dialog box, check the Log packets for debugging box, and then select the events that you want the DNS server to record for debug logging.

The following DNS debug logging options are available:

  • Direction of packets

Send - Packets sent by the DNS server are logged in the DNS server log file.

Receive - Packets received by the DNS server are logged in the log file.

  • Content of packets

Standard queries - Specifies that packets containing standard queries (per RFC 1034) are logged in the DNS server log file.

Updates - Specifies that packets containing dynamic updates (per RFC 2136) are logged in the DNS server log file.

Notifies - Specifies that packets containing notifications (per RFC 1996) are logged in the DNS server log file.

  • Transport protocol

UDP - Specifies that packets sent and received over UDP are logged in the DNS server log file.

TCP - Specifies that packets sent and received over TCP are logged in the DNS server log file.

  • Type of packet

Request - Specifies that request packets are logged in the DNS server log file (a request packet is characterized by a QR bit set to 0 in the DNS message header).

Response - Specifies that response packets are logged in the DNS server log file (a response packet is characterized by a QR bit set to 1 in the DNS message header).

  • Enable filtering based on IP address Provides filtering of packets logged in the DNS server log file. This option allows logging of packets sent from specific IP addresses to a DNS server, or from a DNS server to specific IP addresses.

  • File name - Lets you specify the name and location of the DNS server log file.

For example:

  • dns.log specifies that the DNS server log file should be saved as dns.log in the <systemroot>zSystem32Dns directory. Remember to replace <systemroot> with the actual path to the Windows directory on your computer.

  • temp\dns.log specifies that the DNS server log file should be saved as dns.log in the <systemroot>\Temp directory. Remember to replace <systemroot> with the actual path to the Windows directory on your computer.

  • Log file maximum size limit Lets you set the maximum file size for the DNS server log file. When the specified maximum size of the DNS server log file is reached, the DNS server overwrites the oldest packet information with new information. Note: If left unspecified, the DNS server log file's size can take up a large amount of hard disk space.

PowerShell

The following steps show how to enable debug logging using PowerShell. To select and enable debug logging options on the DNS server, follow these steps:

View event logging status

To view the status of individual diagnostic events, follow the steps.

  1. Sign in to the DNS server with an account that has administrative privileges.

  2. Open an elevated Windows PowerShell prompt on a DNS server.

  3. Use the Get-DnsServerDiagnostics command to view the status of individual diagnostic events. The following example shows the default status of individual diagnostic events.


SaveLogsToPersistentStorage          : False

Queries                              : False

Answers                              : False

Notifications                        : False

Update                               : False

QuestionTransactions                 : False

UnmatchedResponse                    : False

SendPackets                          : False

ReceivePackets                       : False

TcpPackets                           : False

UdpPackets                           : False

FullPackets                          : False

FilterIPAddressList                  :

EventLogLevel                        : 4

UseSystemEventLog                    : False

EnableLoggingToFile                  : True

EnableLogFileRollover                : False

LogFilePath                          :

MaxMBFileSize                        : 500000000

WriteThrough                         : False

EnableLoggingForLocalLookupEvent     : False

EnableLoggingForPluginDllEvent       : False

EnableLoggingForRecursiveLookupEvent : False

EnableLoggingForRemoteServerEvent    : False

EnableLoggingForServerStartStopEvent : False

EnableLoggingForTombstoneEvent       : False

EnableLoggingForZoneDataWriteEvent   : False

EnableLoggingForZoneLoadingEvent     : False

Enable diagnostic events in the event log

To enable diagnostic events in the event log, follow the steps.

  1. To enable only specific diagnostic events, for example, Queries, Answers, Notifications, SendPackets, ReceivePackets, TcpPackets, and UdpPackets diagnostic events, use the following command.

Set-DnsServerDiagnostics -Queries $true -Answers $true -Notifications $true -SendPackets $true -ReceivePackets $true -TcpPackets $true -UdpPackets $true

  1. Enable all diagnostic events at once using the following command.

Set-DnsServerDiagnostics -All $true

  1. To verify the status of individual diagnostic events, use the Get-DnsServerDiagnostics command. The following example shows the status of individual diagnostic events after enabling all diagnostic events.

SaveLogsToPersistentStorage          : True

Queries                              : True

Answers                              : True

Notifications                        : True

Update                               : True

QuestionTransactions                 : True

UnmatchedResponse                    : True

SendPackets                          : True

ReceivePackets                       : True

TcpPackets                           : True

UdpPackets                           : True

FullPackets                          : True

FilterIPAddressList                  :

EventLogLevel                        : 7

UseSystemEventLog                    : False

EnableLoggingToFile                  : True

EnableLogFileRollover                : True

LogFilePath                          :

MaxMBFileSize                        : 500000000

WriteThrough                         : True

EnableLoggingForLocalLookupEvent     : True

EnableLoggingForPluginDllEvent       : True

EnableLoggingForRecursiveLookupEvent : True

EnableLoggingForRemoteServerEvent    : True

EnableLoggingForServerStartStopEvent : True

EnableLoggingForTombstoneEvent       : True

EnableLoggingForZoneDataWriteEvent   : True

EnableLoggingForZoneLoadingEvent     : True

Enable debug log rollover

The Set -DnsServerDiagnostics -All $true command implicitly sets the -EnableLogFileRollover option to $true. Meaning that when the log file reaches its maximum size, Windows starts a new log file instead of overwriting the existing log file. The computer can accumulate enough log files to affect its performance and fill its hard drive. To avoid these issues, consider enabling individual diagnostic events. Alternatively, if you can capture the information that you want in the log file before the file grows to 500 MB, you can enable log rollover. To enable log rollover, follow these steps.

  1. Open an elevated Windows PowerShell prompt on the DNS server where you wish to enable event logging.

  2. Use the Set-DnsServerDiagnostics command to enable debug log rollover. See the following example.

Set-DnsServerDiagnostics -EnableLogFileRollover $true