You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Ken Chu <ke...@yahoo.com> on 2006/03/24 22:47:53 UTC

newbie question about configuration

Hi .Net developers,

I've been trying to get the log4net 1.2.9 beta's WebApp example to work under
ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get any log files
nor trace output when I go to http://myhost/WebAppCS/Trace.axd.  Here are the
things I've tried to do:

- make sure the directory for the log file is writable
- setting the output log file with absolute path (c:\tmp\webapp-log.txt)
- change '\' to '\\' in the WebApp.dll.log4net file
- copy the content of WebApp.dll.log4net into Web.config
- turn on log4net internal debug flag (where does this output to?)

Could someone tell me what I'm missing?  Why isn't the WebForm1.asp page
producing a log file or trace output?  Is this because I converted this .NET
1.0 project to .NET 2.0?

Below is my current web.config file.  Any help would be appreciated.

-Ken
---------------------------------------------------
<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    </configSections>
	<appSettings>
		<!-- To enable internal log4net logging specify the 
		     following appSettings key -->
		<add key="log4net.Internal.Debug" value="true"/>
    </appSettings>
	<system.web>
		<!--  DYNAMIC DEBUG COMPILATION
          Set compilation debug="true" to enable ASPX debugging.  Otherwise,
setting this value to
          false will improve runtime performance of this application. 
          Set compilation debug="true" to insert debugging symbols (.pdb
information)
          into the compiled page. Because this creates a larger file that
executes
          more slowly, you should set this value to true only when debugging
and to
          false at all other times. For more information, refer to the
documentation about
          debugging ASP .NET files.
    -->
		<compilation defaultLanguage="c#" debug="true">
			  <!-- below doesn't work in .NET 2.0.
                          <compilers>
				<compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"
extension=".cs" compilerOptions="/d:DEBUG;TRACE"/>
                          </compilers> -->
        </compilation>
		<!--  CUSTOM ERROR MESSAGES
          Set customError mode values to control the display of user-friendly 
          error messages to users instead of error details (including a stack
trace):

          "On" Always display custom (friendly) messages  
          "Off" Always display detailed ASP.NET error information.
          "RemoteOnly" Display custom (friendly) messages only to users not
running 
          on the local Web server. This setting is recommended for security
purposes, so 
          that you do not display application detail information to remote
clients.
    -->
		<customErrors mode="RemoteOnly"/>
		<!--  AUTHENTICATION 
          This section sets the authentication policies of the application.
Possible modes are "Windows", "Forms", 
          "Passport" and "None"
    -->
		<!-- authentication mode="Windows" / -->
		<!--  APPLICATION-LEVEL TRACE LOGGING
          Application-level tracing enables trace log output for every page
within an application. 
          Set trace enabled="true" to enable application trace logging.  If
pageOutput="true", the
          trace information will be displayed at the bottom of each page. 
Otherwise, you can view the 
          application trace log by browsing the "trace.axd" page from your web
application
          root. 
    -->
		<trace enabled="true" requestLimit="20" pageOutput="false"
traceMode="SortByTime" localOnly="true"/>
		<!--  SESSION STATE SETTINGS
          By default ASP .NET uses cookies to identify which requests belong to
a particular session. 
          If cookies are not available, a session can be tracked by adding a
session identifier to the URL. 
          To disable cookies, set sessionState cookieless="true".
    -->
		<!--sessionState 
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;user id=sa;password="
            cookieless="false" 
            timeout="20" 
    /-->
		<!--  GLOBALIZATION
          This section sets the globalization settings of the application. 
    -->
		<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
		<xhtmlConformance mode="Legacy"/>
    </system.web>
    
    <log4net debug="false">
        <appender name="LogFileAppender" type="log4net.Appender.FileAppender" >
            <file value="C:\tmp\webapp-log.txt" />
            <appendToFile value="true" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date [%thread] %-5level %logger
[%ndc] - %message%newline" />
            </layout>
        </appender>
        <appender name="HttpTraceAppender"
