A .NET Rollbar Client that can be used in any application built on the following .NET versions: .NET Core 2.0+, .NET Standard 2.0+, and .NET Full Framework 4.5+.
Nuget Package Manager:
Install-Package Rollbar
The SDK is designed to have as little impact on the hosting system or application as possible. Normally, you want to use asynchronous logging, since it has virtually no instrumentational overhead on your application execution performance at runtime. It has a "fire and forget" approach to logging.
However, in some specific situations (such as while logging right before exiting an application), you may want to use it synchronously so that the application does not quit before the logging completes.
That is why all the logging methods of the ILogger
interface imply asynchronous/non-blocking implementation. However, the ILogger
interface defines the AsBlockingLogger(TimeSpan timeout)
method that returns a synchronous implementation of the same ILogger
. This approach allows for easier code refactoring when switching between asynchronous and synchronous uses of the logger.
Therefore, the following call will perform async logging:
RollbarLocator.RollbarInstance.Log(ErrorLevel.Error, "test message");
While this call will perform blocking/synchronous logging with a timeout of 1 second:
RollbarLocator.RollbarInstance.AsBlockingLogger(TimeSpan.FromSeconds(5)).Log(ErrorLevel.Error, "test message");
In case of a timeout, all the blocking log methods throw System.TimeoutException
instead of gracefully completing the call. Therefore you might want to make all the blocking log calls within a try-catch block while catching System.TimeoutException
specifically to handle a timeout case.
- Configure Rollbar with
RollbarLocator.RollbarInstance.Configure(new RollbarConfig("POST_SERVER_ITEM_ACCESS_TOKEN"))
- Send errors (asynchronously) to Rollbar with
RollbarLocator.RollbarInstance.Error(Exception)
- Send messages (synchronously) to Rollbar with
RollbarLocator.RollbarInstance.AsBlockingLogger(TimeSpan.FromSeconds(5)).Info(string)
In order to upgrade to v1.0.0+ from an earlier version, you should change your config from the old version
Rollbar.Init(new RollbarConfig("POST_SERVER_ITEM_ACCESS_TOKEN"));
to
const string postServerItemAccessToken = "POST_SERVER_ITEM_ACCESS_TOKEN";
RollbarLocator.RollbarInstance
.Configure(new RollbarConfig(postServerItemAccessToken) { Environment = "proxyTest" }) ;
Additionally, anywhere in your code that you were sending error reports via Rollbar.Report(Exception)
or Rollbar.Report(string)
will need to be replaced with either something like RollbarLocator.RollbarInstance.Error(new Exception("trying out the TraceChain", new NullReferenceException()))
or RollbarLocator.RollbarInstance.Info("Basic info log example.")
.
More detailed information about Rollbar.NET usage and API reference are available at https://docs.rollbar.com/docs/dotnet
If you run into any issues, please email us at support@rollbar.com
You can also find us in IRC: #rollbar on chat.freenode.net
For bug reports, please open an issue on GitHub.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
). - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request