Logging: Log Inner Exceptions

This commit is contained in:
Jonathan Jenne 2020-12-10 11:33:54 +01:00
parent b89ca3aa5a
commit 8ffec017e0
11 changed files with 282 additions and 22 deletions

View File

@ -2,9 +2,9 @@
<configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot"> <configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot">
<behaviors /> <behaviors />
<bindings> <bindings>
<binding digest="System.ServiceModel.Configuration.NetTcpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data name=&quot;tcpBinding&quot; transferMode=&quot;Streamed&quot;&gt;&lt;security&gt;&lt;transport sslProtocols=&quot;None&quot; /&gt;&lt;/security&gt;&lt;/Data&gt;" bindingType="netTcpBinding" name="tcpBinding" /> <binding digest="System.ServiceModel.Configuration.NetTcpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data name=&quot;NetTcpBinding_IEDMIService&quot; transferMode=&quot;Streamed&quot;&gt;&lt;security&gt;&lt;transport sslProtocols=&quot;None&quot; /&gt;&lt;/security&gt;&lt;/Data&gt;" bindingType="netTcpBinding" name="NetTcpBinding_IEDMIService" />
</bindings> </bindings>
<endpoints> <endpoints>
<endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;net.tcp://localhost:9000/DigitalData/Services/Main&quot; binding=&quot;netTcpBinding&quot; bindingConfiguration=&quot;tcpBinding&quot; contract=&quot;EDMIServiceReference.IEDMIService&quot; name=&quot;tcpBinding&quot;&gt;&lt;identity&gt;&lt;servicePrincipalName value=&quot;host/sDD-VMP03-VM09.dd-san01.dd-gan.local.digitaldata.works&quot; /&gt;&lt;/identity&gt;&lt;/Data&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;net.tcp://localhost:9000/DigitalData/Services/Main&quot; binding=&quot;netTcpBinding&quot; bindingConfiguration=&quot;tcpBinding&quot; contract=&quot;EDMIServiceReference.IEDMIService&quot; name=&quot;tcpBinding&quot;&gt;&lt;identity&gt;&lt;servicePrincipalName value=&quot;host/sDD-VMP03-VM09.dd-san01.dd-gan.local.digitaldata.works&quot; /&gt;&lt;/identity&gt;&lt;/Data&gt;" contractName="EDMIServiceReference.IEDMIService" name="tcpBinding" /> <endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;net.tcp://localhost:9000/DigitalData/Services/Main&quot; binding=&quot;netTcpBinding&quot; bindingConfiguration=&quot;NetTcpBinding_IEDMIService&quot; contract=&quot;EDMIServiceReference.IEDMIService&quot; name=&quot;NetTcpBinding_IEDMIService&quot;&gt;&lt;identity&gt;&lt;servicePrincipalName value=&quot;host/sDD-VMP03-VM09.dd-san01.dd-gan.local.digitaldata.works&quot; /&gt;&lt;/identity&gt;&lt;/Data&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;net.tcp://localhost:9000/DigitalData/Services/Main&quot; binding=&quot;netTcpBinding&quot; bindingConfiguration=&quot;NetTcpBinding_IEDMIService&quot; contract=&quot;EDMIServiceReference.IEDMIService&quot; name=&quot;NetTcpBinding_IEDMIService&quot;&gt;&lt;identity&gt;&lt;servicePrincipalName value=&quot;host/sDD-VMP03-VM09.dd-san01.dd-gan.local.digitaldata.works&quot; /&gt;&lt;/identity&gt;&lt;/Data&gt;" contractName="EDMIServiceReference.IEDMIService" name="NetTcpBinding_IEDMIService" />
</endpoints> </endpoints>
</configurationSnapshot> </configurationSnapshot>

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<SavedWcfConfigurationInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="9.1" CheckSum="kW1pXkU3loV3ggP1jXPpV/Y9PXk="> <SavedWcfConfigurationInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="9.1" CheckSum="7vHCICtS9kfxcx4e4JOhjxocA18=">
<bindingConfigurations> <bindingConfigurations>
<bindingConfiguration bindingType="netTcpBinding" name="tcpBinding"> <bindingConfiguration bindingType="netTcpBinding" name="NetTcpBinding_IEDMIService">
<properties> <properties>
<property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>tcpBinding</serializedValue> <serializedValue>NetTcpBinding_IEDMIService</serializedValue>
</property> </property>
<property path="/closeTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/closeTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue /> <serializedValue />
@ -121,7 +121,7 @@
</bindingConfiguration> </bindingConfiguration>
</bindingConfigurations> </bindingConfigurations>
<endpoints> <endpoints>
<endpoint name="tcpBinding" contract="EDMIServiceReference.IEDMIService" bindingType="netTcpBinding" address="net.tcp://localhost:9000/DigitalData/Services/Main" bindingConfiguration="tcpBinding"> <endpoint name="NetTcpBinding_IEDMIService" contract="EDMIServiceReference.IEDMIService" bindingType="netTcpBinding" address="net.tcp://localhost:9000/DigitalData/Services/Main" bindingConfiguration="NetTcpBinding_IEDMIService">
<properties> <properties>
<property path="/address" isComplexType="false" isExplicitlyDefined="true" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/address" isComplexType="false" isExplicitlyDefined="true" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>net.tcp://localhost:9000/DigitalData/Services/Main</serializedValue> <serializedValue>net.tcp://localhost:9000/DigitalData/Services/Main</serializedValue>
@ -133,7 +133,7 @@
<serializedValue>netTcpBinding</serializedValue> <serializedValue>netTcpBinding</serializedValue>
</property> </property>
<property path="/bindingConfiguration" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/bindingConfiguration" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>tcpBinding</serializedValue> <serializedValue>NetTcpBinding_IEDMIService</serializedValue>
</property> </property>
<property path="/contract" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/contract" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>EDMIServiceReference.IEDMIService</serializedValue> <serializedValue>EDMIServiceReference.IEDMIService</serializedValue>
@ -196,7 +196,7 @@
<serializedValue>False</serializedValue> <serializedValue>False</serializedValue>
</property> </property>
<property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>tcpBinding</serializedValue> <serializedValue>NetTcpBinding_IEDMIService</serializedValue>
</property> </property>
<property path="/kind" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <property path="/kind" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue /> <serializedValue />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://DigitalData.Services.EDMIService" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="EDMIService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:i0="http://DigitalData.Services.EDMIService" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="EDMIService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsp:Policy wsu:Id="tcpBinding_policy"> <wsp:Policy wsu:Id="NetTcpBinding_IEDMIService_policy">
<wsp:ExactlyOne> <wsp:ExactlyOne>
<wsp:All> <wsp:All>
<msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1"> <msb:BinaryEncoding xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1">
@ -37,8 +37,8 @@
</wsp:Policy> </wsp:Policy>
<wsdl:import namespace="http://DigitalData.Services.EDMIService" location="" /> <wsdl:import namespace="http://DigitalData.Services.EDMIService" location="" />
<wsdl:types /> <wsdl:types />
<wsdl:binding name="tcpBinding" type="i0:IEDMIService"> <wsdl:binding name="NetTcpBinding_IEDMIService" type="i0:IEDMIService">
<wsp:PolicyReference URI="#tcpBinding_policy"> <wsp:PolicyReference URI="#NetTcpBinding_IEDMIService_policy">
</wsp:PolicyReference> </wsp:PolicyReference>
<soap12:binding transport="http://schemas.microsoft.com/soap/tcp" /> <soap12:binding transport="http://schemas.microsoft.com/soap/tcp" />
<wsdl:operation name="Heartbeat"> <wsdl:operation name="Heartbeat">
@ -170,7 +170,7 @@
</wsdl:operation> </wsdl:operation>
</wsdl:binding> </wsdl:binding>
<wsdl:service name="EDMIService"> <wsdl:service name="EDMIService">
<wsdl:port name="tcpBinding" binding="tns:tcpBinding"> <wsdl:port name="NetTcpBinding_IEDMIService" binding="tns:NetTcpBinding_IEDMIService">
<soap12:address location="net.tcp://localhost:9000/DigitalData/Services/Main" /> <soap12:address location="net.tcp://localhost:9000/DigitalData/Services/Main" />
<wsa10:EndpointReference> <wsa10:EndpointReference>
<wsa10:Address>net.tcp://localhost:9000/DigitalData/Services/Main</wsa10:Address> <wsa10:Address>net.tcp://localhost:9000/DigitalData/Services/Main</wsa10:Address>