type="log4net.Appender.AspNetTraceAppender" >
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date [%thread] %-5level %logger
[%ndc] - %message%newline" />
            </layout>
        </appender>
        <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
            <file value="\\tmp\\rolling-log.txt" />
            <appendToFile value="true" />
            <maxSizeRollBackups value="10" />
            <maximumFileSize value="5MB" />
            <rollingStyle value="Size" />
            <staticLogFileName value="true" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date [%thread] %-5level %logger
[%ndc] - %message%newline" />
            </layout>
        </appender>
        <root>
            <level value="ALL" />
            <appender-ref ref="LogFileAppender" />
            <appender-ref ref="HttpTraceAppender" />
            <appender-ref ref="RollingLogFileAppender" />
        </root>
    </log4net>
</configuration>

Re: newbie question about configuration

Posted by Hollywood <ho...@thzero.com>.
You need to give the folder log4net is writing to read/write permissions for 
the identity user of the AppPool that the web service is running under.

In a related note, if you are using the event log appender you have to give 
that same account read/write permissions to the event log in the registry.

----- Original Message ----- 
From: "Ken Chu" <ke...@yahoo.com>
To: <de...@gmail.com>; "Log4NET User" <lo...@logging.apache.org>
Sent: Tuesday, March 28, 2006 3:40 PM
Subject: Re: newbie question about configuration


> Hi Devin,
>
> Thanks for the suggestion.  I had added Full Control permissions for 
> "Everyone"
> on the output directory, but that didn't help.
>
> -Ken
>
> --- Devin Smith <de...@gmail.com> wrote:
>
>> On 3/24/06, Ken Chu <ke...@yahoo.com> wrote:
>> > Hi .Net developers,
>> >
>> > I've been trying to get the log4net 1.2.9 beta's WebApp example to work
>> under
>> > ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get any log
>> files
>> > nor trace output when I go to http://myhost/WebAppCS/Trace.axd.  Here 
>> > are
>> the
>> > things I've tried to do:
>> >
>> > - make sure the directory for the log file is writable
>> > - setting the output log file with absolute path 
>> > (c:\tmp\webapp-log.txt)
>> > - change '\' to '\\' in the WebApp.dll.log4net file
>> > - copy the content of WebApp.dll.log4net into Web.config
>> > - turn on log4net internal debug flag (where does this output to?)
>> >
>> > Could someone tell me what I'm missing?  Why isn't the WebForm1.asp 
>> > page
>> > producing a log file or trace output?  Is this because I converted this
>> .NET
>> > 1.0 project to .NET 2.0?
>> >
>>
>> Hi Ken,
>>
>> You didn't tell us which user you gave write access to.
>> Make sure that the directory you are writing your log files to has
>> write access by both ASP.NET user and the NETWORK SERVICE user. I
>> always forget which user w3wp runs under but this user needs the write
>> access.
>>
>> Thanks,
>>
>> Devin
>>
> 


Re: newbie question about configuration

Posted by Ken Chu <ke...@yahoo.com>.
Hi Devin,

Thanks for the suggestion.  I had added Full Control permissions for "Everyone"
on the output directory, but that didn't help.

-Ken

--- Devin Smith <de...@gmail.com> wrote:

> On 3/24/06, Ken Chu <ke...@yahoo.com> wrote:
> > Hi .Net developers,
> >
> > I've been trying to get the log4net 1.2.9 beta's WebApp example to work
> under
> > ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get any log
> files
> > nor trace output when I go to http://myhost/WebAppCS/Trace.axd.  Here are
> the
> > things I've tried to do:
> >
> > - make sure the directory for the log file is writable
> > - setting the output log file with absolute path (c:\tmp\webapp-log.txt)
> > - change '\' to '\\' in the WebApp.dll.log4net file
> > - copy the content of WebApp.dll.log4net into Web.config
> > - turn on log4net internal debug flag (where does this output to?)
> >
> > Could someone tell me what I'm missing?  Why isn't the WebForm1.asp page
> > producing a log file or trace output?  Is this because I converted this
> .NET
> > 1.0 project to .NET 2.0?
> >
> 
> Hi Ken,
> 
> You didn't tell us which user you gave write access to.
> Make sure that the directory you are writing your log files to has
> write access by both ASP.NET user and the NETWORK SERVICE user. I
> always forget which user w3wp runs under but this user needs the write
> access.
> 
> Thanks,
> 
> Devin
> 


