diff --git a/src/SmartCommander/Program.cs b/src/SmartCommander/Program.cs
index a80e428..3495bc3 100644
--- a/src/SmartCommander/Program.cs
+++ b/src/SmartCommander/Program.cs
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.ReactiveUI;
+using Serilog;
using SmartCommander.Models;
using System;
using System.Diagnostics;
@@ -35,6 +36,14 @@ public static void Main(string[] args)
}
}
else {
+ Log.Logger = new LoggerConfiguration()
+ .MinimumLevel.Debug()
+#if DEBUG
+ .WriteTo.Console()
+#endif
+ .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day)
+ .CreateLogger();
+
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
}
diff --git a/src/SmartCommander/SmartCommander.csproj b/src/SmartCommander/SmartCommander.csproj
index 049823c..45f9823 100644
--- a/src/SmartCommander/SmartCommander.csproj
+++ b/src/SmartCommander/SmartCommander.csproj
@@ -51,7 +51,10 @@
-
+
+
+
+
diff --git a/src/SmartCommander/ViewModels/FileSearchViewModel.cs b/src/SmartCommander/ViewModels/FileSearchViewModel.cs
index 6dcdf74..c42c3af 100644
--- a/src/SmartCommander/ViewModels/FileSearchViewModel.cs
+++ b/src/SmartCommander/ViewModels/FileSearchViewModel.cs
@@ -1,5 +1,6 @@
using Avalonia.Threading;
using ReactiveUI;
+using Serilog;
using SmartCommander.Extensions;
using SmartCommander.ViewModels;
using System;
@@ -74,19 +75,18 @@ public async Task SearchAsync(string folderPath, string searchPattern, Can
cancellationToken.ThrowIfCancellationRequested();
await SearchAsync(subDir, searchPattern, cancellationToken);
}
- }
- // TODO: add logging
- /*
- catch (OperationCanceledException)
+ }
+ catch (OperationCanceledException e)
{
+ Log.Error("OperationCanceledException: " + e.Message);
}
catch (UnauthorizedAccessException e)
{
- }
- */
- catch (Exception)
+ Log.Error("UnauthorizedAccessException: " + e.Message);
+ }
+ catch (Exception e)
{
-
+ Log.Error("Exception: " + e.Message);
}
return true;