Serilog Sinks Xamarin Save

A Serilog sink that writes events to Xamarin mobile targets

Project README

Serilog.Sinks.Xamarin Build status Join the chat at https://gitter.im/serilog/serilog

Writes Serilog events to the console of Xamarin.iOS (NSLog) / Xamarin.Android (AndroidLog).

Getting started

Install from NuGet:

Install-Package Serilog.Sinks.Xamarin

When using Xamarin.iOS

Log.Logger = new LoggerConfiguration()
    .WriteTo.NSLog()
    .CreateLogger();

When using Xamarin.Android

Log.Logger = new LoggerConfiguration()
    .WriteTo.AndroidLog()
    .Enrich.WithProperty(Constants.SourceContextPropertyName, "MyCustomTag") //Sets the Tag field.
    .CreateLogger();

Within your portable class libary or within your application

Log.Information("This will be written to either NSLog or AndroidLog");

Because the memory buffer may contain events that have not yet been written to the target sink, it is important to call Log.CloseAndFlush() or Logger.Dispose() when the application/activity exits.

Open Source Agenda is not affiliated with "Serilog Sinks Xamarin" Project. README Source: serilog/serilog-sinks-xamarin
Stars
54
Open Issues
4
Last Commit
8 months ago
License

Open Source Agenda Badge

Open Source Agenda Rating