Logging to elmah.io from Uno
The Uno integration for elmah.io is currently in prerelease.
Integrating Uno with elmah.io is done by installing the Elmah.Io.Uno
NuGet package:
Install-Package Elmah.Io.Uno -IncludePrerelease
dotnet add package Elmah.Io.Uno --prerelease
<PackageReference Include="Elmah.Io.Uno" Version="4.0.19-pre" />
paket add Elmah.Io.Uno
While configured in the shared project, the NuGet package will need to be installed in all platform projects.
Elmah.Io.Uno
comes with a logger for Microsoft.Extensions.Logging. To configure the logger, open the App.xaml.cs
file and locate the InitializeLogging
method. Here you will see the logging configuration for your application. Include logging to elmah.io by calling the AddElmahIo
method:
var factory = LoggerFactory.Create(builder =>
{
// ...
builder.AddElmahIo("API_KEY", new Guid("LOG_ID"));
// ...
});
Replace API_KEY
with your API key (Where is my API key?) and LOG_ID
(Where is my log ID?) with the log Id of the log you want to log to.
elmah.io will now automatically log all warning, error, and fatal messages to elmah.io. Uno log messages internally, but you can also do manual logging like this:
this.Log().LogWarning("Oh no");
Logging with Uno's log helper will require you to add the following usings:
using Microsoft.Extensions.Logging;
using Uno.Extensions;
This article was brought to you by the elmah.io team. elmah.io is the best error management system for .NET web applications. We monitor your website, alert you when errors start happening, and help you fix errors fast.
See how we can help you monitor your website for crashes Monitor your website