# Command Reference

## Creating a session ID <a href="#creating-a-session-id" id="creating-a-session-id"></a>

### Standard Session ID <a href="#standard-session-id" id="standard-session-id"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll config --appName <arg> --branchName <arg> --buildName <arg> --includeNamespace <arg> [--excludeNamespace <arg>] [--include <arg>] [--exclude <arg>] [--buildSessionId <arg> | --buildSessionIdFile <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="194">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>appName</code></td><td>Name of the application</td></tr><tr><td><code>branchName</code></td><td>The source branch of the application</td></tr><tr><td><code>buildName</code></td><td>The build label of the current build</td></tr><tr><td><code>includeNamespace</code></td><td>Comma-separated list of namespaces to include in scan.<br>Supports wildcards (* = any string, ? = any character, space character is not allowed). For example: <code>'com.example.*,io.*.demo,com.?ello.world'</code></td></tr><tr><td><code>excludeNamespace</code></td><td>Comma-separated list of packages to exclude from scan.<br>Supports wildcards (* = any string, ? = any character, space character is not allowed). For example: <code>'com.example.*,io.*.demo,com.?ello.world'</code></td></tr><tr><td><code>include</code></td><td>Comma-separated list of files to include in scan. Default: <code>*.exe, *.dll</code><br>Supports wildcards (* = any string, ? = any character, space character is not allowed). For example: <code>'*-with-dependencies.dll,bad-bad?.exe,*-source.dll'</code><br>This is a regex so to include all sub directories and files use the <code>.*</code></td></tr><tr><td><code>exclude</code></td><td>Comma-separated list of files to exclude from scan.<br>Supports wildcards (* = any string, ? = any character). For example: <code>'*-with-dependencies.dll,bad-bad?.exe,*-source.dll'</code></td></tr><tr><td><code>buildSessionId</code></td><td>Optional: A user provided session ID</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Optional: A user provided Build Session ID file.</td></tr><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr><tr><td><code>identifyMethodsByFqn</code></td><td>(optional) Allows the agent identify methods by the fully qualified name (FQN) and support pipelines with multiple compilations of the same version</td></tr><tr><td><code>quiet</code></td><td>Suppresses console feedback messages only. Does not suppress log output when logging is configured to print to the console. The default value is <code>false</code>.</td></tr></tbody></table>

### Pull Request Session ID <a href="#pull-request-session-id" id="pull-request-session-id"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll prConfig --appName <arg> --pullRequestNumber <arg> --targetBranch <arg> --latestCommit <arg> --repositoryUrl <arg> --includeNamespace <arg> [--excludeNamespace <arg>] [--include <arg>] [--exclude <arg>] [--buildSessionId <arg> | --buildSessionIdFile <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="199.3333740234375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>appName</code></td><td>Name of the application</td></tr><tr><td><code>pullRequestNumber</code></td><td>The number assigned to the Pull Request from the source control</td></tr><tr><td><code>targetBranch</code></td><td>The branch to which this PR will be merged into (already reported to SeaLights)</td></tr><tr><td><code>latestCommit</code></td><td>The full SHA of the last commit made to the Pull Request</td></tr><tr><td><code>repoUrl</code></td><td>The pull request URL for the PR to be scanned, up until the section before the <code>pullRequestNumber</code> value</td></tr><tr><td><code>includeNamespace</code></td><td>Comma-separated list of namespaces to include in scan.<br>Supports wildcards (* = any string, ? = any character, space character is not allowed). For example: <code>'com.example.*,io.*.demo,com.?ello.world'</code></td></tr><tr><td><code>excludeNamespace</code></td><td>Comma-separated list of packages to exclude from scan.<br>Supports wildcards (* = any string, ? = any character, space character is not allowed). For example: <code>'com.example.*,io.*.demo,com.?ello.world'</code></td></tr><tr><td><code>include</code></td><td>Comma-separated list of files to include in scan. Default: <code>*.exe, *.dll</code><br>Supports wildcards (* = any string, ? = any character, space character is not allowed). For example: <code>'*-with-dependencies.dll,bad-bad?.exe,*-source.dll'</code><br>This is a regex so to include all sub directories and files use the <code>.*</code></td></tr><tr><td><code>exclude</code></td><td>Comma-separated list of files to exclude from scan.<br>Supports wildcards (* = any string, ? = any character). For example: <code>'*-with-dependencies.dll,bad-bad?.exe,*-source.dll'</code></td></tr><tr><td><code>buildSessionId</code></td><td>Optional: A user provided session ID</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Optional: A user provided Build Session ID file.</td></tr><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr><tr><td><code>identifyMethodsByFqn</code></td><td>(optional) Allows the agent identify methods by the fully qualified name (FQN) and support pipelines with multiple compilations of the same version</td></tr></tbody></table>

