下面是我的代码。NullReference
使用 Logger 对象时出现异常。我想念什么?
using Castle.Core.Logging;
using Castle.Facilities.Logging;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Castle.Windsor.Installer;
namespace log4netTest
{
internal class Program
{
private static void Main(string[] args)
{
new WindsorContainer()
.Install(FromAssembly.This());
var test = new testClass();
test.Do();
}
}
public class testClass
{
public ILogger Logger { get; set; }
public void Do()
{
Logger.Info("start");
Logger.Error("error end");
}
}
public class MyWindorInstaller : IWindsorInstaller
{
#region IWindsorInstaller Members
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility<LoggingFacility>(facility => facility.UseLog4Net("log4net.config"));
}
#endregion
}
}