# Viewing DNClient logs

This guide explains how to view logs for [DNClient](/docs/glossary/dnclient/) in each of the supported platforms.

## Streaming to admin panel

To begin streaming logs to your web browser, log into the [admin panel](https://admin.defined.net), find the host, lighthouse, or relay that you would like to inspect, click the three-dot menu, and choose "Debug." From there, you can stream logs from DNClient for a maximum of five minutes at a time, or you can send debugging commands to inspect the state of the client. (Note: `Query lighthouse` should be run twice; the first command will return the current state from memory as well as start a query, and a repeated command will return updated result.) You can also download a copy of the logs from this page. [Running host diagnostics](/docs/guides/host-diagnostics/) explains each command and how to read its result.

## Linux

### Logs \{#logs-linux\}

If you are using systemd:

```bash
journalctl --unit=dnclient --follow
```

### Config info \{#config-info-linux\}

:::note

This command will strip the private info such as [`pki.key`](https://nebula.defined.net/docs/config/pki#pkikey) from the config, allowing you to safely share the output with Defined Networking support while troubleshooting.

:::

```bash
sudo dnclient info
```

### Service status \{#service-status-linux\}

```bash
systemctl status dnclient
```

```bash
# outputs
● dnclient.service - Defined Networking client daemon
     Loaded: loaded (/etc/systemd/system/dnclient.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-11-30 16:07:48 CST; 2min 3s ago
   Main PID: 546 (dnclient)
      Tasks: 10 (limit: 4560)
     Memory: 19.2M
     CGroup: /system.slice/dnclient.service
             └─546 /home/alice/dnclient run -server https://api.defined.net

# ... shows DNClient logs ...
```

## macOS

### Logs for Server variant \{#logs-for-server-variant-macos\}

```bash
sudo tail -f /usr/local/var/log/dnclient.*
```

### Logs for Desktop variant \{#logs-for-desktop-variant-macos\}

[DNClient Desktop](/docs/glossary/dnclient-desktop/) has multiple logging outputs. The desktop app logs to the system log, viewable in `Console.app` or `log`. The [`dnclientd`](/docs/glossary/dnclientd/) daemon service logs to `/Library/Logs/DefinedNet/dnclientd.log`. Each `dnclient` instances logs to `/Library/Logs/DefinedNet/dnclient.$(host-ID).log`.

View Desktop App Logs:

```zsh
log show --last 3h --predicate 'subsystem == "net.defined.dnclient-desktop"'
```

View `dnclientd` logs:

```bash
sudo tail -f /Library/Logs/DefinedNet/dnclientd.log
```

View `dnclient` logs:

```bash
sudo tail -f /Library/Logs/DefinedNet/dnclient.$(host-ID).log
```

### Config info \{#config-info-macos\}

:::note

This command will strip the private info such as [`pki.key`](https://nebula.defined.net/docs/config/pki#pkikey) from the config, allowing you to safely share the output with Defined Networking support while troubleshooting.

:::

```bash
sudo dnclient info
```

### Service status \{#service-status-macos\}

The Server variant runs as the `dnclient` launchd service:

```bash
sudo launchctl list dnclient
```

```bash
{
	"StandardOutPath" = "/usr/local/var/log/dnclient.out.log";
	"LimitLoadToSessionType" = "System";
	"StandardErrorPath" = "/usr/local/var/log/dnclient.err.log";
	"Label" = "dnclient";
	"OnDemand" = false;
	"LastExitStatus" = 0;
	"PID" = 663;
	"Program" = "/Users/alice/.local/bin/dnclient";
	"ProgramArguments" = (
		"/Users/alice/.local/bin/dnclient";
		"run";
		"-server";
		"https://api.defined.net";
	);
};
```

[DNClient Desktop](/docs/glossary/dnclient-desktop/) runs the [`dnclientd`](/docs/glossary/dnclientd/) daemon as the `net.defined.dnclientd` launchd service:

```bash
sudo launchctl list net.defined.dnclientd
```

```bash
{
	"StandardOutPath" = "/var/log/dnclientd.out.log";
	"LimitLoadToSessionType" = "System";
	"StandardErrorPath" = "/var/log/dnclientd.err.log";
	"Label" = "net.defined.dnclientd";
	"OnDemand" = true;
	"LastExitStatus" = 0;
	"PID" = 17805;
	"Program" = "Contents/Resources/dnclientd";
	"ProgramArguments" = (
		"dnclientd";
		"-log";
		"/Library/Logs/DefinedNet/dnclientd.log";
	);
};
```

## Windows

### Logs for Server variant \{#logs-for-server-variant-windows\}

DNClient writes to the Windows Application event log under the `dnclient` source, or `dnclient.<name>` for an instance enrolled with `-name`. To print the 300 most recent log entries in PowerShell, newest first:

```powershell
Get-WinEvent -FilterHashtable @{ LogName = 'Application'; ProviderName = 'dnclient*' } -MaxEvents 300 |
  Format-List TimeCreated, ProviderName, LevelDisplayName, Message
```

Append `| Out-File dnclient-logs.txt` to write the output to a file you can attach to a support request. Raise `-MaxEvents` to go further back; how far back the logs go depends on the Application log's size and overwrite settings.

<details>
<summary>View the logs in Event Viewer</summary>

Open the Event Viewer app, click on Custom Views -> Administrative Events -> manually enter `dnclient` for "Event sources". For a named instance, enter `dnclient.<name>` instead.

You can also make a "Custom View" which filters on the `dnclient` source, or on `dnclient.<name>`.

![Custom events viewer form showing all logs selected](./making-a-custom-view-all-logs.png)

![Custom events viewer form showing `dnclient` entered within the `Source` field](./making-a-custom-view-dnclient-source.png)

</details>

### Logs for Desktop variant \{#logs-for-desktop-variant-windows\}

[DNClient Desktop](/docs/glossary/dnclient-desktop/) writes to the Windows Application event log under several sources: `dnclient-desktop`, [`dnclientd`](/docs/glossary/dnclientd/), and `dnclient.$(host-ID)`. To print the 300 most recent log entries from all three in PowerShell, newest first:

```powershell
Get-WinEvent -FilterHashtable @{ LogName = 'Application'; ProviderName = 'dnclient*' } -MaxEvents 300 |
  Format-List TimeCreated, ProviderName, LevelDisplayName, Message
```

Append `| Out-File dnclient-logs.txt` to write the output to a file you can attach to a support request. Raise `-MaxEvents` to go further back; how far back the logs go depends on the Application log's size and overwrite settings.

<details>
<summary>View the logs in Event Viewer</summary>

In the Event Viewer app, make a "Custom View" which filters on all three sources.

![Custom events viewer form showing all logs selected](./making-a-custom-view-all-logs.png)

![Custom events viewer form showing `dnclient-desktop`, `dnclientd`, and `dnclient.$(host-ID)` entered within the `Source` field](./making-a-custom-view-dnclient-desktop-sources.png)

</details>

### Config info \{#config-info-windows\}

:::note

This command will strip the private info such as [`pki.key`](https://nebula.defined.net/docs/config/pki#pkikey) from the config, allowing you to safely share the output with Defined Networking support while troubleshooting.

:::

```powershell
& 'C:\Program Files\Defined Networking\DNClient\dnclient.exe' info
```

### Service status \{#service-status-windows\}

The Server variant runs as the `dnclient` service, or `dnclient.<name>` for an instance enrolled with `-name`, and [DNClient Desktop](/docs/glossary/dnclient-desktop/) runs as the [`dnclientd`](/docs/glossary/dnclientd/) service. To check either one in PowerShell:

```powershell
Get-Service 'dnclient*' | Format-List Name, DisplayName, Status, StartType
```

```powershell
# outputs on a Server install
Name        : dnclient
DisplayName : Defined Networking Client
Status      : Running
StartType   : Automatic

# outputs on a Desktop install
Name        : dnclientd
DisplayName : Defined Networking Client Daemon
Status      : Running
StartType   : Automatic
```

<details>
<summary>View the service in the Services app</summary>

Open the Services app, and find the Defined Networking Client service in the list. You should be able to see the status and start or stop the service.

<Image
  src={windowsDnclientServiceStatus}
  alt="Services app showing the status of the DNClient service"
  style={{ maxWidth: "650px", width: "100%", marginInline: "auto", display: "block" }}
/>

</details>

## Android / iOS

### Logs \{#logs-android-ios\}

Tap on the site in question and tap "View Logs" on the details page for that site. You can then read, share, or delete your logs.

:::info

Logs are cleared each time a site is started.

:::

<Image
  src={viewingLogsOnMobile}
  alt="Nebula site details page in the mobile app, shows a 'Logs' option third from the top"
  class="screenshot-shadow"
  style={{ maxWidth: "390px", width: "100%", marginInline: "auto", display: "block" }}
/>
