Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4net won't write to the visual web developer console

this is my config for log4net but it wont write to the console
see appender: ConsoleAppender

<?xml version="1.0" encoding="utf-8"?>
<configuration>


  <configSections>
    <section name="log4net"
       type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
      <param name="File" value="C:\Users\name\Documents\visual studio 2010\Projects\logs\logfile.txt" />
      <param name="AppendToFile" value="true" />
      <layout type="log4net.Layout.PatternLayout">

        <param name="ConversionPattern" value="%d [%t] %-5p  %C %m%n%newline" />
      </layout>
    </appender>

    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
      <layout type="log4net.Layout.PatternLayout">

        <param name="ConversionPattern" value="%d [%t] %-5p  %C %m%n%newline" />
      </layout>
    </appender>

    <root>
      <level value="ALL" />
      <appender-ref ref="LogFileAppender" />
      <appender-ref ref="ConsoleAppender" />
    </root>
  </log4net>
</configuration>

Why doesn't it write to the console?

Edit 1 This is how I initialize it:

log4net.Config.XmlConfigurator.Configure(new FileInfo("C:\\Users\\name\\Documents\\Visual Studio 2010\\Projects\\ExecutionEngine\\Libraries\\App.Config"));

Thanks

like image 617
SexyMF Avatar asked Sep 18 '11 08:09

SexyMF


1 Answers

You can use the trace appender for this purpose. For instance like this:

<appender name="TraceAppender"
          type="log4net.Appender.TraceAppender" >
    <layout type="log4net.Layout.PatternLayout">
       <conversionPattern value="%-6level - %message%newline" />
    </layout>
</appender>
like image 144
Stefan Egli Avatar answered Sep 29 '22 08:09

Stefan Egli