## Scanning a build <a href="#scanning-a-build" id="scanning-a-build"></a>

### Scanning files <a href="#scanning-files" id="scanning-files"></a>

The project must contain all the PDB files!

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll scan {--buildSessionId <arg> | --buildSessionIdFile <arg>} --workspacePath <arg> --ignoreGeneratedCode true [--firstModule {true|false}] [--uniqueModuleId <arg>] [--baseDir <arg>] [--scm <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="196.666748046875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>buildSessionId</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>workspacePath</code></td><td>Path to the source workspace</td></tr><tr><td><code>firstModule</code></td><td>Must be provided when scanning the first module</td></tr><tr><td><code>uniqueModuleId</code></td><td>A unique module ID to be used for seperate modules</td></tr><tr><td><code>baseDir</code></td><td>Base path where all relative paths should start from. By default the agent searches for the solution file and uses its path for this value</td></tr><tr><td><code>hashingAlgorithm</code></td><td>Hashing algorithm to use. Available options are md5 (default), sha1, sha256, sha384, sha512</td></tr><tr><td><code>scm</code></td><td>The SCM that is used in order to provide integration with. Values: auto, git, none</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr><tr><td><code>ExtraScanDir</code></td><td>Scan additional folder to collect more runtime components (.git/dll/exe ) for scanning. The path is an absolute path.</td></tr><tr><td><code>extraDbgSearchDirs</code></td><td>Comma-separated list of absolute paths to the folders where the agent will recursively search for *.pdb files</td></tr><tr><td><code>quiet</code></td><td>Suppresses console feedback messages only. Does not suppress log output when logging is configured to print to the console. The default value is <code>false</code>.</td></tr></tbody></table>

### Ending multi-modules scan <a href="#ending-multi-modules-scan" id="ending-multi-modules-scan"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll reportBuildStatus {--buildSessionId <arg> | --buildSessionIdFile <arg>} --success <true|false> [--message <arg>] [--duration <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

| Parameter            | Description                                                                  |
| -------------------- | ---------------------------------------------------------------------------- |
| `token`              | Access token generated from the SeaLights server                             |
| `tokenFile`          | Path to file containing the access token generated from the SeaLights server |
| `buildSessionId`     | Session ID of configuration created                                          |
| `buildSessionIdFile` | Path to file containing the Session ID of configuration created              |
| `success`            | Indicates that the build succeeded (considered failed if not specified)      |
| `message`            | Additional build status message to report (optional)                         |
| `duration`           | Build duration in milliseconds (optional)                                    |

## Coverage Collection operation <a href="#coverage-collection-operation" id="coverage-collection-operation"></a>

### Starting the Application/Process via the Agent (`run` command) <a href="#starting-the-application-process-via-the-agent-run-command" id="starting-the-application-process-via-the-agent-run-command"></a>

A single process can be run with the SeaLights agent as a test listener to capture the test footprints or events from a testing framework (like MSTest, NUnit, and XUnit).

{% hint style="warning" %}
The `buildSessionId` and `buildSessionIdFile` parameters are **deprecated** for external test-runner commands. Use `labId` instead. These parameters remain supported for in-process testing (Unit Tests, Integration Tests, Component Tests).
{% endhint %}

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll run {--buildSessionId <arg> | --buildSessionIdFile <arg>} --target <arg> [--workingDir <arg>] [--instrumentationMode {tests|coverage|testsAndCoverage}] [--targetArgs <arg>] [--labId <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]] [--profilerRegistrationMethod <path32|path64>]
```

{% endcode %}

<table><thead><tr><th width="248.66668701171875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>buildSessionId</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>target</code></td><td>Name of the application to run with the test listener</td></tr><tr><td><code>workingDir</code></td><td>Path to working directory. Current working directory will be used if not specified</td></tr><tr><td><code>profilerRegistrationMethod</code></td><td>Sets the COM32 profiler DLL registration method.</td></tr><tr><td><code>targetArgs</code></td><td>Command line arguments to pass the target application</td></tr><tr><td><code>labId</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr><tr><td><code>tags</code></td><td>(Optional) One or several tags (comma separated) to be passed to Sealights in order to label this instance in the cockpit.<br>Any free text (without spaces) is allowed, like <code>--tags tag1,tag2</code></td></tr><tr><td><code>instrumentationMode</code></td><td><p>(Optional) Set instrumentation mode, default value is <code>testsAndCoverage</code>.<br>Possible values:</p><ul><li><code>tests</code> reporting test events only (for functional testing)</li><li><code>coverage</code> reporting coverage only (for agent connected to the application under test)</li><li><code>testsAndCoverage</code> reporting both test and coverage (for In-Process testing like Unit Tests, Integraiton Tests or Components Tests)</li></ul></td></tr><tr><td><code>tiaDisabled</code></td><td>(Optional) Set to <code>true</code> to disable getting TIA Recommendations from Sealights Backend (Default: <code>false</code>).</td></tr><tr><td><code>quiet</code></td><td>Suppresses console feedback messages only. Does not suppress log output when logging is configured to print to the console. The default value is <code>false</code>.</td></tr></tbody></table>

### Configuring a Background Listener <a href="#configuring-a-background-listener" id="configuring-a-background-listener"></a>

#### Environment variables required for Background test listener <a href="#environment-variables-required-for-background-test-listener" id="environment-variables-required-for-background-test-listener"></a>

You need to run your process with the following environment variables:

{% tabs %}
{% tab title=".NET Core/ Windows" %}
{% code overflow="wrap" lineNumbers="true" %}

```
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={01CA2C22-DC03-4FF5-8350-59E32A3536BA}
CORECLR_PROFILER_PATH_32=SL.DotNet.ProfilerLib.Windows_x86.dll
CORECLR_PROFILER_PATH_64=SL.DotNet.ProfilerLib.Windows_x64.dll
SL_CollectorId=SL_Agent
```

{% endcode %}
{% endtab %}

{% tab title=".NET Core/Linux" %}
{% code overflow="wrap" lineNumbers="true" %}

```
CORECLR_ENABLE_PROFILING=1
CORECLR_PROFILER={3B1DAA64-89D4-4999-ABF4-6A979B650B7D}
CORECLR_PROFILER_PATH_32=libSL.DotNet.ProfilerLib.Linux.so
CORECLR_PROFILER_PATH_64=libSL.DotNet.ProfilerLib.Linux.so
SL_CollectorId=SL_Agent
```

{% endcode %}
{% endtab %}
{% endtabs %}

<table><thead><tr><th width="250">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>CORECLR_ENABLE_PROFILING</code></td><td>Enable Sealights profiling to capture coverage by setting the value to 1.</td></tr><tr><td><code>CORECLR_PROFILER</code></td><td>Linux: <code>{3B1DAA64-89D4-4999-ABF4-6A979B650B7D}</code><br>Windows: <code>{01CA2C22-DC03-4FF5-8350-59E32A3536BA}</code></td></tr><tr><td><code>CORECLR_PROFILER_PATH_32</code></td><td><p>Name of the profiler executable for an <strong>x86</strong> architecture:</p><ul><li>Linux: <code>libSL.DotNet.ProfilerLib.Linux.so</code></li><li>Windows: <code>SL.DotNet.ProfilerLib.Windows_x86.dll</code></li></ul></td></tr><tr><td><code>CORECLR_PROFILER_PATH_64</code></td><td><p>Name of the profiler executable for an <strong>x64</strong> architecture:</p><ul><li>Linux: <code>libSL.DotNet.ProfilerLib.Linux.so</code></li><li>Windows: <code>SL.DotNet.ProfilerLib.Windows_x64.dll</code></li></ul></td></tr><tr><td><code>SL_CollectorId</code></td><td>A random alphanumeric ID that was provided during the startBackgroundTestListener</td></tr><tr><td><code>SL_LogLevel</code></td><td>Optional: Level of logs to generate - Default is 0 (none), Fatal=1, Error=4, Debug=6, All=999</td></tr><tr><td><code>SL_LogDir</code></td><td>Optional: Folder to save log files in</td></tr></tbody></table>

#### Starting Background test listener <a href="#starting-background-test-listener" id="starting-background-test-listener"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll startBackgroundTestListener {--buildSessionId <arg> | --buildSessionIdFile <arg>} --testListenerSessionKey <arg> [--labId <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="230">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>buildSessionId</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>testListenerSessionKey</code></td><td><p>A random alphanumeric ID (%RANDOM% in command line)</p><p>This ID needs to be passed to any process that you want to capture cover</p></td></tr><tr><td><code>labId</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr></tbody></table>

#### Stop Background test listener <a href="#stop-background-test-listener" id="stop-background-test-listener"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll stopBackgroundTestListener {--buildSessionId <arg> | --buildSessionIdFile <arg>} --testListenerSessionKey <arg> [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="216.6666259765625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>buildSessionId</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>testListenerSessionKey</code></td><td>A random alphanumeric ID that was provided during the startBackgroundTestListener</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr></tbody></table>

### MS Windows - Specific commands <a href="#ms-windows-specific-commands" id="ms-windows-specific-commands"></a>

#### Installing/Uninstalling the Coverage Collector service <a href="#installing-uninstalling-the-coverage-collector-service" id="installing-uninstalling-the-coverage-collector-service"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
SL.DotNet.CoverageCollectorService.exe {install {start} | unsinstall }
```

