我有一個Windows服務,它使用System.Threads和Timers每隔x分鐘創建一個類的實例。服務調用所在的主類中的日誌記錄工作正常,但所謂的類不能登錄,我只是沒有得到任何輸出。log4net:日誌記錄只能在主類中使用
這就是我的mainclass的框架:
/// <summary>
/// Create an Instance of the Log
/// </summary>
private static readonly ILog logger = LogManager.GetLogger("Test");
/// <summary>
/// Get the Instance of the Log
/// </summary>
internal static ILog log
{
get { return logger; }
}
如果我現在請出任何其他類Service.log參考,並嘗試寫日誌,如Service.log.Info(「測試」) ;什麼都沒有出現。
如果我嘗試創建日誌中的第二類的新實例,通過使用
/// <summary>
/// Create an Instance of the Log
/// </summary>
private static readonly ILog logsomething = LogManager.GetLogger("Test");
我沒有得到任何地輸出,它只能在mainclass。我不能讓它在任何其他線程類中工作。我的配置基於RollingFileAppender。
能否請您發表您的配置? – gregwhitaker 2012-03-20 12:23:13