Monday, May 21, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: FW: Problems with Network Drive
Prev Next
You are not authorized to post a reply.

Author Messages
Paul Franklin

11/05/2008 1:04 PM  
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].
log4net: 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!

Read amazing stories to your kids on Messenger Try it Now!
Steve Wagner

11/06/2008 7:08 AM  

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

11/10/2008 10:57 AM  
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
Dag Christensen

11/10/2008 12:30 PM  

I don't think I understand what the problem is?

You're saying writing to UNC is fine, while log4net complains about T: being unavailable? As Steve says, this indicates that T: isn't mapped for the logged on user (did the login script run successfully?)

Re your code below: If T: and the UNC path both points to the same folder for the logged on user, why would you (or log4net) want to translate T: to its equivalent UNC path?

Have you tried writing directly to "T:\" from your service? (from outside log4net)

I don't think you'll see usage of WMI in core log4net. I haven't tried this myself, but I believe you can override RollingFileAppender's File {get; set; } if you want to implement the code you posted.

Best wishes,

Dag

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > FW: Problems with Network Drive



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement