Integrating as a TraceListener
Absolutely any .NET-based application that already uses the TraceListeners
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, TraceSources and TraceListeners).
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 the Rollbar API from now on. Make sure your app.config file looks similar to 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="17965fa5041749b6bf7095a190001ded"
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 and just add Rollbar specific configuration elements/sections within the same app.config file, for example, add something like this:
<configSections>
<section name="rollbar" type="Rollbar.NetFramework.RollbarConfigSection, Rollbar"/>
<section name="rollbarTelemetry" type="Rollbar.NetFramework.RollbarTelemetryConfigSection, Rollbar"/>
</configSections>
<rollbar
accessToken="17965fa5041749b6bf7095a190001ded"
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 flavor .NET Standard implementation used by your application does not support app.config files 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