mirror of
https://github.com/winsw/winsw.git
synced 2025-12-10 18:37:28 +08:00
Include logger names in logs
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
using WinSW.Logging;
|
||||
using WinSW.Util;
|
||||
|
||||
namespace WinSW
|
||||
@@ -22,7 +23,7 @@ namespace WinSW
|
||||
Basic
|
||||
}
|
||||
|
||||
private static readonly ILog Logger = LogManager.GetLogger(typeof(Download));
|
||||
private static readonly ILog Logger = LogManager.GetLogger(LoggerNames.Service);
|
||||
|
||||
public readonly string From;
|
||||
public readonly string To;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using log4net;
|
||||
using WinSW.Logging;
|
||||
|
||||
namespace WinSW.Extensions
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace WinSW.Extensions
|
||||
|
||||
public XmlServiceConfig ServiceConfig { get; }
|
||||
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(WinSWExtensionManager));
|
||||
private static readonly ILog Log = LogManager.GetLogger(LoggerNames.Service);
|
||||
|
||||
public WinSWExtensionManager(XmlServiceConfig serviceConfig)
|
||||
{
|
||||
|
||||
8
src/WinSW.Core/Logging/LoggerNames.cs
Normal file
8
src/WinSW.Core/Logging/LoggerNames.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace WinSW.Logging
|
||||
{
|
||||
internal static class LoggerNames
|
||||
{
|
||||
internal const string Console = "console";
|
||||
internal const string Service = "service";
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using log4net;
|
||||
using WinSW.Logging;
|
||||
using WinSW.Native;
|
||||
using static WinSW.Native.ConsoleApis;
|
||||
using static WinSW.Native.ProcessApis;
|
||||
@@ -12,7 +13,7 @@ namespace WinSW.Util
|
||||
{
|
||||
public static class ProcessExtensions
|
||||
{
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(ProcessExtensions));
|
||||
private static readonly ILog Log = LogManager.GetLogger(LoggerNames.Service);
|
||||
|
||||
public static void StopTree(this Process process, int millisecondsTimeout)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace WinSW
|
||||
|
||||
private static readonly int AdditionalStopTimeout = 1_000;
|
||||
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(WrapperService));
|
||||
private static readonly ILog Log = LogManager.GetLogger(LoggerNames.Service);
|
||||
|
||||
private readonly XmlServiceConfig config;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace WinSW
|
||||
{
|
||||
private const string NoPipe = "-";
|
||||
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
|
||||
private static readonly ILog Log = LogManager.GetLogger(LoggerNames.Console);
|
||||
|
||||
internal static Action<Exception, InvocationContext>? TestExceptionHandler;
|
||||
internal static XmlServiceConfig? TestConfig;
|
||||
@@ -1095,7 +1095,7 @@ namespace WinSW
|
||||
{
|
||||
Name = "Wrapper console log",
|
||||
Threshold = consoleLogLevel,
|
||||
Layout = new PatternLayout("%date{ABSOLUTE} - %message%newline"),
|
||||
Layout = new PatternLayout("%message%newline"),
|
||||
};
|
||||
consoleAppender.ActivateOptions();
|
||||
|
||||
@@ -1139,7 +1139,7 @@ namespace WinSW
|
||||
Name = "Wrapper file log",
|
||||
Threshold = fileLogLevel,
|
||||
LockingModel = new FileAppender.MinimalLock(),
|
||||
Layout = new PatternLayout("%date %-5level - %message%newline"),
|
||||
Layout = new PatternLayout("%date{yyyy-MM-ddTHH:mm:ss.fff} %-5level %logger - %message%newline"),
|
||||
};
|
||||
fileAppender.ActivateOptions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user