{% endcode %}

<table><thead><tr><th width="136.6666259765625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>install</code></td><td>Install the Coverage Collector Service</td></tr><tr><td><code>start</code></td><td>Start the service</td></tr><tr><td><code>uninstall</code></td><td>Uninstall the service. This command should be executed alone.<br>This is commonly used when upgrading your agent version, as it is needed to uninstall the coverage collector service from the machine first.</td></tr></tbody></table>

#### Register the Profiler for a Windows Service <a href="#register-the-profiler-for-a-windows-service" id="register-the-profiler-for-a-windows-service"></a>

This command will add the Environment `REG_MULTI_SZ` record to the target service inside the Windows registry (Related Windows Registry path: `Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services`) with a list of the environment variables required to start the Sealights profiler.

{% code overflow="wrap" lineNumbers="true" %}

```
SL.DotNet.exe instrumentService --serviceName <arg> {--force} {--undo}
```

{% endcode %}

<table><thead><tr><th width="131.33331298828125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>serviceName</code></td><td>REQUIRED Target service name</td></tr><tr><td><code>force</code></td><td>Forces overwriting existing registry entries. Default value: <code>false</code></td></tr><tr><td><code>undo</code></td><td>Unregister the Profiler and removes the Environment Variables from the Registry.</td></tr></tbody></table>

