What am I missing with log4net - No log file created

Posted by Saif Khan on Stack Overflow See other posts from Stack Overflow or by Saif Khan
Published on 2010-04-12T05:30:38Z Indexed on 2010/04/12 5:33 UTC
Read the original article Hit count: 514

Filed under:
|
|

I am trying to use log4net in a VB.NET app for some unknown reason it's not creating the log file.

Here is my app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
       <configSections>
    <section name="log4net"
    type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="c:\log-file.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="FileAppender" />
    </root>

  </log4net>
</configuration>

Here is the app code

Imports log4net
Public Class Form1
    Dim log As ILog
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        log.Error("test")
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        log4net.Config.XmlConfigurator.Configure()
        log = log4net.LogManager.GetLogger("TestThings")
    End Sub
End Class

"TestThings" is the name of the VS project. What am I missing?

© Stack Overflow or respective owner

Related posts about log4net

Related posts about logging