Steve,
I am aware that mapped drives are only visible to the current user. Our Windows
service is started using a specific user account and our VB.NET application is
able to cope with reading in configuration files (including the log4net.xml
file itself) from a UNC or mapped drive using the following bit of code:
Private Sub New(ByVal configFile As String)
'check that the config file is mapped drive
ConfigurationFileDetails = configFile
If Not configFile.StartsWith("\\") Then
'convert mapped drive letter
Dim search As New Management.ManagementObjectSearcher("SELECT RemoteName FROM
win32_NetworkConnection WHERE LocalName = """ + configFile.Substring(0, 2) +
"""")
Dim remoteName As String
Dim mgmtObjCollection As Management.ManagementObjectCollection = search.Get()
For Each mgmtObj As Management.ManagementObject In mgmtObjCollection
remoteName = mgmtObj("RemoteName").ToString
If Not IsNothing(remoteName) Then
remoteName += configFile.Substring(2)
ConfigurationFileDetails = remoteName
End If
Next
End If
I was hoping that there might be something similar in log4net itself?
Paul
> Date: Thu, 6 Nov 2008 07:08:49 +0100> From: [EMAIL PROTECTED]> To:
> [email protected]> Subject: Re: FW: Problems with Network
> Drive> > May i am wrong, but as far as i know are mapped network drives only>
> visible for the current which created it and not for the entry system.> UNC
> Pathes are the most common way to access a network share.> > Steve> > Paul
> Franklin schrieb:> > > > > > I am trying to log to a Network Drive using a
> RollingFileAppender but am having problems. When I set the file parameter
> value to a UNC value (\\servername\sharename\Alert.txt) it works fine
> However, when I try to set it to a mapped drive value which refers to the
> same path it fails. The internal debug is showing this: log4net:ERROR
> [RollingFileAppender] No output stream or file set for the appender named
> [TDALog].log4net: FileAppender: Opening file for writing [T:\Alert.txt]
> append [True]log4net:ERROR [RollingFileAppender] Unable to acquire lock on
> file T:\Alert.txt. Could not find a part of the path 'T:\'.log4net:ERROR
> [RollingFileAppender] OpenFile(T:\Alert.txt,True) call
> failed.log4net.Appender.FileAppender+LockingStream+LockStateException: The
> file is not currently locked at
> log4net.Appender.FileAppender.LockingStream.get_CanWrite() at
> System.IO.StreamWriter..ctor(Stream stream, Encoding encoding, Int32
> bufferSize) at System.IO.StreamWriter..ctor(Stream stream, > Encoding
> encoding) at log4net.Appender.FileAppender.OpenFile(String fileName, Boolean
> append) at log4net.Appender.RollingFileAppender.OpenFile(String fileName,
> Boolean append) at log4net.Appender.FileAppender.SafeOpenFile(String
> fileName, Boolean append)log4net:ERROR [RollingFileAppender] No output stream
> or file set for the appender named [TDALog]. When I use UNC for the same file
> it works okay: log4net: FileAppender: Opening file for writing
> [\\uncdrive\share\Alert.txt] append [True]log4net: XmlHierarchyConfigurator:
> Created Appender [TDALog]log4net: XmlHierarchyConfigurator: Adding appender
> named [TDALog] to logger [root].log4net: XmlHierarchyConfigurator: Retrieving
> an instance of log4net.Repository.Logger for logger [tda].log4net:
> XmlHierarchyConfigurator: Setting [trustda] additivity to [True].log4net:
> XmlHierarchyConfigurator: Logger [trustda] Level string is [DEBUG].log4net:
> XmlHierarchyConfigurator: Logger [trustda] level set to
> [name="DEBUG",value=30000].log4n> et: XmlHierarchyConfigurator: Adding
> appender named [TDALog] to logger [tda]. Any ideas? We would only use UNC as
> a last resort because the application is going to be distributed to multiple
> sites which all use a common drive mapping letter> > > > Click here for FREE
> customisable desktop wallpapers. Get them Now!> >
> _________________________________________________________________> > See the
> most popular videos on the web > >
> http://clk.atdmt.com/GBL/go/115454061/direct/01/
_________________________________________________________________
BigSnapSearch.com - 24 prizes a day, every day - Search Now!
http://clk.atdmt.com/UKM/go/117442309/direct/01/