我有一个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