Skip to content

Latest commit

 

History

History
38 lines (25 loc) · 1.26 KB

README.md

File metadata and controls

38 lines (25 loc) · 1.26 KB

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.