Skip to content
Snippets Groups Projects
Commit f567360b authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Move logger setup to separate method.

Refers to #2
parent 7dda7b63
No related branches found
No related tags found
No related merge requests found
...@@ -60,21 +60,8 @@ namespace ATxTray ...@@ -60,21 +60,8 @@ namespace ATxTray
private static DirectoryInfo _selectedDir; private static DirectoryInfo _selectedDir;
public AutoTxTray(string baseDir) { public AutoTxTray(string baseDir) {
#region logging configuration
var logConfig = new LoggingConfiguration(); SetupLogging();
var fileTarget = new FileTarget {
FileName = Path.GetFileNameWithoutExtension(Application.ExecutablePath) + ".log",
Layout = @"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] ${message}"
// Layout = @"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] (${logger}) ${message}"
};
logConfig.AddTarget("file", fileTarget);
var logRule = new LoggingRule("*", LogLevel.Debug, fileTarget);
logConfig.LoggingRules.Add(logRule);
LogManager.Configuration = logConfig;
#endregion
_statusFile = Path.Combine(baseDir, "status.xml"); _statusFile = Path.Combine(baseDir, "status.xml");
...@@ -124,7 +111,23 @@ namespace ATxTray ...@@ -124,7 +111,23 @@ namespace ATxTray
fsw.Changed += StatusUpdated; fsw.Changed += StatusUpdated;
fsw.EnableRaisingEvents = true; fsw.EnableRaisingEvents = true;
Log.Info("AutoTxTray initialization completed."); Log.Info("{0} initialization completed.", AppTitle);
}
/// <summary>
/// Configure logging using a file target.
/// </summary>
private static void SetupLogging() {
var logConfig = new LoggingConfiguration();
var fileTarget = new FileTarget {
FileName = Path.GetFileNameWithoutExtension(Application.ExecutablePath) + ".log",
Layout = @"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] ${message}"
// Layout = @"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] (${logger}) ${message}"
};
logConfig.AddTarget("file", fileTarget);
var logRule = new LoggingRule("*", LogLevel.Debug, fileTarget);
logConfig.LoggingRules.Add(logRule);
LogManager.Configuration = logConfig;
} }
private void SetupContextMenu() { private void SetupContextMenu() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment