Below is a routine I use for creating log files. It works great on most VB
Applications. However, for web services, it needs some help. The problem
is I cant reflect properly into a web service to find out where the .DLL is.
As is, this code writes a log file ok, but the log file ends up buried
directory deep inside the .Net Framework directories. Anyone know how to
find the path of a web service .DLL so I can fix this code to write to the
"bin" directory where the Web Service Dll is?
Public Function get_name_of_app lication(Option al ByVal
IncludeFullPath OfExe As Boolean = False) As String
Dim Application_Dir ectory As String
Dim Asm As System.Reflecti on.Assembly = _
System.Reflecti on.Assembly.Get ExecutingAssemb ly
Dim strConfigLoc As String = Asm.Location
If Not IncludeFullPath OfExe Then
strConfigLoc = GetFileNameOnly (Asm.Location)
End If
get_name_of_app lication = strConfigLoc.To String
End Function
Public Sub COMMON_Module_P rint(ByVal MyMessage As String, Optional ByVal
WriteToFile As Boolean = False)
Try
Static TodaysDate As Date = Now
Debug.WriteLine (MyMessage)
If WriteToFile Then
Dim OutputLogFileNa me As String =
get_name_of_app lication(True) & ".Log"
COMMON_FILE_Mod ule.FILE_Append File(MyMessage,
OutputLogFileNa me)
If Now.Date < TodaysDate.Date Then
'Archive OutputFile
Dim ArchivedFileNam e As String = OutputLogFileNa me &
".Archived. " & Now.Date.ToShor tDateString.Rep lace("/", "-")
FILE_ForceMove( OutputLogFileNa me, ArchivedFileNam e)
TodaysDate = Now
End If
End If
Catch ex As Exception
RaiseEvent Mod_Print("COMM ON_Module_Print : " & ex.Message)
End Try
End Sub
Applications. However, for web services, it needs some help. The problem
is I cant reflect properly into a web service to find out where the .DLL is.
As is, this code writes a log file ok, but the log file ends up buried
directory deep inside the .Net Framework directories. Anyone know how to
find the path of a web service .DLL so I can fix this code to write to the
"bin" directory where the Web Service Dll is?
Public Function get_name_of_app lication(Option al ByVal
IncludeFullPath OfExe As Boolean = False) As String
Dim Application_Dir ectory As String
Dim Asm As System.Reflecti on.Assembly = _
System.Reflecti on.Assembly.Get ExecutingAssemb ly
Dim strConfigLoc As String = Asm.Location
If Not IncludeFullPath OfExe Then
strConfigLoc = GetFileNameOnly (Asm.Location)
End If
get_name_of_app lication = strConfigLoc.To String
End Function
Public Sub COMMON_Module_P rint(ByVal MyMessage As String, Optional ByVal
WriteToFile As Boolean = False)
Try
Static TodaysDate As Date = Now
Debug.WriteLine (MyMessage)
If WriteToFile Then
Dim OutputLogFileNa me As String =
get_name_of_app lication(True) & ".Log"
COMMON_FILE_Mod ule.FILE_Append File(MyMessage,
OutputLogFileNa me)
If Now.Date < TodaysDate.Date Then
'Archive OutputFile
Dim ArchivedFileNam e As String = OutputLogFileNa me &
".Archived. " & Now.Date.ToShor tDateString.Rep lace("/", "-")
FILE_ForceMove( OutputLogFileNa me, ArchivedFileNam e)
TodaysDate = Now
End If
End If
Catch ex As Exception
RaiseEvent Mod_Print("COMM ON_Module_Print : " & ex.Message)
End Try
End Sub
Comment