Re: newbie question about configuration

Posted by Devin Smith <de...@gmail.com>.
On 3/24/06, Ken Chu <ke...@yahoo.com> wrote:
> Hi .Net developers,
>
> I've been trying to get the log4net 1.2.9 beta's WebApp example to work under
> ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get any log files
> nor trace output when I go to http://myhost/WebAppCS/Trace.axd.  Here are the
> things I've tried to do:
>
> - make sure the directory for the log file is writable
> - setting the output log file with absolute path (c:\tmp\webapp-log.txt)
> - change '\' to '\\' in the WebApp.dll.log4net file
> - copy the content of WebApp.dll.log4net into Web.config
> - turn on log4net internal debug flag (where does this output to?)
>
> Could someone tell me what I'm missing?  Why isn't the WebForm1.asp page
> producing a log file or trace output?  Is this because I converted this .NET
> 1.0 project to .NET 2.0?
>

Hi Ken,

You didn't tell us which user you gave write access to.
Make sure that the directory you are writing your log files to has
write access by both ASP.NET user and the NETWORK SERVICE user. I
always forget which user w3wp runs under but this user needs the write
access.

Thanks,

Devin

Re: newbie question about configuration

Posted by Ron Grabowski <ro...@yahoo.com>.
This page:

 http://logging.apache.org/log4net/release/faq.html

says:

"
Internal debugging messages are written to the console and to the
System.Diagnostics.Trace system
"

I'm not very familiar with .NET 2.0 apps but I would imagine you can
still add code like this to your web.config. This redirects output sent
to System.Diagnostics.Trace to a file:

<system.diagnostics>
 <trace autoflush="true">
  <listeners>
  <add name="textWriterTraceListener" 
   type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\\Inetpub\\wwwroot\\Logs\\log4net.txt" />
 </listeners>
</trace>
</system.diagnostics>

System.Diagnostics.Trace is different from
System.Web.HttpContext.Current.Trace. Log4net sends its debug messages
to System.Diagnostics.Trace.

Before adding that code to your web.config I would verify that you can
create and write to the log4net.txt file.

--- Ken Chu <ke...@yahoo.com> wrote:

> Yes, I have turned on internal debugging, but could you tell me where
> to look
> for the output of that?  I also suspect log4net can't find the config
> file, but
> I don't understand why it doesn't work as part of web.config.
> 
> Yes, I have tried trace output.  That is what Trace.axd is supposed
> to show,
> but I don't see any log4net output there either.  I only see .NET
> trace output,
> like this:
> 
> Request Details
> Session Id:	fej2pg45qfqbuhrhfw240viz	Request Type:	POST
> Time of Request:	3/23/2006 7:26:53 PM	Status Code:	200
> Request Encoding:	Unicode (UTF-8)	Response Encoding:	Unicode (UTF-8)
> Trace Information
> Category	Message	From First(s)	From Last(s)
> aspx.page	Begin PreInit		
> aspx.page	End PreInit	5.11238160157227E-05	0.000051
> aspx.page	Begin Init	8.38095344520044E-05	0.000033
> ...
> ...
> Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
> Version:2.0.50727.42
> 
> -Ken
> 
> --- Ron Grabowski <ro...@yahoo.com> wrote:
> 
> > Have you tried following these instructions?
> > 
> >  http://logging.apache.org/log4net/release/faq.html#internalDebug
> > 
> > and verified that log4net is starting correctly? Maybe log4net
> can't
> > find its config file. I would also try using an appender that does
> not
> > require file access to verify that log4net has been configured
> > correctly:
> > 
> > <appender name="AspNetTraceAppender"
> > type="log4net.Appender.AspNetTraceAppender" >
> > <layout type="log4net.Layout.PatternLayout" />
> > </appender>
> > 
> > Once that is working you can concentrate on the FileAppender.
> > 
> > --- Ken Chu <ke...@yahoo.com> wrote:
> > 
> > > Hi .Net developers,
> > > 
> > > I've been trying to get the log4net 1.2.9 beta's WebApp example
> to
> > > work under
> > > ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get
> any
> > > log files
> > > nor trace output when I go to http://myhost/WebAppCS/Trace.axd. 
> Here
> > > are the
> > > things I've tried to do:
> > > 
> > > - make sure the directory for the log file is writable
> > > - setting the output log file with absolute path
> > > (c:\tmp\webapp-log.txt)
> > > - change '\' to '\\' in the WebApp.dll.log4net file
> > > - copy the content of WebApp.dll.log4net into Web.config
> > > - turn on log4net internal debug flag (where does this output
> to?)
> > > 
> > > Could someone tell me what I'm missing?  Why isn't the
> WebForm1.asp
> > > page
> > > producing a log file or trace output?  Is this because I
> converted
> > > this .NET
> > > 1.0 project to .NET 2.0?
> > > 
> > > Below is my current web.config file.  Any help would be
> appreciated.
> > > 
> > > -Ken
> > > ---------------------------------------------------
> > > <?xml version="1.0"?>
> > > <configuration>
> > >     <configSections>
> > >         <section name="log4net"
> > > type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
> />
> > >     </configSections>
> > > 	<appSettings>
> > > 		<!-- To enable internal log4net logging specify the 
> > > 		     following appSettings key -->
> > > 		<add key="log4net.Internal.Debug" value="true"/>
> > >     </appSettings>
> > > 	<system.web>
> > > 		<!--  DYNAMIC DEBUG COMPILATION
> > >           Set compilation debug="true" to enable ASPX debugging. 
> > > Otherwise,
> > > setting this value to
> > >           false will improve runtime performance of this
> application.
> > > 
> > >           Set compilation debug="true" to insert debugging
> symbols
> > > (.pdb
> > > information)
> > >           into the compiled page. Because this creates a larger
> file
> > > that
> > > executes
> > >           more slowly, you should set this value to true only
> when
> > > debugging
> > > and to
> > >           false at all other times. For more information, refer
> to
> > > the
> > > documentation about
> > >           debugging ASP .NET files.
> > >     -->
> > > 		<compilation defaultLanguage="c#" debug="true">
> > > 			  <!-- below doesn't work in .NET 2.0.
> > >                           <compilers>
> > > 				<compiler language="c#"
> > > type="Microsoft.CSharp.CSharpCodeProvider, System,
> > > Version=2.0.0.0, Culture=neutral,
> PublicKeyToken=B77A5C561934E089"
> > > extension=".cs" compilerOptions="/d:DEBUG;TRACE"/>
> > >                           </compilers> -->
> > >         </compilation>
> > > 		<!--  CUSTOM ERROR MESSAGES
> > >           Set customError mode values to control the display of
> > > user-friendly 
> > >           error messages to users instead of error details
> (including
> > > a stack
> > > trace):
> > > 
> > >           "On" Always display custom (friendly) messages  
> > >           "Off" Always display detailed ASP.NET error
> information.
> > >           "RemoteOnly" Display custom (friendly) messages only to
> > > users not
> > > running 
> > >           on the local Web server. This setting is recommended
> for
> > > security
> > > purposes, so 
> > >           that you do not display application detail information
> to
> > > remote
> > > clients.
> > >     -->
> > > 		<customErrors mode="RemoteOnly"/>
> > > 		<!--  AUTHENTICATION 
> > >           This section sets the authentication policies of the
> > > application.
> > > Possible modes are "Windows", "Forms", 
> > >           "Passport" and "None"
> > >     -->
> > > 		<!-- authentication mode="Windows" / -->
> > > 		<!--  APPLICATION-LEVEL TRACE LOGGING
> > >           Application-level tracing enables trace log output for
> > > every page
> > > within an application. 
> > >           Set trace enabled="true" to enable application trace
> > > logging.  If
> > > pageOutput="true", the
> > >           trace information will be displayed at the bottom of
> each
> > > page. 
> > > Otherwise, you can view the 
> > >           application trace log by browsing the "trace.axd" page
> from
> > > your web
> > > application
> > >           root. 
> > >     -->
> > > 		<trace enabled="true" requestLimit="20" pageOutput="false"
> > > traceMode="SortByTime" localOnly="true"/>
> > > 		<!--  SESSION STATE SETTINGS
> > >           By default ASP .NET uses cookies to identify which
> requests
> > > belong to
> > > a particular session. 
> > >           If cookies are not available, a session can be tracked
> by
> > > adding a
> > > session identifier to the URL. 
> > >           To disable cookies, set sessionState cookieless="true".
> > >     -->
> > > 		<!--sessionState 
> > >             mode="InProc"
> > >             stateConnectionString="tcpip=127.0.0.1:42424"
> > >             sqlConnectionString="data source=127.0.0.1;user
> > > id=sa;password="
> > >             cookieless="false" 
> > >             timeout="20" 
> > >     /-->
> 
=== message truncated ===


