Integrating as a TraceListener
Absolutely any .NET-based application that already uses the TraceListeners
For the working sample, please look here.
You can start quickly enjoying all the benefits of Rollbar API services if you are already actively using .NET's built-in tracing infrastructure (aka, TraceSource
s and TraceListener
s).
And you do not even need to recompile your .NET Framework-based application - just configure RollbarTraceListener
within your app.config
file, drop the Rollbar.dll
side-by-side with the config file, and restart the application so that all your traces will be forwarded to Rollbar from now on. Make sure your app.config
file looks like this example:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="textFileListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="TextTrace.log"
traceOutputOptions="ProcessId, ThreadId, Timestamp, DateTime, Callstack,LogicalOperationStack"
/>
<add name="rollbarListener"
type="Rollbar.NetStandard.RollbarTraceListener,Rollbar"
traceOutputOptions="ProcessId, ThreadId, Timestamp, DateTime, Callstack,LogicalOperationStack"
rollbarAccessToken="TOKEN"
rollbarEnvironment="RollbarNetSamples"
/>
<remove name="Default"/>
</listeners>
</trace>
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
If you need more control over the Rollbar notifier's static instance that is used by the RollbarTraceListener, do not specify rollbarAccessToken and rollbarEnvironment attributes in the example above. Just add Rollbar specific configuration elements/sections within the same app.config file. Here is a sample setup:
<configSections>
<section name="rollbar" type="Rollbar.NetFramework.RollbarConfigSection, Rollbar"/>
<section name="rollbarTelemetry" type="Rollbar.NetFramework.RollbarTelemetryConfigSection, Rollbar"/>
</configSections>
<rollbar
accessToken="TOKEN"
environment="unit-tests"
enabled="true"
scrubFields="ThePassword, Secret"
scrubWhitelistFields="ThePassword"
logLevel="Info"
maxReportsPerMinute="160"
reportingQueueDepth="120"
personDataCollectionPolicies="Username, Email"
ipAddressCollectionPolicy="CollectAnonymized"
/>
<rollbarTelemetry
telemetryEnabled="true"
telemetryQueueDepth="100"
telemetryAutoCollectionTypes="Network, Log, Error"
telemetryAutoCollectionInterval="00:00:00.3000000"
/>
However, if the .NET Standard implementation used by your application does not support app.config files you can drop our Rollbar.App.Config.dll
assembly (from the Rollbar.App.Config module/package) side-by-side with your executable and it will aid in reading the rollbar
config section. Or, you can always configure Rollbar singleton in code as well as add a RollbarTraceListener
instance (that will be using the just configured Rollbar singleton) to the tracing infrastructure in code (exactly as any other TraceListener
). But in this case, you will have to recompile your application.
Updated about 1 year ago