Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8475965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:02:42+00:00 2026-06-10T18:02:42+00:00

I am using Log4Net to log exceptions in my web application. Here I have

  • 0

I am using Log4Net to log exceptions in my web application.

Here I have found an example for a configuration: http://www.csharptocsharp.com/log4net-configuration-for-rockin-loggin

<?xml version="1.0"?>

<configuration>
  <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>

  <log4net>
    <!--
  This writes the log information to the console window.  It only logs events
  that are at least at the INFO level (which would mean that DEBUG events are not
  captured.
  -->
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{ABSOLUTE} [%thread] %level %logger - %message%newlineExtra Info: %property{testProperty}%newline%exception"/>
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
        <levelMin value="INFO"/>
        <levelMax value="FATAL"/>
      </filter>
    </appender>
    <!--
  This stores information in the log.txt file.  It only captures log events
  that contain the key word test or error.
  -->
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
           <file value="L:\Name\trunk\Name.Web\log.txt"/>
      <appendToFile value="true"/>
      <rollingStyle value="Size"/>
      <maxSizeRollBackups value="5"/>
      <maximumFileSize value="10MB"/>
      <staticLogFileName value="true"/>
      <filter type="log4net.Filter.StringMatchFilter">
        <stringToMatch value="test"/>
      </filter>
      <filter type="log4net.Filter.StringMatchFilter">
        <stringToMatch value="error"/>
      </filter>
      <filter type="log4net.Filter.DenyAllFilter"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %level %logger - %message%newline%exception"/>
      </layout>
    </appender>
    <root>
      <level value="FATAL"/>
      <appender-ref ref="RollingFileAppender"/>
    </root>
    <logger name="Log4NetTest.OtherClass">
      <level value="DEBUG"/>
      <appender-ref ref="ConsoleAppender"/>
    </logger>
  </log4net>


</configuration>

In my class I have:

protected static readonly ILog log = LogManager.GetLogger(typeof(TemplateController));

and in my method I have:

log4net.Config.XmlConfigurator.Configure();

                //————————–
                log.Error("sadi the great");
                log.Info("sadi the great");

but I have got error:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:02:43+00:00Added an answer on June 10, 2026 at 6:02 pm

    A working configuration for Rolling File appender is like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
        </configSections>
        <log4net>
             <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
                 <file value="logger.log" />
                 <appendToFile value="true" />
                 <maximumFileSize value="100KB" />
                 <maxSizeRollBackups value="2" />
                 <layout type="log4net.Layout.PatternLayout">
                 <conversionPattern value="%date %logger [%thread] [%ndc] (%file:%line) %level- %message%newline"/>
                 </layout>
             </appender>
    
      <root>
          <level value="DEBUG" />      
      <appender-ref ref="RollingFile" />
      </root>
      </log4net>
    </configuration>
    

    and you should change your target framework to “.net framework 4” (by default it is different in my case)
    check this one will be useful

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have been using log4net for logging our asp.net web forms application. Our logging
i want to log an asp.net , framework 4.0 web application. i'm using log4net
I'm currently using log4net in my ASP.NET MVC application to log exceptions. The way
Currently my application is using log4net to log errors, the web.config for this is
I've been using log4net to log our ASP.NET web site's log messages, and lately
I'm using log4net to log my web app's progress, using Log4PostSharp to AOP-injectify all
I am using log4net for logging my asp.net application. However the log file is
I have a Windows form App which write to log files using log4net. The
My application writes a log file (currently using log4net ). I'd like to setup
Am using Log4Net to log my application,everything works fine to me, just wanna understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.