logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Devin Smith <devinsm...@gmail.com>
Subject Re: ASP.NET starter help.
Date Tue, 31 Jan 2006 16:37:30 GMT
Hi All,

Thanks for all your help. I got the TraceAppender working so I
switched back to FileAppender. Now everything seems to work. I no
longer have any log4net information inside my AssemblyInfo.cs which
seemed to be one of the problems. Also, Geert, I was having a similar
problem like you but now I am no longer having a problem with logging
inside Application_Start (although I'm not sure what I changed so that
logging started to work inside it. :( )

Thanks again,

Devin

On 1/31/06, Ron Grabowski <rongrabowski@yahoo.com> wrote:
> Let's try getting log4net to produce output...then concentrate on the
> FileAppender once we know log4net is working correctly.
>
> Create a log4net.config file in the root of your website (i.e. in the
> same folder as web.config):
>
> <?xml version="1.0" encoding="utf-8" ?>
> <log4net>
>  <appender name="AspNetTraceAppender"
> type="log4net.Appender.AspNetTraceAppender" >
>   <layout type="log4net.Layout.PatternLayout">
>    <conversionPattern value="%logger - %message" />
>   </layout>
>  </appender>
>  <root>
>   <level value="ALL" />
>   <appender-ref ref="AspNetTraceAppender" />
>  </root>
> </log4net>
>
> Make sure the web.config file has tracing enabled:
>
> <trace enabled="true" requestLimit="10" pageOutput="true"
> traceMode="SortByTime" localOnly="false" />
>
> Use this snippet in Global.asax.cs:
>
> protected void Application_Start(Object sender, EventArgs e)
> {
>  log4net.Config.XmlConfigurator.ConfigureAndWatch(
>   new System.IO.FileInfo(
>    AppDomain.CurrentDomain.SetupInformation.ApplicationBase +
>    "log4net.config"));
>  log.Info("Application started");
> }
>
> --- Devin Smith <devinsmith@gmail.com> wrote:
>
> > Hi,
> >
> > I've spent a number of hours trying to get log4net to log something
> > in
> > an ASP.NET project but have not gotten anywhere. Hopefully someone
> > can
> > tell me what's going on here.
> >
> > In the AssemblyInfo.cs file for my main site I have:
> >
> > [assembly: log4net.Config.Repository("SiteCore")]
> > [assembly:
> > log4net.Config.XmlConfigurator(ConfigFileExtension="log4net",
> > Watch=true)]
> >
> > In Global.ascx.cs:
> >
> > // Class fields
> > private static readonly ILog log =
> >
> log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
> >
> > and inside Application_Start:
> >
> > public void Application_Start(object sender, EventArgs e)
> > {
> >               log4net.Config.XmlConfigurator.Configure();
> >               log.Info("Hello World, I am a logger");
> > }
> >
> > Now because I have the settings above in my AssemblyInfo.cs I need a
> > seperate config file (well according to the mailing list, and many
> > blog sites). Inside the bin of my ASP.net project I have a
> > SiteCore.dll.log4net file that contains the following:
> >
> > <?xml version="1.0" encoding="utf-8" ?>
> > <!-- This section contains the log4net configuration settings -->
> > <log4net>
> >       <!-- Define some output appenders -->
> >       <appender name="RollingLogFileAppender"
> >                 type="log4net.Appender.RollingFileAppender,log4net">
> >          <param name="File"
> >             value="C:\\Inetpub\\wwwroot\\test1\\LogFiles\\mylog.txt"/>
> >          <param name="AppendToFile" value="true"/>
> >
> >       <param name="MaxSizeRollBackups" value="10"/>
> >       <param name="MaximumFileSize" value="5MB"/>
> >       <param name="RollingStyle" value="Size"/>
> >       <param name="StaticLogFileName" value="true"/>
> >       <layout type="log4net.Layout.PatternLayout,log4net">
> >               <param name="ConversionPattern"
> >               value="%d [%t] %-5p %c [%x] - %m%n"/>
> >       </layout>
> >       </appender>
> >
> >       <!-- Setup the root category, add the appenders and set the default
> > priority -->
> >       <root>
> >               <level value="DEBUG" />
> >               <appender-ref ref="RollingLogFileAppender" />
> >       </root>
> > </log4net>
> >
> > Now, I checked that LogFiles is writeable by ASPNET and I also
> > created
> > a 0 byte mylog.txt and made it writeable by ASPNET as well.
> >
> > I'm not sure what i'm doing wrong but any help is appreciated.
> >
> > Thanks,
> >
> > Devin
> >
>

Mime
View raw message