Skip to main content

Dapfor Logger and log4net

Pinned Featured


1 comment

  • Dapfor Team

    Hello Phillip,

    It's quite simple. It is only necessary to add a custom appender to the project and redirect calls to the dapfor logging system:

    1. Сreate a new custom class library, or use existing one.
    2. Add log4net as new references to the new library
    3. Create a new Appeder and inherit it from log4net.Appender.AppenderSkeleton

    namespace YourNamespace
    public class DapforAppender : log4net.Appender.AppenderSkeleton
            protected override void Append(LoggingEvent loggingEvent)
                if(Equals(loggingEvent.Level, Level.Info))
                else if (Equals(loggingEvent.Level, Level.Fatal))
                else if (Equals(loggingEvent.Level, Level.Error))
                else if (Equals(loggingEvent.Level, Level.Debug))

    4. In the application, create a new config file and call it something like Log.config, and set it up so that log4net knows where/how to instantiate your new appender:

    <?xml version="1.0" encoding="utf-8" ?> 
        <!-- Appenders -->
        <appender name="DapforAppender" type="YourNamespace.DapforAppender" />

      <!-- Logger hierarchy -->
        <appender-ref ref="DapforAppender" />

    5. Initialize the log4net in Program.Main() method as following:

    FileInfo fi = new FileInfo("Log.config");

    6. Put Dapfor.Net.Diagnostics.LogViewer control somewhere you want.


    Best regards,

    The Dapfor Team



Please sign in to leave a comment.

Powered by Zendesk