Skip to content

Instantly share code, notes, and snippets.

@dmitry-osin
Created February 28, 2016 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitry-osin/46594deac08827e99223 to your computer and use it in GitHub Desktop.
Save dmitry-osin/46594deac08827e99223 to your computer and use it in GitHub Desktop.
private async void ConfigurateLogger()
{
StorageFolder logsFolder = null;
try
{
logsFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("Logs");
}
catch (Exception)
{
}
if (logsFolder == null)
{
logsFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Logs");
var file = await logsFolder.CreateFileAsync("Log.txt",
CreationCollisionOption.ReplaceExisting);
using (var stream = await file.OpenStreamForWriteAsync())
{
Log.Logger = new LoggerConfiguration().WriteTo
.TextWriter(new StreamWriter(stream))
.CreateLogger();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment