Thanks, I’ll try that out when I get a chance.  But actually, I did figure this 
out last night – I just needed to call XmlConfigurator.Configure(FileInfo) and 
explicitly tell the configurator where the xml file was.  I asked Mike Knowles 
about it and he updated his blog article about it with a full source code 
project specifically for sharepoint:
http://mikeknowles.com/blog/2009/02/17/ConfiguringLog4netForSharePointWindowsAuthentication.aspx

Thanks for the help!
- Tomas

From: Cankut Eskin [mailto:cankutes...@gmail.com]
Sent: Wednesday, February 24, 2010 1:25 AM
To: Log4NET User
Subject: Re: no log file generated

Try enabling log4net internal debugging to see if something is going wrong.
How to enable internal debugging is described in 
http://logging.apache.org/log4net/release/faq.html

And make sure that the process running your application has permission to 
write/create "F:\arrowlog.txt".
On 24 February 2010 02:19, Tomas Ramirez 
<tom...@windward.net<mailto:tom...@windward.net>> wrote:
I've done some investigating, and here's what I noticed.  My web parts (in my 
dev environment) are capable of creating and writing to the file that I 
specified in the RollingFileAppender, so it shouldn't be any problem with 
permission to that file.  That makes me think that it must be a problem with 
log4net getting the configuration information in the first place.  But I'm just 
theorizing, in hopes that this will help someone help me figure out what's 
going on.

- Tomas


-----Original Message-----
From: Tomas Ramirez [mailto:tom...@windward.net<mailto:tom...@windward.net>]
Sent: Tuesday, February 23, 2010 3:02 PM
To: log4net-user@logging.apache.org<mailto:log4net-user@logging.apache.org>
Subject: no log file generated

Hi, I'm trying to use log4net in sharepoint web parts, but no log file is being 
generated.  Is there something I'm forgetting to do?  Here's what I've got:

I've got a web part that calls:
       log4net.Config.XmlConfigurator.Configure();
       ILog log = LogManager.GetLogger(typeof(DataDefinitionWebPart));
       log.Fatal(String.Format("{0}\n{1}\n{2}", ex.Message, ex.Source, 
ex.StackTrace));

Then in my web config, I have a log4net section in configSections
       <section name="log4net" 
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

And I here's what I have in the log4net section:
 <log4net>
   <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
     <layout type="log4net.Layout.PatternLayout">
       <param name="ConversionPattern" value="[%t] ac.server %-5p %c - %m%n" />
     </layout>
   </appender>
   <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
     <layout type="log4net.Layout.PatternLayout">
       <param name="ConversionPattern" value="[%t] ac.server %-5p %c - %m%n" />
     </layout>
   </appender>
   <appender name="RollingFileAppender" 
type="log4net.Appender.RollingFileAppender">
     <!-- This is where your log is saved -->
     <param name="File" value="F:\arrowlog.txt" />
     <appendToFile value="true" />
     <rollingStyle value="Date" />
     <datePattern value=".yyyy-MM-dd" />
     <layout type="log4net.Layout.PatternLayout">
       <param name="ConversionPattern" value="%d [%t] ac.server %-5p %c - %m%n" 
/>
     </layout>
   </appender>
   <root>
     <level value="DEBUG" />
     <appender-ref ref="ConsoleAppender" />
     <appender-ref ref="TraceAppender" />
     <appender-ref ref="RollingFileAppender" />
   </root>
 </log4net>

Thanks!
- Tomas




--
Cankut Eskin

Reply via email to