English 中文(简体)
log4net info没有书写记录
原标题:Log4net info is not writing to log file
  • 时间:2012-04-23 16:45:10
  •  标签:
  • .net
  • log4net
<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 NameApp Namedata_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] &lt;%X{diagnostic}&gt; - %m%n"/>
            </layout>
        </appender>
        <appender name="PerformanceLogger" type="log4net.Appender.RollingFileAppender,log4net">
      <file type="log4net.Util.PatternString" value="%env{ALLUSERSPROFILE}Company NameApp Nameperformance.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] &lt;%X{DR} %X{NA}&gt; - %m%n"/>
            </layout>
        </appender>
    <appender name="TransactionLogger" type="log4net.Appender.RollingFileAppender,log4net">
      <file type="log4net.Util.PatternString" value="%env{ALLUSERSPROFILE}Company NameApp Namedata_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] &lt;%X{DR} %X{NA}&gt; - %m%n"/>
      </layout>
    </appender>
        <!-- Define the email appender -->
        <appender name="SMTPAppender" type="log4net.Appender.SMTPAppender">
            <param name="To" value="[email protected]"/>
            <param name="From" value="[email protected]"/>
            <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] &lt;%X{auth}&gt; - %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("Write some info")

当我称之为上述法典时,它不把任何产出写到数据中。 记录。 但新洛格人。 Error(“某些错误”)进行罚款。

我赞赏您的支持。

最佳回答

The recommended way to get a logger is as shown here, not as you have it. I would try this again following the log4net docs. ILog log = LogManager.GetLogger("application-log");

log.Info("Application Start");
log.Debug("This is a debug message");

if (log.IsDebugEnabled)
{
    log.Debug("This is another debug message");
}

您也不妨设立一个<代码><root>要素,以澄清贵方的违约水平。

问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签