<configuration>
<!-- Register the section handler for the log4net section -->
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<!-- This section contains the log4net configuration settings -->
<log4net debug="true">
<!-- Define the default appender -->
<appender name="PowerFAIDSLogger" type="log4net.Appender.RollingFileAppender,log4net">
<file type="log4net.Util.PatternString" value="%env{ALLUSERSPROFILE}\Company Name\App Name\data_integration.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="512KB"/>
<param name="StaticLogFileName" value="true"/>
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="{%d{MMM-dd-yyyy} ~ %t} %10r %-5p [%x] <%X{diagnostic}> - %m%n"/>
</layout>
</appender>
<appender name="PerformanceLogger" type="log4net.Appender.RollingFileAppender,log4net">
<file type="log4net.Util.PatternString" value="%env{ALLUSERSPROFILE}\Company Name\App Name\performance.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="512KB"/>
<param name="StaticLogFileName" value="true"/>
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="{%d{MMM-dd-yyyy} ~ %t} %10r %-5p [%x] <%X{DR} %X{NA}> - %m%n"/>
</layout>
</appender>
<appender name="TransactionLogger" type="log4net.Appender.RollingFileAppender,log4net">
<file type="log4net.Util.PatternString" value="%env{ALLUSERSPROFILE}\Company Name\App Name\data_integrationTransaction.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="512KB"/>
<param name="StaticLogFileName" value="true"/>
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="{%d{MMM-dd-yyyy} ~ %t} %10r %-5p [%x] <%X{DR} %X{NA}> - %m%n"/>
</layout>
</appender>
<!-- Define the email appender -->
<appender name="SMTPAppender" type="log4net.Appender.SMTPAppender">
<param name="To" value="someone@abc.com"/>
<param name="From" value="jdf@CompanyName.org"/>
<param name="Subject" value="App Name Error Message"/>
<param name="SMTPHost" value="ecogsdf.CompanyName.local"/>
<param name="LocationInfo" value="false"/>
<param name="BufferSize" value="512"/>
<param name="Lossy" value="true"/>
<evaluator type="log4net.spi.LevelEvaluator">
<param name="Threshold" value="WARN"/>
</evaluator>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] <%X{auth}> - %m%n"/>
</layout>
</appender>
<!-- Setup the loggers, add the appenders and set the default priority -->
<logger name="PerformanceLogger">
<priority value="ALL"/>
<appender-ref ref="PerformanceLogger"/>
</logger>
<logger name="App NameLogger">
<priority value="WARN"/>
<appender-ref ref="App NameLogger"/>
</logger>
<logger name="TransactionLogger">
<level value="INFO" />
<appender-ref ref="TransactionLogger"/>
</logger>
</log4net>
</configuration>
' CODE New Logger().Info("写一些信息")
当我调用上面的代码时,它不会将任何输出写入 data_integrationTransaction.log 文件。但是 New Logger().Error("Write some error") 工作正常。
我感谢您的支持。