logo       

RE: FileAppender's OpenFile() has mandatory call to Directory.CreateDirecto: msg#00050

log.log4net.user

Subject: RE: FileAppender's OpenFile() has mandatory call to Directory.CreateDirectory(...)

This is a bug in the FileAppender. It has been fixed in the CVS
repository. You can either make a local mod to your copy of the source
or pull the CVS version of log4net and use that.

The fix is to add an Directory.Exists check around the
Directory.CreateDirectory.

Nicko

> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@xxxxxxxxx]
> Sent: 11 February 2005 02:58
> To: log4net-user@xxxxxxxxxxxxxxxxxx
> Subject: FileAppender's OpenFile() has mandatory call to
> Directory.CreateDirectory(...)
>
> When I uploaded my project to my web hosting company I was
> able to capture log4net's internal debug messages and output
> them to a file (which tells me the folder where the log files
> are being written to exists and is writable). The following
> exception appeared in the log
> file:
>
> OpenFile(d:\hosting\xyz\Logs\log.txt,True) call failed.
> System.IO.DirectoryNotFoundException: Could not find a part
> of the path "d:\".
> at System.IO.__Error.WinIOError(Int32 errorCode, String str)
> at System.IO.Directory.InternalCreateDirectory(String
> fullPath, String path)
> at System.IO.Directory.CreateDirectory(String path)
> at log4net.Appender.FileAppender.OpenFile(String fileName, Boolean
> append)
>
> Visual Studio told me this about the exception:
>
> "
> System.IO.DirectoryNotFoundException: The specified path is
> invalid, such as being on an unmapped drive.
> "
>
> It does exist becuase I'm logging log4net's internal messages
> to a file in the same folder:
>
> d:\hosting\xyz\Logs\log4net.txt
>
> I use the following code to create that file:
>
> string physicalPathLogFile =
> Path.Combine(
> System.Web.HttpRuntime.AppDomainAppPath,
> LOG4NET_LOG_FILE);
>
> FileStream fileStream = new FileStream(
> physicalPathLogFile,
> FileMode.Create,
> FileAccess.Write );
>
> If I comment out this line in FileAppender (and the lines
> that reference LogLog, m_fileName, and m_appendToFile):
>
> // Ensure that the directory structure exists
> Directory.CreateDirectory((new FileInfo(fileName)).DirectoryName);
>
> Everything works ok. Is there a way to tell the FileAppender
> that I _don't_ want to perform the directory structure check?
>
> - Ron
>



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise