Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.
C#
The log sits beside the real executable and rolls over at 20 MB
Alexander Graef837e73ce2730
diff --git a/WaveDudeNext.WPF/App.xaml.cs b/WaveDudeNext.WPF/App.xaml.csindex 05c15d4..92ceef8 100644--- a/WaveDudeNext.WPF/App.xaml.cs+++ b/WaveDudeNext.WPF/App.xaml.cs@@ -60,11 +60,19 @@ public partial class App : Applicationpublic static string LocalAppDataDirectory { get; } =Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WaveDudeNext");+ /// <summary>+ /// The folder the executable was started from: <see cref="Environment.ProcessPath"/>'s, not+ /// <see cref="AppContext.BaseDirectory"/>, which for the single-file publish is the bundle's extraction folder under+ /// %Temp% (2026-10-19, the user found the log there).+ /// </summary>+ public static string ExecutableDirectory { get; } =+ Path.GetDirectoryName(Environment.ProcessPath) is { Length: > 0 } folder ? folder : AppContext.BaseDirectory;+/// <summary>/// Path of the current log file. Next to the executable when that folder is writable,/// otherwise in <see cref="LocalAppDataDirectory"/>. Set by <see cref="SetupLoggingConfig"/>./// </summary>- public static string LogFile { get; private set; } = Path.Combine(AppContext.BaseDirectory, LogFileName);+ public static string LogFile { get; private set; } = Path.Combine(ExecutableDirectory, LogFileName);/// <summary>/// Replaces the NLog configuration with the application's targets: a rolling file next to@@ -80,10 +88,12 @@ public partial class App : Applicationvar fileTarget = new FileTarget("logfile"){FileName = LogFile,+ // one rolling file: it grows across sessions and rolls over at 20 MB, the previous one kept as the single+ // archive, so the last 20 to 40 MB are always there (the user's choice, 2026-10-19; archiving at every start+ // had left each session's log as an archive before anyone looked at it)ArchiveFileName = Path.ChangeExtension(LogFile, "archive.log"), // NLog 6 appends _00, _01 itself- MaxArchiveFiles = 2,- ArchiveAboveSize = 8 * 1024 * 1024,- ArchiveOldFileOnStartup = true,+ MaxArchiveFiles = 1,+ ArchiveAboveSize = 20 * 1024 * 1024,KeepFileOpen = true,Layout = FileLayout,};@@ -138,9 +148,9 @@ public partial class App : Application/// <summary>The executable's folder if a file can be created there, else <see cref="LocalAppDataDirectory"/>.</summary>private static string ResolveLogDirectory(){- if (IsWritable(AppContext.BaseDirectory))+ if (IsWritable(ExecutableDirectory)){- return AppContext.BaseDirectory;+ return ExecutableDirectory;}Directory.CreateDirectory(LocalAppDataDirectory);return LocalAppDataDirectory;diff --git a/WaveDudeNext.WPF/MainWindow.xaml.cs b/WaveDudeNext.WPF/MainWindow.xaml.csindex 95f88a5..29ae6ad 100644--- a/WaveDudeNext.WPF/MainWindow.xaml.cs+++ b/WaveDudeNext.WPF/MainWindow.xaml.cs@@ -538,9 +538,10 @@ public partial class MainWindow : WindowSettings.Default.Save();Logger.Debug("User settings saved");}- catch (ConfigurationErrorsException ex)+ catch (Exception ex) when (ex is ConfigurationErrorsException or IOException or UnauthorizedAccessException){- // Losing window placement or the recent list is not worth interrupting the user.+ // Losing window placement or the recent list is not worth interrupting the user. The file errors: two+ // instances closing at once replace the same user.config, and the second one finds it gone (2026-10-19)Logger.Warn(ex, "Could not save the user settings");}}