asp.net's config is called web.config.  try looking for that.

Maybhate, Dipty wrote:

 

 


From: Maybhate, Dipty
Sent: Wednesday, August 16, 2006 10:55 AM
To: '[email protected]'
Subject: Problem logging in class library

 

Hi Everyone

I am new to log4net and I am facing problems with it. In my .Net solution I have a class library project and a ASP.net project. I want to create a Logger class which is like a wrapper in the class library and have all the other Webservices or ASP.net projects in the solution access that.

This is how I use log4net in the Class library

 

AssemblyInfo.cs

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

 

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">

            <param name="File" value="c:\\LogTest23.txt" />

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

            <layout type="log4net.Layout.PatternLayout">

                <param name="Header" value="[Header]\r\n" />

                <param name="Footer" value="[Footer]\r\n" />

                <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />

            </layout>

        </appender>               

        <root>

            <level value="INFO" />

            <appender-ref ref="FileAppender" />            

        </root>

    </log4net>

</configuration>

 

Logger class

private static readonly ILog logger =

                  LogManager.GetLogger(typeof(Class1));

log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo("App.config"));

                  logger.Debug("Here is a debug log.");

                  logger.Info("... and an Info log.");

                  logger.Warn("... and a warning.");

                  logger.Error("... and an error.");

                  logger.Fatal("... and a fatal error.");

 

I also tried using the <ClassLibraryName>.exe.config as the name for the app.config as I read it somewhere

Then my ASP.net application creates an object of this Class1 from the class library application and see if the log file is created

Could you please help me figure out what I am doing wrong?

Thank you very much

Dipty

 

 


Reply via email to