.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links


Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

Hi Everyone

In my .Net solution I have a class library project and an ASP.net project. This is how I use log4net in the Class library



[assembly : log4net.Config.XmlConfigurator(Watch=true)]



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



    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=, Culture=neutral, PublicKeyToken=1b44e1d426115821" />



  <!-- Log4net Logging Setup -->

  <log4net debug="false">

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

      <param name="File" value="C:\\test.log"/>

      <param name="AppendToFile" value="true"/>

      <maxSizeRollBackups value="10"/>

      <datePattern value="yyyy-MM-dd"/>

      <rollingStyle value="Date"/>


View Complete Post

More Related Resource Links

how make log4net serializable

Hello, im working with log4net ( http://logging.apache.org/log4net/release/features.html ). I need to make log4net serializable. Have anyone a idea how this works? greetingshttp://get.lima-city.de

Use the log4net provider instead of standard IO for the log provider

I need to log entries  into a log file.This should be done in the data access layer.At present, I am using the standard IO for making the log entries.But I need to use the log4net provider instead of standard IO for the log provider.I have added the log4net as a reference to my project.Can anyone explain how to achieve this..?

Log4Net with WCF Service is not writting the Log file.


Hai All,

    I have WCF Service which is hosted in IIS 7.5 and I am using Log4Net for logging errors that are raised in the WCF Service. I have all the setting configured properly in my application as per the Log4Net samples configuration. My application is working when I am using VS 2010 application server. But when I host the same Service in Windows 7 IIS 7.5 the log is being created with out any exception but there is no data in the log file.

One more thing is I have kept the Debugger in the ErrorLogger file of the Log4Net and seen all the values there, every thing is fine and I can see all the values are properly going till the last moment but in the log file nothing is present. I am unable to understand why the service is not able to write the file in the specified path which is mentioned in the web.config file.

The Log4Net settings in the Presentation Layer is as follows.

        <!--    Log4Net Appender for logging to Log file    -->
        <appender name="RollingFile" type="log4net.Appender.FileAppender">
            <file value="D:\_log\EdgeLog.log" />

log4net in mvc application


I wondered what the best way to implement the log4net in my mvc project

My 4 question is:
1. Where the best place to write this code line
public log4net.ILog log =  log4net.LogManager.GetLogger("File");
In the controller constructer or before the write event, or else.
2. I want after writing to file to release the file
3. I want give the admin manager the option to select if use the log4net or not, if I add an appsetting value "useLogs" where the best place/way to implement/unimplement this program to my application.
4. After that the file limit I want send the admin an email that the file limit that the admin backup and delete the file (for more disc space) is this option built in the log4net, maybe do It automatically


My step  to config the log4net is:
1. Add reference to log4net.dll
2. Add         <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
In web.config file
3. Add the log4net config in web.config file
        <level value="DEBUG" />
        <appender-ref ref="

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend