Dear Ron,
Thank you for your reply. I have successfully resolved the problem.
The HOMEPATH environment by itself returns the directory without the drive.
i.e. \DOCUMENT and SETTINGS\USERNAME
Therefore to resolve this problem, we need to add a HOMEDRIVE environment
variable before the homepath
i.e. Dim location as string = "${HOMEDRIVE}${HOMEPATH}\APPLICATION\Log\log.txt"
will do the trick fine.
Once again, thank you for your help and the amazing work you did for log4net.
It is really amazing what you have achieved.
Eugene
-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 24, 2007 7:48 PM
To: Log4NET Dev
Subject: Re: Configuration problems
On my machine the environment variable HOMEPATH seems to always point to my
home directory. Perhaps you could use that to create the path:
Dim location As String
= "${HOMEPATH}\APPLICATION\Log\log.txt"
log4net will replace ${HOMEPATH} with the appropriate environment variable. You
can also build the string yourself with the Environment class that is part of
the Framework. Does 1.1 have these special constants?
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
----- Original Message ----
From: Eugene Lim <[EMAIL PROTECTED]>
To: [email protected]
Sent: Tuesday, April 24, 2007 4:42:20 AM
Subject: Configuration problems
Dear all,
Recently, I seem to have problems configuring the log4net. I am using Visual
Studio 2003 and am developing a rich client application. I depend on the logs
to tell me what the errors are when troubleshooting by remote.
When I configure the settings using the xml in the app.config file, it works
fine without problems for users who have administrator privileges
However, because many normal users with no administrator privileges are
experiencing having no records of their log files, I have decided to move the
log files into the user directory as Windows XP does not allow ordinary user
accounts to write to the C:\Program Files folder and sub folder This means that
the directory of where to store the log file is dynamically changed, depending
on the windows login user. (e.g. c:\Documents and
Settings\USERNAME\applicationName\log.txt )
The problem is that when this is programmatically generated, it does not
generate any log:
Please find below my code for your kind perusal:
Public Sub New()
'File Appender
Dim fileappender As New log4net.Appender.FileAppender
Dim temp As String = WindowsIdentity.GetCurrent.Name
Dim location As String
‘Remove the domain if it exists
If temp.IndexOf("\") > 0 Then
temp = temp.Substring(temp.IndexOf("\") + 1, temp.Length -
temp.IndexOf("\") - 1)
location = "C:\Documents and Settings\" & temp &
"\APPLICATION\Log\log.txt"
Else
location = "C:\Documents and Settings\" &
WindowsIdentity.GetCurrent.Name & "\APPLICATION\Log\ log.txt"
End If
fileappender.File = location
fileappender.AppendToFile = True
fileappender.Layout = New
log4net.Layout.PatternLayout("%date{dd-MM-yyyy} %-5level [%thread]: [%ndc]
%message %newline")
BasicConfigurator.Configure(fileappender)
'Http appender.
Dim httpappender As New log4net.Appender.AspNetTraceAppender
httpappender.Layout = New
log4net.Layout.PatternLayout("%date{dd-MM-yyyy} %-5level [%thread]: [%ndc]
%message %newline")
'RollingLogAppender
Dim rollingappender As New log4net.Appender.RollingFileAppender
rollingappender.File = location
rollingappender.RollingStyle =
Appender.RollingFileAppender.RollingMode.Date
rollingappender.StaticLogFileName = True
rollingappender.AppendToFile = True
rollingappender.MaximumFileSize = "5MB"
rollingappender.Layout = New
log4net.Layout.PatternLayout("%date{dd-MM-yyyy} %-5level [%thread]: [%ndc]
%message %newline")
BasicConfigurator.Configure(rollingappender)
End Sub
Please did I miss out anything? Are there any examples of setting the
information without using xml files? Thank you in advance for any assistance
rendered.
Eugene