There are a few ways to configure Exceptionless in your project. We'll cover them here or you can jump to app-specific examples: Console App Example, Web Server Example.

ExceptionlessClient Configuration #

The examples below show the various ways (configuration file, attributes or code) that Exceptionless can be configured in your application.

Configuring With Code #

using Exceptionless;

var client = new ExceptionlessClient(c => {
c.ApiKey = "YOUR_API_KEY";

// You can also set the api key directly on the default instance.
ExceptionlessClient.Default.Configuration.ApiKey = "YOUR_API_KEY"

Configuring With Attributes #

You can also configure Exceptionless using attributes like this:

using Exceptionless.Configuration;
[assembly: Exceptionless("YOUR_API_KEY")]

The Exceptionless assembly attribute will only be picked up if it’s defined in the entry or calling assembly. If you have placed the above attribute in different location you’ll need to call the method below during startup.

using Exceptionless;

Configuring With Environment Variables #

You can also add an Environment variable or application setting with the key name Exceptionless:ApiKey and your YOUR_API_KEY as the value.

Using Web.config #

Exceptionless can be configured using a config section in your web.config or app.config depending on what kind of project you have. Installing the correct NuGet package should automatically add the necessary configuration elements. It should look like this:

<?xml version="1.0" encoding="utf-8"?>
<section name="exceptionless" type="Exceptionless.ExceptionlessSection, Exceptionless" />
<!-- attribute names are cases sensitive -->
<exceptionless apiKey="API_KEY_HERE" />
<remove name="ExceptionlessModule" />
<add name="ExceptionlessModule" type="Exceptionless.Mvc.ExceptionlessModule, Exceptionless.Mvc" />

Versioning #

By specifying an application version you can enable additional functionality. By default, an application version will try to be resolved from assembly attributes. However, it's a good practice to specify an application version if possible using the code below.

using Exceptionless;

Offline storage #

Events can also be persisted to disk for offline scenarios or to ensure no events are lost between application restarts. When selecting a folder path, make sure that the identity the application is running under has full permissions to that folder.

Please note that this adds a bit of overhead as events need to be serialized to disk on submission and is not recommended for high throughput logging scenarios.

Configuration File #

<!-- Use Folder Storage -->
<exceptionless apiKey="YOUR_API_KEY" storagePath="PATH OR FOLDER NAME" />

Code #

// Use folder storage
ExceptionlessClient.Default.Configuration.UseFolderStorage("PATH OR FOLDER NAME");
// Use isolated storage

Disabling Exceptionless #

You can disable Exceptionless from reporting events during testing using the Enabled setting.

Configuration File #

<exceptionless apiKey="YOUR_API_KEY" enabled="false" />

Attribute #

using Exceptionless.Configuration;
[assembly: Exceptionless("YOUR_API_KEY", Enabled=false)]

Self Hosted Options #

The Exceptionless client can also be configured to send data to your self hosted instance. This is configured by setting the serverUrl setting to point to your Exceptionless instance.

Configuration file #

<exceptionless apiKey="YOUR_API_KEY" serverUrl="http://localhost" />

Attribute #

using Exceptionless.Configuration;
[assembly: Exceptionless("YOUR_API_KEY", ServerUrl = "http://localhost")]

Next > Client Configuration Values