1
有沒有辦法讓Spring.Net記錄它在構建對象時所做的事情?的可以Spring.Net記錄它在做什麼,因爲它的構造函數對象?
Constructing Object A
Constructing Object B
etc etc.....
量級上的東西,我需要解決我的應用程序內的循環依賴,並看到在春天創建的對象可能是一個巨大的幫助的順序。
有沒有辦法讓Spring.Net記錄它在構建對象時所做的事情?的可以Spring.Net記錄它在做什麼,因爲它的構造函數對象?
Constructing Object A
Constructing Object B
etc etc.....
量級上的東西,我需要解決我的應用程序內的循環依賴,並看到在春天創建的對象可能是一個巨大的幫助的順序。
這可以很容易地完成。 Spring使用Common.Logging
。您可以從Spring.Objects.Factory.*
類中獲取日誌輸出並查找... Creating instance of Object 'your-id-here' ...
消息。
請注意,您必須登錄DEBUG
級別,這意味着您會看到很多其他信息。
下的app.config將日誌創建調用控制檯,使用log4net的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
</layout>
</appender>
<!-- this logger will catch creation messages -->
<logger name="Spring.Objects.Factory">
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</logger>
</log4net>
</configuration>
所以大部分是樣板Common.Logging
和log4net的配置,這是對Common.Logging
website有據可查。如果你想附加到一個文件或其他東西,請參閱log4net文檔。