Your problem is the file name.  It looks like a directory to .NET.

Try this

 <param name="File" value="C:\PTS1.3\MyApplication.Log"/>

Also, with the RollingFileAppender you will want to grant the ASPNET user
Modify permissions on the directory.  Log4Net needs this to do file deleting
and renaming. 

-----Original Message-----
From: Karnecki, David (Modis) [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 21, 2007 8:38 AM
To: Log4NET User
Subject: RE: log4net WILL NOT write to the log file.

Good Morning Ron,

Thank you for the quick response.

After sending the initial email someone here suggested that I add

<Assembly: log4net.Config.XmlConfigurator()>

to my project and that has given a more complete debug log that I have
attached.  
The same problem but with log4net error messages. The error indicates
incorrect permissions, but as I stated earlier, ASPNET does have write
permissions on the \Log subdir.  
The web.config sections follow below and the debug log and a wordpad file
that contains a screenshot of the \Log subdir ASPNET permissions is also
attached.

Thanks in advance for your help.

Dave K




>From web.config.  The sections follow: 
-----------------------------------------------------------------------
<!--  log4net Appender settings  -->
  <configSections>
    <section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
requirePermission="false"/>
  </configSections>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add
                name="textWriterTraceListener"
                type="System.Diagnostics.TextWriterTraceListener"
                initializeData="C:\temp\log4net.txt" />
      </listeners>
    </trace>
  </system.diagnostics>
  <log4net>
    <logger name="PTS">
      <level value="ALL"/>
      <appender-ref ref="RollingFileAppender"/>
    </logger>
    <root>
      <level value="INFO"/>
      <appender-ref ref="RollingFileAppender"/>
    </root>
    <appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender">
      <param name="File" value="C:\PTS1.3\Log"/>
      <param name="AppendToFile" value="true"/>
      <rollingStyle value="Size"/>
      <maxSizeRollBackups value="10"/>
      <maximumFileSize value="10MB"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd hh:mm:ss}
- %m%n"/>
      </layout>
    </appender>
  </log4net>
  <appSettings>
    <add key="log4net.Internal.Debug" value="true"/>




-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]
Sent: Monday, August 20, 2007 7:17 PM
To: Log4NET User
Subject: Re: log4net WILL NOT write to the log file.


Where is your code that initializes log4net? Are you initializing log4net
from the web.config or from log4net.config?


----- Original Message ----

From: "Karnecki, David (Modis)" <[EMAIL PROTECTED]>

To: [email protected]

Sent: Monday, August 20, 2007 8:53:14 AM

Subject: log4net WILL NOT write to the log file.



     To Whom It May Concern:

  

 I have 1st insured  that the ASPNET account has write privileges on my \Log
subdirectory before  I sent this question.

  

 The code fragment  I'm using to write with is below.  I have also tried
example code straight  from your samples

 to no avail.   There is another app running on the same server which
has no trouble writing to  its log file via

 log4net. I've set my  app up the same as his.

  

 Can there be any  other reason the log isn't being written?

  

 Thanks,

  

 Cordially,

 Dave  Karneck

 [EMAIL PROTECTED]

  

 
------------------------------------------------------------------------
-----------------------------------------------------------------------

    log4net version :    1.2.10    Assembly type is    .dll    ASP.Net
application    running on IIS    Desktop is WIndows    XP v5.1 SP2
debug file produced    is attached
------------------------------------------------------------------------
-----------------------------------------------------------------------

 CODE FRAGMENT

 
------------------------------------------------------------------------
-----------------------------------------------------------------------



 Dim Log As ILog =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().Dec
laringType)

 Dim errMessage As String = "Task Order Types could  not be retrieved from
table 'TASK_ORDER'."

 Dim errMsg As String = ""

  

 If IsNothing(ex.InnerException) Then

     errMsg = Log.Logger.Name.ToString() & vbCrLf & errMessage  & vbCrLf &
ex.Message & vbCrLf &  Environment.StackTrace

 Else

    errMsg = Log.Logger.Name.ToString()  & vbCrLf & errMessage & vbCrLf &
ex.Message & vbCrLf &  ex.InnerException.ToString

 End  If

 Log.Error(errMsg)











Reply via email to