diff --git a/ExternalConnectors/ExternalConnectors.csproj b/ExternalConnectors/ExternalConnectors.csproj index 544cac65..db984ec7 100644 --- a/ExternalConnectors/ExternalConnectors.csproj +++ b/ExternalConnectors/ExternalConnectors.csproj @@ -11,8 +11,8 @@ - - + + diff --git a/mRemoteNG/App/Logger.cs b/mRemoteNG/App/Logger.cs index 7501cdd4..5667b04c 100644 --- a/mRemoteNG/App/Logger.cs +++ b/mRemoteNG/App/Logger.cs @@ -1,14 +1,11 @@ using System; using System.IO; -using System.Reflection; using System.Runtime.Versioning; using System.Windows.Forms; using log4net; using log4net.Appender; using log4net.Config; -using mRemoteNG.Properties; - -// ReSharper disable ArrangeAccessorOwnerBody +using log4net.Repository; namespace mRemoteNG.App { @@ -29,22 +26,27 @@ namespace mRemoteNG.App private void Initialize() { XmlConfigurator.Configure(LogManager.CreateRepository("mRemoteNG")); + if (string.IsNullOrEmpty(Properties.OptionsNotificationsPage.Default.LogFilePath)) + { Properties.OptionsNotificationsPage.Default.LogFilePath = BuildLogFilePath(); + } SetLogPath(Properties.OptionsNotificationsPage.Default.LogToApplicationDirectory ? DefaultLogPath : Properties.OptionsNotificationsPage.Default.LogFilePath); } public void SetLogPath(string path) { - var repository = LogManager.GetRepository("mRemoteNG"); + ILoggerRepository repository = LogManager.GetRepository("mRemoteNG"); + XmlConfigurator.Configure(repository, new FileInfo("log4net.config")); - var appenders = repository.GetAppenders(); + + IAppender[] appenders = repository.GetAppenders(); foreach (var appender in appenders) { - var fileAppender = (RollingFileAppender)appender; - if (fileAppender == null || fileAppender.Name != "LogFileAppender") continue; + RollingFileAppender fileAppender = (RollingFileAppender)appender; + if (fileAppender is not { Name: "LogFileAppender" }) continue; fileAppender.File = path; fileAppender.ActivateOptions(); } @@ -54,22 +56,26 @@ namespace mRemoteNG.App private static string BuildLogFilePath() { - var logFilePath = Runtime.IsPortableEdition ? GetLogPathPortableEdition() : GetLogPathNormalEdition(); - var logFileName = Path.ChangeExtension(Application.ProductName, ".log"); + string logFilePath = Runtime.IsPortableEdition ? GetLogPathPortableEdition() : GetLogPathNormalEdition(); + + string logFileName = Path.ChangeExtension(Application.ProductName, ".log"); + if (logFileName == null) return "mRemoteNG.log"; - var logFile = Path.Combine(logFilePath, logFileName); + + string logFile = Path.Combine(logFilePath, logFileName); + return logFile; } private static string GetLogPathNormalEdition() { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), - Application.ProductName); + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Application.ProductName); } private static string GetLogPathPortableEdition() { return Application.StartupPath; } + } } \ No newline at end of file diff --git a/mRemoteNG/Config/Serializers/ConnectionSerializers/Sql/DataTableSerializer.cs b/mRemoteNG/Config/Serializers/ConnectionSerializers/Sql/DataTableSerializer.cs index 27d4afbb..070e9494 100644 --- a/mRemoteNG/Config/Serializers/ConnectionSerializers/Sql/DataTableSerializer.cs +++ b/mRemoteNG/Config/Serializers/ConnectionSerializers/Sql/DataTableSerializer.cs @@ -52,7 +52,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql return Serialize(rootNode); } - catch (Exception ex) + catch (Exception) { return _dataTable; } diff --git a/mRemoteNG/mRemoteNG.csproj b/mRemoteNG/mRemoteNG.csproj index ac79b7b2..f5b6aedf 100644 --- a/mRemoteNG/mRemoteNG.csproj +++ b/mRemoteNG/mRemoteNG.csproj @@ -41,7 +41,7 @@ False 7 - True + False DEBUG;PORTABLE @@ -60,13 +60,13 @@ False 7 - True + False False True 7 - True + False diff --git a/mRemoteNGSpecs/mRemoteNGSpecs.csproj b/mRemoteNGSpecs/mRemoteNGSpecs.csproj index 9a39807d..c657925c 100644 --- a/mRemoteNGSpecs/mRemoteNGSpecs.csproj +++ b/mRemoteNGSpecs/mRemoteNGSpecs.csproj @@ -19,8 +19,11 @@ + + + diff --git a/mRemoteNGTests/mRemoteNGTests.csproj b/mRemoteNGTests/mRemoteNGTests.csproj index 7093f31b..6378a165 100644 --- a/mRemoteNGTests/mRemoteNGTests.csproj +++ b/mRemoteNGTests/mRemoteNGTests.csproj @@ -20,6 +20,7 @@ + all