Re: newbie question about configuration

Posted by Ken Chu <ke...@yahoo.com>.
Yes, I have turned on internal debugging, but could you tell me where to look
for the output of that?  I also suspect log4net can't find the config file, but
I don't understand why it doesn't work as part of web.config.

Yes, I have tried trace output.  That is what Trace.axd is supposed to show,
but I don't see any log4net output there either.  I only see .NET trace output,
like this:

Request Details
Session Id:	fej2pg45qfqbuhrhfw240viz	Request Type:	POST
Time of Request:	3/23/2006 7:26:53 PM	Status Code:	200
Request Encoding:	Unicode (UTF-8)	Response Encoding:	Unicode (UTF-8)
Trace Information
Category	Message	From First(s)	From Last(s)
aspx.page	Begin PreInit		
aspx.page	End PreInit	5.11238160157227E-05	0.000051
aspx.page	Begin Init	8.38095344520044E-05	0.000033
...
...
Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42

-Ken

--- Ron Grabowski <ro...@yahoo.com> wrote:

> Have you tried following these instructions?
> 
>  http://logging.apache.org/log4net/release/faq.html#internalDebug
> 
> and verified that log4net is starting correctly? Maybe log4net can't
> find its config file. I would also try using an appender that does not
> require file access to verify that log4net has been configured
> correctly:
> 
> <appender name="AspNetTraceAppender"
> type="log4net.Appender.AspNetTraceAppender" >
> <layout type="log4net.Layout.PatternLayout" />
> </appender>
> 
> Once that is working you can concentrate on the FileAppender.
> 
> --- Ken Chu <ke...@yahoo.com> wrote:
> 
> > Hi .Net developers,
> > 
> > I've been trying to get the log4net 1.2.9 beta's WebApp example to
> > work under
> > ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get any
> > log files
> > nor trace output when I go to http://myhost/WebAppCS/Trace.axd.  Here
> > are the
> > things I've tried to do:
> > 
> > - make sure the directory for the log file is writable
> > - setting the output log file with absolute path
> > (c:\tmp\webapp-log.txt)
> > - change '\' to '\\' in the WebApp.dll.log4net file
> > - copy the content of WebApp.dll.log4net into Web.config
> > - turn on log4net internal debug flag (where does this output to?)
> > 
> > Could someone tell me what I'm missing?  Why isn't the WebForm1.asp
> > page
> > producing a log file or trace output?  Is this because I converted
> > this .NET
> > 1.0 project to .NET 2.0?
> > 
> > Below is my current web.config file.  Any help would be appreciated.
> > 
> > -Ken
> > ---------------------------------------------------
> > <?xml version="1.0"?>
> > <configuration>
> >     <configSections>
> >         <section name="log4net"
> > type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
> >     </configSections>
> > 	<appSettings>
> > 		<!-- To enable internal log4net logging specify the 
> > 		     following appSettings key -->
> > 		<add key="log4net.Internal.Debug" value="true"/>
> >     </appSettings>
> > 	<system.web>
> > 		<!--  DYNAMIC DEBUG COMPILATION
> >           Set compilation debug="true" to enable ASPX debugging. 
> > Otherwise,
> > setting this value to
> >           false will improve runtime performance of this application.
> > 
> >           Set compilation debug="true" to insert debugging symbols
> > (.pdb
> > information)
> >           into the compiled page. Because this creates a larger file
> > that
> > executes
> >           more slowly, you should set this value to true only when
> > debugging
> > and to
> >           false at all other times. For more information, refer to
> > the
> > documentation about
> >           debugging ASP .NET files.
> >     -->
> > 		<compilation defaultLanguage="c#" debug="true">
> > 			  <!-- below doesn't work in .NET 2.0.
> >                           <compilers>
> > 				<compiler language="c#"
> > type="Microsoft.CSharp.CSharpCodeProvider, System,
> > Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"
> > extension=".cs" compilerOptions="/d:DEBUG;TRACE"/>
> >                           </compilers> -->
> >         </compilation>
> > 		<!--  CUSTOM ERROR MESSAGES
> >           Set customError mode values to control the display of
> > user-friendly 
> >           error messages to users instead of error details (including
> > a stack
> > trace):
> > 
> >           "On" Always display custom (friendly) messages  
> >           "Off" Always display detailed ASP.NET error information.
> >           "RemoteOnly" Display custom (friendly) messages only to
> > users not
> > running 
> >           on the local Web server. This setting is recommended for
> > security
> > purposes, so 
> >           that you do not display application detail information to
> > remote
> > clients.
> >     -->
> > 		<customErrors mode="RemoteOnly"/>
> > 		<!--  AUTHENTICATION 
> >           This section sets the authentication policies of the
> > application.
> > Possible modes are "Windows", "Forms", 
> >           "Passport" and "None"
> >     -->
> > 		<!-- authentication mode="Windows" / -->
> > 		<!--  APPLICATION-LEVEL TRACE LOGGING
> >           Application-level tracing enables trace log output for
> > every page
> > within an application. 
> >           Set trace enabled="true" to enable application trace
> > logging.  If
> > pageOutput="true", the
> >           trace information will be displayed at the bottom of each
> > page. 
> > Otherwise, you can view the 
> >           application trace log by browsing the "trace.axd" page from
> > your web
> > application
> >           root. 
> >     -->
> > 		<trace enabled="true" requestLimit="20" pageOutput="false"
> > traceMode="SortByTime" localOnly="true"/>
> > 		<!--  SESSION STATE SETTINGS
> >           By default ASP .NET uses cookies to identify which requests
> > belong to
> > a particular session. 
> >           If cookies are not available, a session can be tracked by
> > adding a
> > session identifier to the URL. 
> >           To disable cookies, set sessionState cookieless="true".
> >     -->
> > 		<!--sessionState 
> >             mode="InProc"
> >             stateConnectionString="tcpip=127.0.0.1:42424"
> >             sqlConnectionString="data source=127.0.0.1;user
> > id=sa;password="
> >             cookieless="false" 
> >             timeout="20" 
> >     /-->
> > 		<!--  GLOBALIZATION
> >           This section sets the globalization settings of the
> > application. 
> >     -->
> > 		<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
> > 		<xhtmlConformance mode="Legacy"/>
> >     </system.web>
> >     
> >     <log4net debug="false">
> >         <appender name="LogFileAppender"
> > type="log4net.Appender.FileAppender" >
> >             <file value="C:\tmp\webapp-log.txt" />
> >             <appendToFile value="true" />
> >             <layout type="log4net.Layout.PatternLayout">
> >                 <conversionPattern value="%date [%thread] %-5level
> > %logger
> > [%ndc] - %message%newline" />
> >             </layout>
> >         </appender>
> >         <appender name="HttpTraceAppender"
> > type="log4net.Appender.AspNetTraceAppender" >
> >             <layout type="log4net.Layout.PatternLayout">
> >                 <conversionPattern value="%date [%thread] %-5level
> > %logger
> > [%ndc] - %message%newline" />
> >             </layout>
> >         </appender>
> >         <appender name="RollingLogFileAppender"
> > type="log4net.Appender.RollingFileAppender">
> >             <file value="\\tmp\\rolling-log.txt" />
> >             <appendToFile value="true" />
> >             <maxSizeRollBackups value="10" />
> >             <maximumFileSize value="5MB" />
> >             <rollingStyle value="Size" />
> >             <staticLogFileName value="true" />
> >             <layout type="log4net.Layout.PatternLayout">
> >                 <conversionPattern value="%date [%thread] %-5level
> > %logger
> > [%ndc] - %message%newline" />
> >             </layout>
> >         </appender>
> >         <root>
> >             <level value="ALL" />
> >             <appender-ref ref="LogFileAppender" />
> >             <appender-ref ref="HttpTraceAppender" />
> >             <appender-ref ref="RollingLogFileAppender" />
> >         </root>
> >     </log4net>
> > </configuration>
> > 
> 
> 


