I have configured the log4net in Web.Config and I am able to log messages
exactly the way I need.
Followed is my code which I am using in my web application in Web.Config,
Global.asax and my .cs.
*My Web.Config*
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
</configSections>
<appSettings>
</appSettings>
<log4net>
<appender name="AspNetTraceAppender" type="
log4net.Appender.AspNetTraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level - %message%newline"/>
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="bin\MyProject-Log.log"/>
<appendToFile value="true"/>
<layout type="log4net.Layout.PatternLayout">
<header value="My Project Startup..."/>
<footer value="My Project Shutdown..."/>
<conversionPattern value="%date %-5level - %message%newline"/>
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="LogFileAppender"/>
</root>
<logger name="MyLogger">
<level value="ALL"/>
<appender-ref ref="AspNetTraceAppender"/>
</logger>
</log4net>
<system.web>
<compilation defaultLanguage="c#" debug="true"/>
<customErrors mode="RemoteOnly" defaultRedirect="DefaultError.aspx"/>
<authentication mode="Forms">
<forms loginUrl="login.aspx" name="adAuthName" t㬬meout="60" path="/"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/> <!-- Allow all users -->
</authorization>
<identity impersonate="true"/>
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode
="SortByTime" localOnly="true"/>
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false" timeout="20"/>
<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
</system.web>
</configuration>
*Global.asax*
protected void Application_Start(Object sender, EventArgs e)
{
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(
AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "web.config"));
}
*.CS code*
private static readonly ILog log = log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
if(log.IsInfoEnabled)
log.Info(strMessage);
Once this code executes then all my sessions are getting expired.
Please help me regarding this to get out of the issue.
Thank you
On 5/2/07, Ron Grabowski <[EMAIL PROTECTED]> wrote:
Is your extension dll looking for the correct configuration file? Can you
post code where it fails to read the config file?
----- Original Message ----
From: JkReddy <[EMAIL PROTECTED]>
To: [email protected]
Sent: Wednesday, May 2, 2007 10:28:44 AM
Subject: Need help on testing dll, that uses external configuration file,
using Nunit.
I have extended the log4net , to suite my requirements.
Now I want to write, the unit tests for that library, using external
log4net configuration file.
I want to use Nunit. My question is how to test my dll, with the use of
external log configuration file. Could you point me in the right
direction.
In my extension dll, the code looking for the config file, in base
directory, but not successfull
getting config file read.
--
View this message in context:
http://www.nabble.com/Need-help-on-testing-dll%2C-that-uses-external-configuration-file%2C-using-Nunit.-tf3680882.html#a10286867
Sent from the Log4net - Users mailing list archive at Nabble.com.
--
Phani Prathap Nadigadda