#### Register the Profiler for IIS <a href="#register-the-profiler-for-iis" id="register-the-profiler-for-iis"></a>

This command registers the Sealight profiler with two specific IIS services: `WAS` and `W3SVC`. So this command is equivalent to `instrumentService` running twice (for each of these IIS services).

`SL.DotNet.exe instrumentIIS {--force}`

| Parameter | Description                                                                      |
| --------- | -------------------------------------------------------------------------------- |
| `force`   | Forces overwriting existing registry entries. Default value: `false`             |
| `undo`    | Unregister the Profiler and removes the Environment Variables from the Registry. |

#### Starting coverage collection session <a href="#starting-coverage-collection-session" id="starting-coverage-collection-session"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
SL.DotNet.exe startCollectorServiceSession {--buildSessionId <arg> | --buildSessionIdFile <arg>} [--labId <arg>] --processName <arg> --applicationPool <arg> --includeChildProcesses {true|false} [--token <arg> | --tokenFile <arg>] [--machine <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="198">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>buildSessionId</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>processName</code></td><td><ul><li>Name of the executable to collect coverage from.</li><li>If you’re running several services on the machine, you can use <code>--processName *</code> and every service having the Sealights' environment variables defined in its Registry entry will be metered</li><li>For .NET Core processes, set <code>--processName dotnet</code>, as this is the name of the process on which .NET Core applications run.</li><li>For IIS, provide <code>w3wp.exe</code></li></ul></td></tr><tr><td><code>applicationPool</code></td><td><p>For IIS, provide the Application pool.</p><p>Since there could be multiple applications running on a single IIS server, it is important to make note of the Application Pool name that corresponds to the hosted application from which coverage will be collected. You can provide a star (<code>*</code>) to the <code>applicationPool</code> parameter in order to capture of all the Application Pools at once. This start (<code>*)</code> option can be used for troubleshooting or if your IIS server is dedicated to your application but is not necessarily defined as a best practice.</p></td></tr><tr><td><code>labId</code></td><td>Unique ID for a set of test labs in case multiple labs are running simultaneously</td></tr><tr><td><code>machine</code></td><td>(Optional) IIS Host to start the session remotely on.</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through. To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr></tbody></table>

#### Stopping coverage collection session <a href="#stopping-coverage-collection-session" id="stopping-coverage-collection-session"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
SL.DotNet.exe stopCollectorServiceSession --stopAllSessions --processName <arg> --applicationPool <arg> [--machine <arg>]
```

{% endcode %}

<table><thead><tr><th width="174">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>stopAllSessions</code></td><td>Close all the sessions at once.</td></tr><tr><td><code>processName</code></td><td><ul><li>If you’re running several services on the machine, you can use <code>--processName *</code> and every service having the Sealights' environment variables defined in its Registry entry will be metered</li><li>For .NET Core processes, set <code>--processName dotnet</code>, as this is the name of the process on which .NET Core applications run.</li><li>For IIS, provide <code>w3wp.exe</code></li></ul></td></tr><tr><td><code>applicationPool</code></td><td><p>For IIS, provide the Application pool.</p><p>Since there could be multiple applications running on a single IIS server, it is important to make note of the Application Pool name that corresponds to the hosted application from which coverage will be collected. You can provide a star (<code>*</code>) to the <code>applicationPool</code> parameter in order to stop capture of all the Application Pools at once.</p></td></tr><tr><td><code>labId</code></td><td>Unique ID for a set of test labs in case multiple labs are running similtaniously</td></tr><tr><td><code>machine</code></td><td>(Optional) IIS Host to stop the session remotely on.</td></tr></tbody></table>

## Reporting a Test Stage <a href="#reporting-a-test-stage" id="reporting-a-test-stage"></a>

### Starting a test stage <a href="#starting-a-test-stage" id="starting-a-test-stage"></a>

{% code overflow="wrap" lineNumbers="true" %}

```
dotnet ./<agent-path>/SL.DotNet.dll startExecution {--buildSessionId <arg> | --buildSessionIdFile <arg>} --testStage <arg> [--labId <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

<table><thead><tr><th width="196.6666259765625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td>Access token generated from the SeaLights server</td></tr><tr><td><code>tokenFile</code></td><td>Path to file containing the access token generated from the SeaLights server</td></tr><tr><td><code>buildSessionId</code></td><td>Session ID of configuration created</td></tr><tr><td><code>buildSessionIdFile</code></td><td>Path to file containing the Session ID of configuration created</td></tr><tr><td><code>testStage</code></td><td>Name of the test stage</td></tr><tr><td><code>labId</code></td><td>Unique ID for a set of test labs in case multiple labs are running similtaniously</td></tr><tr><td><code>proxy</code></td><td>Address of proxy to run connection through. To use the system proxy just provide the value 'system'</td></tr><tr><td><code>proxyUsername</code></td><td>The proxy username if needed</td></tr><tr><td><code>proxyPassword</code></td><td>The proxy password if needed</td></tr></tbody></table>

### Upload report files <a href="#upload-report-files" id="upload-report-files"></a>

{% code overflow="wrap" %}

```
dotnet ./<agent-path>/SL.DotNet.dll uploadTestReport {--buildSessionId <arg> | --buildSessionIdFile <arg>} --testStage <arg> --report <arg> [--labId <arg>] [--token <arg> | --tokenFile <arg>] [proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

| `token`              | Access token generated from the SeaLights server                                                                                                                                   |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tokenFile`          | Path to file containing the access token generated from the SeaLights server                                                                                                       |
| `buildSessionId`     | Session ID of configuration created                                                                                                                                                |
| `buildSessionIdFile` | Path to file containing the Session ID of configuration created                                                                                                                    |
| `testStage`          | Name of the test stage                                                                                                                                                             |
| `report`             | Path to report file or directory containing all the valid reports (Non recursive). Supported formats are MSTest (TRX files), [xUnit.Net](http://xunit.net/) and NUnit (XML files). |
| `labId`              | Unique ID for a set of test labs in case multiple labs are running simultaneously                                                                                                  |
| `proxy`              | Address of proxy to run connection through. To use the system proxy just provide the value '`system`'.                                                                             |
| `proxyUsername`      | The proxy username if needed                                                                                                                                                       |
| `proxyPassword`      | The proxy password if needed                                                                                                                                                       |

### Ending a test stage <a href="#ending-a-test-stage" id="ending-a-test-stage"></a>

{% code overflow="wrap" %}

```
dotnet ./<agent-path>/SL.DotNet.dll endExecution {--buildSessionId <arg> | --buildSessionIdFile <arg>} --testStage <arg> [--labId <arg>] [--token <arg> | --tokenFile <arg>] [--proxy <arg> [--proxyUsername <arg> --proxyPassword <arg>]]
```

{% endcode %}

| `token`              | Access token generated from the SeaLights server                                                             |
| -------------------- | ------------------------------------------------------------------------------------------------------------ |
| `tokenfile`          | Path to file containing the access token generated from the SeaLights server                                 |
| `buildsessionid`     | Session ID of configuration created                                                                          |
| `buildsessionidfile` | Path to file containing the Session ID of configuration created                                              |
| `labId`              | Unique ID for a set of test labs in case multiple labs are running similtaniously                            |
| `proxy`              | <p>Address of proxy to run connection through<br>To use the system proxy just provide the value 'system'</p> |
| `proxyUsername`      | The proxy username if needed                                                                                 |
| `proxyPassword`      | The proxy password if needed                                                                                 |

## **Logging** <a href="#logging" id="logging"></a>

If you're facing technical issue, you can consult our dedicated FAQ section at [https://github.com/Sealights/gitbook.setupandconfiguration/blob/master/troubleshooting-faq/.net-.netcore](https://github.com/Sealights/gitbook.setupandconfiguration/blob/master/troubleshooting-faq/.net-.netcore "mention") as we’ve listed there the most common problems and solutions for your benefit.

### Agents Commands <a href="#agents-commands" id="agents-commands"></a>

To enable logs when executing direct agent commands, you can set the following parameters with any of the above commands\
Both console output and file options are compatible and non-exclusive.

For logging into the console and a file, add

{% code overflow="wrap" lineNumbers="true" %}

```
--logPreset Debug --logDir C:\Sealights\Logs\
```

{% endcode %}

For logging only into the console, add

{% code overflow="wrap" lineNumbers="true" %}

```
--logPreset Debug --logAppendFile false
```

{% endcode %}

<table><thead><tr><th width="259.333251953125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>logPreset</code></td><td>Set the log preset. Allows managing several log-related options at once and has precedence on <code>LOG_LEVEL</code>. The default preset is <code>Default</code>. See below the available options.</td></tr><tr><td><code>logAppendConsole</code></td><td>Set to false to disable log output to the console. Default is true.</td></tr><tr><td><code>logAppendFile</code></td><td>Set to true to enable log output to a file</td></tr><tr><td><code>logFilename</code></td><td>Provide the name of the log file</td></tr><tr><td><code>profilerLogLevel</code></td><td>Level of logs to generate by the Profiler entity as a Integer value: Default is 0 (none), Fatal=1, Error=4, Debug=6, All=999<br>Value from this options will be passed to the environment variable <code>SL_LogLevel</code>.<br>This option is available only for a subset of the agent’s commands (<code>run</code>, <code>cdAgent</code>, <code>instrumentService</code>, <code>instrumentIIS</code>)</td></tr><tr><td><code>profilerLogDir</code></td><td>Folder to save Profiler log files in. Value from this options will be passed to the environment variable <code>SL_LogDir</code>.<br>This option is available only for a subset of the agent’s commands (<code>run</code>, <code>cdAgent</code>, <code>instrumentService</code>, <code>instrumentIIS</code>)</td></tr><tr><td><code>enablePerformanceMonitoring</code></td><td>Set to true to enable performance monitoring of the host machine. Default value: <code>false</code><br>Write a warning to the log if resource usage exceeded threshold of 90%. Available metrics: CPU, RAM, Network Usage.<br>Note: This option is available only for collector-related commands (<code>cdAgent</code>, <code>run</code>, <code>startBackgroundTestListener</code>)</td></tr></tbody></table>

### Environment variables (Profiler, Collector, Background Listener...) <a href="#background-listener" id="background-listener"></a>

To enable logs, you can add the following environment variables to the registry in addition to the regular variables set for the Profiler.\
If the below variables are set, any agent’s command will print values in the configuration data (in the Profiler section).

<table><thead><tr><th width="362">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>SL_LOGGING_LOGPRESET</code></td><td>Set the log preset. Allows managing several log-related options at once and has precedence on <code>LOG_LEVEL</code>. The default preset is <code>Default</code>. <em>See below table for the detailed available options.</em></td></tr><tr><td><code>SL_LOGLEVEL</code></td><td>Level of logs to generate : <code>Disabled</code>, <code>Critical</code> , <code>Error</code> , <code>Warn</code> , <code>Info</code> (Default) , <code>Debug</code> , <code>Trace</code></td></tr><tr><td><code>SL_LOGGING_TOCONSOLE</code></td><td>Enables or disables logging to the console. Default value: <em>true</em></td></tr><tr><td><code>SL_LOGGING_TOFILE</code></td><td>Enables or disables logging into a file. Default value: <em>false</em></td></tr><tr><td><code>SL_LOGDIR</code> (or <code>SL_LOGDIRECTORY</code>)</td><td>Set the directory for logs for <strong>both the collector and the profiler</strong>. The default value depends on the OS: "<code>.\logs</code>" for Windows and "<code>/var/log/sealights</code>" for Linux</td></tr><tr><td><code>SL_LOGGING_FILENAME</code></td><td>Sets the collector’s log file name relative to the <code>SL_LOGDIR</code> set above. Default value: <code>cli_{command}_{time}_{pid}.log</code></td></tr><tr><td><code>SL_FEATURES_ENABLEPERFORMANCEMONITORING</code></td><td>Enable performance monitoring of the host machine — available metrics: CPU, RAM, Network Usage. Write a warning to the log if resource usage exceeds the threshold of 90%. (Default is <code>false</code>)</td></tr><tr><td><code>SL_PROFILER_LOGLEVEL</code></td><td>Set to <code>none</code> to disable logging from the Profilers. This restricts output exclusively to the Collector's logs, simplifying troubleshooting.</td></tr></tbody></table>

### Available logging presets

<table><thead><tr><th width="168.6666259765625">Option value</th><th>Description</th></tr></thead><tbody><tr><td><code>Default</code></td><td>Do nothing. Default value</td></tr><tr><td><code>Disabled</code></td><td>Disable logs. Set <code>LogLevel</code> to “<code>Disabled</code>”</td></tr><tr><td><code>Debug</code></td><td><p>Debug mode.</p><p>Set <code>LogLevel</code> to “<code>Debug</code>” and <code>LogAppendFile</code> to “<code>True</code>”</p></td></tr><tr><td><code>Diagnostic</code></td><td><p>Diagnostics mode. The same as Debug, plus enabled perf metrics</p><p>Set <code>LogLevel</code> to <code>Debug</code>, <code>LogAppendFile</code> and <code>EnablePerformanceMonitoring</code> to <code>True</code></p></td></tr></tbody></table>