Re: newbie question about configuration

Posted by Ron Grabowski <ro...@yahoo.com>.
Have you tried following these instructions?

 http://logging.apache.org/log4net/release/faq.html#internalDebug

and verified that log4net is starting correctly? Maybe log4net can't
find its config file. I would also try using an appender that does not
require file access to verify that log4net has been configured
correctly:

<appender name="AspNetTraceAppender"
type="log4net.Appender.AspNetTraceAppender" >
<layout type="log4net.Layout.PatternLayout" />
</appender>

Once that is working you can concentrate on the FileAppender.

--- Ken Chu <ke...@yahoo.com> wrote:

> Hi .Net developers,
> 
> I've been trying to get the log4net 1.2.9 beta's WebApp example to
> work under
> ASP.NET 2.0 without any luck (using C# in VS2005).  I don't get any
> log files
> nor trace output when I go to http://myhost/WebAppCS/Trace.axd.  Here
> are the
> things I've tried to do:
> 
> - make sure the directory for the log file is writable
> - setting the output log file with absolute path
> (c:\tmp\webapp-log.txt)
> - change '\' to '\\' in the WebApp.dll.log4net file
> - copy the content of WebApp.dll.log4net into Web.config
> - turn on log4net internal debug flag (where does this output to?)
> 
> Could someone tell me what I'm missing?  Why isn't the WebForm1.asp
> page
> producing a log file or trace output?  Is this because I converted
> this .NET
> 1.0 project to .NET 2.0?
> 
> Below is my current web.config file.  Any help would be appreciated.
> 
> -Ken
> ---------------------------------------------------
> <?xml version="1.0"?>
> <configuration>
>     <configSections>
>         <section name="log4net"
> type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
>     </configSections>
> 	<appSettings>
> 		<!-- To enable internal log4net logging specify the 
> 		     following appSettings key -->
> 		<add key="log4net.Internal.Debug" value="true"/>
>     </appSettings>
> 	<system.web>
> 		<!--  DYNAMIC DEBUG COMPILATION
>           Set compilation debug="true" to enable ASPX debugging. 
> Otherwise,
> setting this value to
>           false will improve runtime performance of this application.
> 
>           Set compilation debug="true" to insert debugging symbols
> (.pdb
> information)
>           into the compiled page. Because this creates a larger file
> that
> executes
>           more slowly, you should set this value to true only when
> debugging
> and to
>           false at all other times. For more information, refer to
> the
> documentation about
>           debugging ASP .NET files.
>     -->
> 		<compilation defaultLanguage="c#" debug="true">
> 			  <!-- below doesn't work in .NET 2.0.
>                           <compilers>
> 				<compiler language="c#"
> type="Microsoft.CSharp.CSharpCodeProvider, System,
> Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"
> extension=".cs" compilerOptions="/d:DEBUG;TRACE"/>
>                           </compilers> -->
>         </compilation>
> 		<!--  CUSTOM ERROR MESSAGES
>           Set customError mode values to control the display of
> user-friendly 
>           error messages to users instead of error details (including
> a stack
> trace):
> 
>           "On" Always display custom (friendly) messages  
>           "Off" Always display detailed ASP.NET error information.
>           "RemoteOnly" Display custom (friendly) messages only to
> users not
> running 
>           on the local Web server. This setting is recommended for
> security
> purposes, so 
>           that you do not display application detail information to
> remote
> clients.
>     -->
> 		<customErrors mode="RemoteOnly"/>
> 		<!--  AUTHENTICATION 
>           This section sets the authentication policies of the
> application.
> Possible modes are "Windows", "Forms", 
>           "Passport" and "None"
>     -->
> 		<!-- authentication mode="Windows" / -->
> 		<!--  APPLICATION-LEVEL TRACE LOGGING
>           Application-level tracing enables trace log output for
> every page
> within an application. 
>           Set trace enabled="true" to enable application trace
> logging.  If
> pageOutput="true", the
>           trace information will be displayed at the bottom of each
> page. 
> Otherwise, you can view the 
>           application trace log by browsing the "trace.axd" page from
> your web
> application
>           root. 
>     -->
> 		<trace enabled="true" requestLimit="20" pageOutput="false"
> traceMode="SortByTime" localOnly="true"/>
> 		<!--  SESSION STATE SETTINGS
>           By default ASP .NET uses cookies to identify which requests
> belong to
> a particular session. 
>           If cookies are not available, a session can be tracked by
> adding a
> session identifier to the URL. 
>           To disable cookies, set sessionState cookieless="true".
>     -->
> 		<!--sessionState 
>             mode="InProc"
>             stateConnectionString="tcpip=127.0.0.1:42424"
>             sqlConnectionString="data source=127.0.0.1;user
> id=sa;password="
>             cookieless="false" 
>             timeout="20" 
>     /-->
> 		<!--  GLOBALIZATION
>           This section sets the globalization settings of the
> application. 
>     -->
> 		<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
> 		<xhtmlConformance mode="Legacy"/>
>     </system.web>
>     
>     <log4net debug="false">
>         <appender name="LogFileAppender"
> type="log4net.Appender.FileAppender" >
>             <file value="C:\tmp\webapp-log.txt" />
>             <appendToFile value="true" />
>             <layout type="log4net.Layout.PatternLayout">
>                 <conversionPattern value="%date [%thread] %-5level
> %logger
> [%ndc] - %message%newline" />
>             </layout>
>         </appender>
>         <appender name="HttpTraceAppender"
> type="log4net.Appender.AspNetTraceAppender" >
>             <layout type="log4net.Layout.PatternLayout">
>                 <conversionPattern value="%date [%thread] %-5level
> %logger
> [%ndc] - %message%newline" />
>             </layout>
>         </appender>
>         <appender name="RollingLogFileAppender"
> type="log4net.Appender.RollingFileAppender">
>             <file value="\\tmp\\rolling-log.txt" />
>             <appendToFile value="true" />
>             <maxSizeRollBackups value="10" />
>             <maximumFileSize value="5MB" />
>             <rollingStyle value="Size" />
>             <staticLogFileName value="true" />
>             <layout type="log4net.Layout.PatternLayout">
>                 <conversionPattern value="%date [%thread] %-5level
> %logger
> [%ndc] - %message%newline" />
>             </layout>
>         </appender>
>         <root>
>             <level value="ALL" />
>             <appender-ref ref="LogFileAppender" />
>             <appender-ref ref="HttpTraceAppender" />
>             <appender-ref ref="RollingLogFileAppender" />
>         </root>
>     </log4net>
> </configuration>
>