我想在项目中用log4net生成自定义的文件名,如,20100902.log.
我想这个在web.config里是做不了的.
就用程序配.可使老是报
警告 1“log4net.Appender.FileAppender.FileAppender(log4net.Layout.ILayout, string)”已过时:“Instead use the default constructor and set the Layout & File properties”E:\ConpanyWeb\500kv\500kv\ahead\logtest.aspx.cs3015500kv
求解决
给你个可用的配置:
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<sectionGroup name="spring">
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core" />
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file type="log4net.Util.PatternString" value="Logs\%date{yyyMMdd}.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level - %message%newline" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="FileAppender"/>
</root>
<logger name="Spring">
<level value="WARN" />
</logger>
<logger name="Clubank">
<level value="DEBUG" />
</logger>
</log4net>