-
-
Notifications
You must be signed in to change notification settings - Fork 142
Configuration
The following sections will walk you through configuring Exceptionless to fit your specific requirements. The sections below assume that you already have an Exceptionless Api Key. You can find your Exceptionless Api Key by clicking on your project in the project list. Next, click on the Api Keys
tab to see your projects Api Keys.
- ExceptionlessClient Configuration
- Exceptionless Portable Class Library (PCL) Configuration
- WCF Configuration
- Offline Storage
- Disabling Exceptionless During Testing
- Custom Config Settings
- Adding Static Extended Data Values with Every Report
- Adding Custom Tags with Every Report
- Enabling Trace Message Collection
- Self Hosted Options
The examples below will show you the various ways (configuration file, attributes or code) the ExceptionlessClient may be configured. Please note that the package (Ex. Exceptionless.WebApi
) you are using will contain a detailed read me with the best way to configure the ExceptionlessClient for your specific platform.
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"?>
<configuration>
<configSections>
<section name="exceptionless" type="Exceptionless.ExceptionlessSection, Exceptionless.Extras" />
</configSections>
<!-- attribute names are cases sensitive -->
<exceptionless apiKey="API_KEY_HERE" />
...
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ExceptionlessModule" />
<add name="ExceptionlessModule" type="Exceptionless.Mvc.ExceptionlessModule, Exceptionless.Mvc" />
</modules>
...
</system.webServer>
</configuration>
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;
ExceptionlessClient.Default.Configuration.ReadFromAttributes(typeof(MyClass).Assembly)
using Exceptionless;
var client = new ExceptionlessClient(c => {
c.ApiKey = "YOUR_API_KEY";
c.SetVersion(version);
});
// You can also set the api directly on the default instance.
ExceptionlessClient.Default.Configuration.ApiKey = "YOUR_API_KEY"
You can also add a Environment Variable or Application setting with the key name Exceptionless:ApiKey
and your YOUR_API_KEY
as the value.
If you are using only the Exceptionless.Portable
package, you’ll need to configure exceptionless via attribute config or code. If you choose the attribute method, you’ll need to read the configuration on startup.
using Exceptionless;
ExceptionlessClient.Default.Configuration.ReadFromAttributes(typeof(MyClass).Assembly)
You will also need to wire up to any error handlers as the Exceptionless
PCL package doesn’t know what platform you are running on.
It’s also worth noting that when using the Exceptionless
PCL package you will the very basic feature set:
- Basic stacking of exceptions. PCL libraries don’t have access to an errors stack frames so they can’t be broken down.
- Basic
ISubmissionClient
that doesn’t support proxies. - No Environmental Information will be sent. For these reasons if you are on a known platform then use the platform specific package to save you time configuring while giving you more contextual information.
You can also configure exceptionless to capture all WCF exceptions following the steps below.
- Install the Exceptionless.Web NuGet package.
- Configure your Api Key (see the previous section).
- Add the ExceptionlessWcfHandleErrorAttribute to your WCF Classes.
using Exceptionless.Web;
[ExceptionlessWcfHandleErrorAttribute]
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.
<!-- Use Folder Storage -->
<exceptionless apiKey="YOUR_API_KEY" storagePath="PATH OR FOLDER NAME" />
// Use folder storage
ExceptionlessClient.Default.Configuration.UseFolderStorage("PATH OR FOLDER NAME");
// Use isolated storage
ExceptionlessClient.Default.Configuration.UseIsolatedStorage();
You can disable Exceptionless from reporting events during testing using the Enabled
setting.
<exceptionless apiKey="YOUR_API_KEY" enabled="false" />
using Exceptionless.Configuration;
[assembly: Exceptionless("YOUR_API_KEY", Enabled=false)]
Exceptionless allows you to add custom config values to your Exceptionless clients that can be set through the client config section, attributes or remotely on the project settings. These config values can be accessed and used within your app to control things like wether or not to send custom data with your reports. For example, you could have a IncludeOrderData
flag in your config that you use to control wether or not you add a custom order object to your Exceptionless report data. You can even remotely turn the setting on or off from your project settings. Here is an example of doing that:
<exceptionless apiKey="YOUR_API_KEY">
<settings>
<add name="IncludeOrderData" value="true" />
</settings>
</exceptionless>
using Exceptionless.Configuration;
[assembly: ExceptionlessSetting("IncludeOrderData", "true")]
Then in your app, you can check the setting and determine if you should include the order data or not:
using Exceptionless;
try {
...
} catch (Exception ex) {
var report = ex.ToExceptionless();
if (ExceptionlessClient.Default.Configuration.Settings["IncludeOrderData"] == "true")
report.AddObject(order);
report.Submit();
}
You can have the Exceptionless client automatically add extended data values to every report that it submits like this:
<exceptionless apiKey="YOUR_API_KEY">
<data>
<add name="Data1" value="Exceptionless"/>
<add name="Data2" value="10"/>
<add name="Data3" value="true"/>
<add name="Data4" value="{ 'Property1': 'Exceptionless', 'Property2: 10, 'Property3': true }"/>
</data>
</exceptionless>
using Exceptionless;
ExceptionlessClient.Default.Configuration.DefaultData["Data1"] = "Exceptionless";
You can have the Exceptionless client automatically add specific tags to every report that it submits like this:
<exceptionless apiKey="YOUR_API_KEY" tags="Tag1,Tag2" />
using Exceptionless;
ExceptionlessClient.Default.Configuration.DefaultTags.Add("Tag1");
One config setting built into Exceptionless can be used to include the last X trace log messages with your event reports. You can enable this setting by specifying a TraceLogLimit
setting with a value greater than 0. This value is the maxiumum number of trace messages that will be submitted with the event report.
<exceptionless apiKey="YOUR_API_KEY">
<settings>
<add name="TraceLogLimit" value="10" />
</settings>
</exceptionless>
using Exceptionless.Configuration;
[assembly: ExceptionlessSetting("TraceLogLimit", "10")]
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.
<exceptionless apiKey="YOUR_API_KEY" serverUrl="http://localhost" />
using Exceptionless.Configuration;
[assembly: Exceptionless("YOUR_API_KEY", ServerUrl = "http://localhost")]
Looking for General Exceptionless Documentation, UI Documentation, or Documentation for another Client?
Visit the Primary Exceptionless Documentation Page and go from there.