首先要更正我在
前一篇文章的錯誤:Spring.NET 只需要 Common Logging for .NET(而且是較舊的版本),並沒有相依於 log4net,所以在使用 Spring.NET Framework 的開發中,如果不希望額外增加參考,可以藉由以下幾項達成:
- <configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="level" value="INFO" />
</factoryAdapter>
</logging>
</common>
- private static Common.Logging.ILog log = Common.Logging.LogManager.GetLogger(typeof(MyClass));
- log.Info("myInfo");
如此一來,記錄會出現在 Visual Studio 的 Output 視窗。
沒有留言:
張貼留言