View File

@ -25,7 +25,7 @@
<system.serviceModel> <system.serviceModel>
<bindings> <bindings>
<netTcpBinding> <netTcpBinding>
<binding name="tcpBinding" transferMode="Streamed"> <binding name="NetTcpBinding_IEDMIService" transferMode="Streamed">
<security> <security>
<transport sslProtocols="None" /> <transport sslProtocols="None" />
</security> </security>
@ -34,8 +34,8 @@
</bindings> </bindings>
<client> <client>
<endpoint address="net.tcp://localhost:9000/DigitalData/Services/Main" <endpoint address="net.tcp://localhost:9000/DigitalData/Services/Main"
binding="netTcpBinding" bindingConfiguration="tcpBinding" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IEDMIService"
contract="EDMIServiceReference.IEDMIService" name="tcpBinding"> contract="EDMIServiceReference.IEDMIService" name="NetTcpBinding_IEDMIService">
<identity> <identity>
<servicePrincipalName value="host/sDD-VMP03-VM09.dd-san01.dd-gan.local.digitaldata.works" /> <servicePrincipalName value="host/sDD-VMP03-VM09.dd-san01.dd-gan.local.digitaldata.works" />
</identity> </identity>

View File

@ -87,11 +87,12 @@ Public Class LogConfig
Private Const LOG_FORMAT_BASE As String = DATE_FORMAT_DEFAULT & "|${logger:shortName=True}|${level:uppercase=true}" Private Const LOG_FORMAT_BASE As String = DATE_FORMAT_DEFAULT & "|${logger:shortName=True}|${level:uppercase=true}"
Private Const LOG_FORMAT_BASE_LONG_DATE As String = DATE_FORMAT_LONG & "|${logger:shortName=True}|${level:uppercase=true}" Private Const LOG_FORMAT_BASE_LONG_DATE As String = DATE_FORMAT_LONG & "|${logger:shortName=True}|${level:uppercase=true}"
Private Const LOG_FORMAT_CALLSITE As String = "${callsite:className=false:fileName=true:includeSourcePath=false:methodName=true}" Private Const LOG_FORMAT_CALLSITE As String = "${callsite:className=false:fileName=true:includeSourcePath=false:methodName=true}"
Private Const LOG_FORMAT_EXCEPTION As String = "${exception:format=Message,StackTrace:innerFormat=Message:maxInnerExceptionLevel=1}"
Private Const LOG_FORMAT_DEFAULT As String = LOG_FORMAT_BASE & " >> ${message}" Private Const LOG_FORMAT_DEFAULT As String = LOG_FORMAT_BASE & " >> ${message}"
Private Const LOG_FORMAT_EXCEPTION As String = LOG_FORMAT_BASE & " >> ${exception:format=Message}${newline}${exception:format=StackTrace}" Private Const LOG_FORMAT_ERROR As String = LOG_FORMAT_BASE & " >> " & LOG_FORMAT_EXCEPTION
Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> " & LOG_FORMAT_CALLSITE & " -> ${message}" Private Const LOG_FORMAT_DEBUG As String = LOG_FORMAT_BASE_LONG_DATE & " >> " & LOG_FORMAT_CALLSITE & " -> ${message}"
Private Const LOG_FORMAT_MEMORY As String = LOG_FORMAT_BASE_LONG_DATE & " >> ${message}${newline}${exception:format=Message}${newline}${exception:format=StackTrace}" Private Const LOG_FORMAT_MEMORY As String = LOG_FORMAT_BASE_LONG_DATE & " >> " & LOG_FORMAT_EXCEPTION
Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt" Private Const FILE_NAME_ACCESS_TEST = "accessTest.txt"
Private Const FOLDER_NAME_LOG = "Log" Private Const FOLDER_NAME_LOG = "Log"
@ -404,7 +405,7 @@ Public Class LogConfig
Dim errorLogWithExceptions As New FileTarget() With { Dim errorLogWithExceptions As New FileTarget() With {
.FileName = Path.Combine(basePath, FILE_NAME_FORMAT_ERROR), .FileName = Path.Combine(basePath, FILE_NAME_FORMAT_ERROR),
.Name = TARGET_ERROR_EX, .Name = TARGET_ERROR_EX,
.Layout = LOG_FORMAT_EXCEPTION, .Layout = LOG_FORMAT_ERROR,
.MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT, .MaxArchiveFiles = MAX_ARCHIVE_FILES_DEFAULT,
.ArchiveEvery = ARCHIVE_EVERY, .ArchiveEvery = ARCHIVE_EVERY,
.KeepFileOpen = KEEP_FILES_OPEN .KeepFileOpen = KEEP_FILES_OPEN

View File

@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' übernehmen, indem Sie "*" eingeben: ' übernehmen, indem Sie "*" eingeben:
' <Assembly: AssemblyVersion("1.0.*")> ' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.0.2.0")> <Assembly: AssemblyVersion("2.0.3.0")>
<Assembly: AssemblyFileVersion("2.0.2.0")> <Assembly: AssemblyFileVersion("2.0.3.0")>

View File

@ -37,6 +37,8 @@ Public Class EDMIService
Dim oDescription = ContractDescription.GetContract(GetType(IEDMIService), GetType(EDMIService)) Dim oDescription = ContractDescription.GetContract(GetType(IEDMIService), GetType(EDMIService))
Dim oEndpoint As New ServiceEndpoint(oDescription, oBinding, oAddress) Dim oEndpoint As New ServiceEndpoint(oDescription, oBinding, oAddress)
Config.AddServiceEndpoint(oEndpoint) Config.AddServiceEndpoint(oEndpoint)
Config.Description.Behaviors.Add(New ServiceDebugBehavior With {.IncludeExceptionDetailInFaults = True}) Config.Description.Behaviors.Add(New ServiceDebugBehavior With {.IncludeExceptionDetailInFaults = True})
End Sub End Sub

View File

@ -125,6 +125,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Config.vb" /> <Compile Include="Config.vb" />
<Compile Include="EDMITraceListener.vb" />
<Compile Include="GlobalState.vb" /> <Compile Include="GlobalState.vb" />
<Compile Include="Messages.vb" /> <Compile Include="Messages.vb" />
<Compile Include="Results\BaseResult.vb" /> <Compile Include="Results\BaseResult.vb" />

View File

@ -0,0 +1,251 @@
Imports System.Configuration
Imports System.Globalization
Imports System.IO
Imports System.Security.Permissions
Imports System.Text.RegularExpressions
''' <summary>
''' Adapted from: https://www.codeproject.com/Articles/30956/A-Rolling-XmlWriterTraceListener
''' </summary>
<HostProtection(Synchronization:=True)>
Public Class EDMITraceListener
Inherits XmlWriterTraceListener
Private Shared ReadOnly LogFileNumberCaptureName As String = "LogFileNumber"
Private _attributesLoaded As Boolean = False
Private _logfileSuffixExpression As Regex = New Regex("_(?<" & LogFileNumberCaptureName & ">\d*)\.", RegexOptions.Compiled)
Private _currentFileSuffixNumber As Integer = 0
Private _maxTraceFileSize As Long = 128 * 1024 * 1024
Private _basicTraceFileName As String = String.Empty
Public Sub New(ByVal filename As String)
MyBase.New(filename)
Me._basicTraceFileName = filename
Me._currentFileSuffixNumber = Me.GetTraceFileNumber()
Me.StartNewTraceFile()
End Sub
Public Sub New(ByVal filename As String, ByVal name As String)
MyBase.New(filename, name)
Me._basicTraceFileName = filename
Me.StartNewTraceFile()
End Sub
Public ReadOnly Property CurrentTraceFileName As String
Get
Return Path.Combine(Path.GetDirectoryName(Me._basicTraceFileName), Path.GetFileNameWithoutExtension(Me._basicTraceFileName) & "_" & Me._currentFileSuffixNumber.ToString().PadLeft(4, "0"c) & Path.GetExtension(Me._basicTraceFileName))
End Get
End Property
Public Property MaxTraceFileSize As Long
Get
If Not Me._attributesLoaded Then
Me.LoadAttributes()
End If
Return Me._maxTraceFileSize
End Get
Set(ByVal value As Long)
If Not Me._attributesLoaded Then
Me.LoadAttributes()
End If
Me._maxTraceFileSize = value
End Set
End Property
Protected ReadOnly Property IsRollingConditionReached As Boolean
Get
Dim streamWriter As StreamWriter = CType(Me.Writer, StreamWriter)
Dim fileStream As FileStream = CType(streamWriter.BaseStream, FileStream)
Dim traceFileName As String = fileStream.Name
Dim traceFileInfo As FileInfo = New FileInfo(traceFileName)
If traceFileInfo.Length > Me.MaxTraceFileSize Then
Return True
Else
Return False
End If
End Get
End Property
Public Overrides Sub Fail(ByVal message As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.Fail(message)
End Sub
Public Overrides Sub Fail(ByVal message As String, ByVal detailMessage As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.Fail(message, detailMessage)
End Sub
Public Overrides Sub TraceData(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ByVal data As Object)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.TraceData(eventCache, source, eventType, id, data)
End Sub
Public Overrides Sub TraceData(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ParamArray data As Object())
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.TraceData(eventCache, source, eventType, id, data)
End Sub
Public Overrides Sub TraceEvent(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.TraceEvent(eventCache, source, eventType, id)
End Sub
Public Overrides Sub TraceEvent(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ByVal message As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.TraceEvent(eventCache, source, eventType, id, message)
End Sub
Public Overrides Sub TraceEvent(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal eventType As TraceEventType, ByVal id As Integer, ByVal format As String, ParamArray args As Object())
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.TraceEvent(eventCache, source, eventType, id, format, args)
End Sub
Public Overrides Sub TraceTransfer(ByVal eventCache As TraceEventCache, ByVal source As String, ByVal id As Integer, ByVal message As String, ByVal relatedActivityId As Guid)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.TraceTransfer(eventCache, source, id, message, relatedActivityId)
End Sub
Public Overrides Sub Write(ByVal o As Object)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.Write(o)
End Sub
Public Overrides Sub Write(ByVal o As Object, ByVal category As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.Write(o, category)
End Sub
Public Overrides Sub Write(ByVal message As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.Write(message)
End Sub
Public Overrides Sub Write(ByVal message As String, ByVal category As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.Write(message, category)
End Sub
Public Overrides Sub WriteLine(ByVal o As Object)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.WriteLine(o)
End Sub
Public Overrides Sub WriteLine(ByVal o As Object, ByVal category As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.WriteLine(o, category)
End Sub
Public Overrides Sub WriteLine(ByVal message As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.WriteLine(message)
End Sub
Public Overrides Sub WriteLine(ByVal message As String, ByVal category As String)
If Me.IsRollingConditionReached Then
Me.StartNewTraceFile()
End If
MyBase.WriteLine(message, category)
End Sub
Protected Overrides Function GetSupportedAttributes() As String()
Return New String(0) {"MaxTraceFileSize"}
End Function
Private Sub StartNewTraceFile()
Dim streamWriter As StreamWriter = CType(Me.Writer, StreamWriter)
Dim fileStream As FileStream = CType(streamWriter.BaseStream, FileStream)
fileStream.Close()
Me._currentFileSuffixNumber += 1
Me.Writer = New StreamWriter(New FileStream(Me.CurrentTraceFileName, FileMode.Create))
End Sub
Private Function GetTraceFileNumber() As Integer
Dim directoryName As String = Path.GetDirectoryName(Me._basicTraceFileName)
Dim basicTraceFileNameWithoutExtension As String = Path.GetFileNameWithoutExtension(Me._basicTraceFileName)
Dim basicTraceFileNameExtension As String = Path.GetExtension(Me._basicTraceFileName)
Dim existingLogFiles As String() = Directory.GetFiles(directoryName, basicTraceFileNameWithoutExtension & "*")
Dim highestNumber As Integer = -1
For Each existingLogFile As String In existingLogFiles
Dim match As Match = Me._logfileSuffixExpression.Match(existingLogFile)
If match IsNot Nothing Then
Dim tempInt As Integer
If match.Groups.Count >= 1 AndAlso Integer.TryParse(match.Groups(LogFileNumberCaptureName).Value, tempInt) AndAlso tempInt >= highestNumber Then
highestNumber = tempInt
End If
End If
Next
Return highestNumber
End Function
Private Sub LoadAttributes()
If Attributes.ContainsKey("MaxTraceFileSize") AndAlso Not String.IsNullOrEmpty(Attributes("MaxTraceFileSize")) Then
Dim tempLong As Long = 0
Dim attributeValue As String = Attributes("MaxTraceFileSize")
If Long.TryParse(attributeValue, tempLong) Then
Me.MaxTraceFileSize = Long.Parse(Attributes("MaxTraceFileSize"), NumberFormatInfo.InvariantInfo)
Else
Throw New ConfigurationErrorsException(String.Format("Trace listener {0} has an unparseable configuration attribute ""MaxTraceFileSize"". The value ""{1}"" cannot be parsed to a long value.", Me.Name, attributeValue))
End If
End If
Me._attributesLoaded = True
End Sub
End Class

View File

@ -6,6 +6,7 @@ Imports Quartz.Listener
Public Class JobListener Public Class JobListener
Inherits JobListenerSupport Inherits JobListenerSupport
Public Overrides ReadOnly Property Name As String = "JobListener" Public Overrides ReadOnly Property Name As String = "JobListener"
Public Property Dataset As DataSet Public Property Dataset As DataSet
@ -31,7 +32,7 @@ Public Class JobListener
Dim oDatatableNameTemp As String = oDatatableName & "-TEMP" Dim oDatatableNameTemp As String = oDatatableName & "-TEMP"
If Dataset.Tables.Contains(oDatatableName) Then If Dataset.Tables.Contains(oDatatableName) Then
_Logger.Debug("DataTable [{0}] exists, renaming and replacing", oDatatableName) _Logger.Debug("DataTable [{0}] exists, renaming and replacing in DataSet", oDatatableName)
' Rename the new table, add TEMP suffix ' Rename the new table, add TEMP suffix
oDataTable.TableName = oDatatableNameTemp oDataTable.TableName = oDatatableNameTemp
' Add the new table to the dataset ' Add the new table to the dataset
@ -41,7 +42,7 @@ Public Class JobListener
' Rename the new table ' Rename the new table
Dataset.Tables.Item(oDatatableNameTemp).TableName = oDatatableName Dataset.Tables.Item(oDatatableNameTemp).TableName = oDatatableName
Else Else
_Logger.Debug("DataTable [{0}] does not exist, adding", oDatatableName) _Logger.Debug("DataTable [{0}] does not exist, adding to DataSet", oDatatableName)
Dataset.Tables.Add(oDataTable) Dataset.Tables.Add(oDataTable)
End If End If

View File

@ -9,11 +9,15 @@ Public Class ServiceHost(Of T)
MyBase.New(GetType(T), baseAddresses) MyBase.New(GetType(T), baseAddresses)
End Sub End Sub
Public Sub EnableMetadataExchange(ByVal Optional EnableHttpGet As Boolean = True) Public Sub EnableMetadataExchange(ByVal Optional EnableHttpGet As Boolean = True)
If State = CommunicationState.Opened Then If State = CommunicationState.Opened Then
Throw New InvalidOperationException("Host is already opened") Throw New InvalidOperationException("Host is already opened")
End If End If
Dim oMetadataBehavior As ServiceMetadataBehavior = Description.Behaviors.Find(Of ServiceMetadataBehavior)() Dim oMetadataBehavior As ServiceMetadataBehavior = Description.Behaviors.Find(Of ServiceMetadataBehavior)()
If oMetadataBehavior Is Nothing Then If oMetadataBehavior Is Nothing Then