Enterprise Library: Loading the .config file

‘This .vb file shows how to load a .config file to be the defualt in the Enterprise Library

Imports Microsoft.Practices.EnterpriseLibrary.Logging
Imports Microsoft.Practices.EnterpriseLibrary.Logging.ExtraInformation
Imports Microsoft.Practices.EnterpriseLibrary.Logging.Filters
Imports Microsoft.Practices.EnterpriseLibrary.Common.Configuration

Public Class CLogger
Private Shared _singleton As CLogger

Private _configSource As New FileConfigurationSource(“EntLoggingConf.config”)
Private _configBuilder As New ConfigurationSourceBuilder
Private _logWriter As LogWriter

Private Sub New()
EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(_configSource)

_logWriter = EnterpriseLibraryContainer.Current.GetInstance(Of LogWriter)()

End Sub

Public Shared ReadOnly Property Singleton As CLogger
If _singleton Is Nothing Then
_singleton = New CLogger
End If
Return _singleton
End Get
End Property

Public Sub Log()
Dim logEntry As New LogEntry()

logEntry.EventId = 100
logEntry.Priority = 2
logEntry.Message = “Informational message”
logEntry.Categories.Add(“UI Events”)

_logWriter.Write(“dfdfzf dfds fdf”)

End Sub
End Class

About Reader Man حسين ناجي الصفافير

حسين ناجي الصفافير Hussain Naji Al-Safafeer Info: https://readerman1.wordpress.com/aboutme
This entry was posted in Technical and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s