Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

Configuring the Out of Process Console

jeff starkey edited this page Apr 2, 2017 · 10 revisions

Table of Contents


What does the Config look like?

The original/default configuration file contains a flat file sink. Here is the file with changes in. It is set to receive or "sink" log messages from the DemoConsole application included as the SemanticLogging project.

Multiple Sources and Multiple Sinks -- the "eventSource" element

Check out that two event sources are configured here and both log to this sink. Many event sources may be set up within one application and many sinks may capture content. Several sinks may monitor a source, several sources may log to a sink.

Event Levels -- the "levels" attribute

This demo set the "event levels" for the two event sources -- one to Informational, the other to Warning. This setting works in concert with the event source settings. The event source marks various messages with event levels (levels of severity). The event sink listens at a given event level. The monitoring may be turned up or down using the configuration, and does not require code change. This is built into SL and is very useful.

Log Message Separator -- the "header" attribute

This is a formatted string that will appear between log messages in order to make them more readable, which is useful when they are on a console screen or in a flat file, but not helpful for databases or similar sinks.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/practices/2013/entlib/semanticlogging/etw"
			   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			   xsi:schemaLocation="http://schemas.microsoft.com/practices/2013/entlib/semanticlogging/etw SemanticLogging-svc.xsd">
  
  <!-- Optional settings for fine tuning performance and Trace Event Session identification-->
  <traceEventService></traceEventService>
  <!-- Sinks reference definitons used by this host to listen ETW events -->
 <sinks>
	<!--[Add any built-in or custom sink definition here]-->
	  <consoleSink name="ConsoleEventSink">
	  <sources>
		<eventSource name="SemanticLogging-DemoConsole-EventSource" level="Informational"/>
		<eventSource name="SemanticLogging-SemanticLogging-EventSource" level="Warning"/>
	  </sources>
	  <eventTextFormatter header="+==============Demo of ETW Out-Of-Process Logging to Console==================+"/>
	</consoleSink>
  </sinks>

</configuration>

What does the default file look like?

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns="http://schemas.microsoft.com/practices/2013/entlib/semanticlogging/etw"
			   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			   xsi:schemaLocation="http://schemas.microsoft.com/practices/2013/entlib/semanticlogging/etw SemanticLogging-svc.xsd">
  
  <!-- Optional settings for fine tuning performance and Trace Event Session identification-->
  <traceEventService/>

  <sinks>
	<!-- The service identity should have security permissions to access the resource according to each event sink -->
	<flatFileSink name="svcRuntime" fileName="SemanticLogging-svc.runtime.log" >
	  <sources>
		<!-- The below settings shows a simple configuration sample for the buit-in non-transient fault tracing -->
		<!-- Remove this eventSource if you'd like, and add your own configuration according to the documentation -->
		<!-- The name attribute is from the EventSource.Name Property -->
		<eventSource name="Microsoft-EventSource" level="Warning"/>
	  </sources>
	  <!--[Add any built-in or custom formatter here if the sink supports text formatters]-->
	  <eventTextFormatter header="----------"/>
	</flatFileSink>
	
	<!--[Add any built-in or custom sink definition here]-->
  
  </sinks>

</configuration>

Where is the Console App?

Here is the folder where the SLAB utility (aka the OOP Console) was installed when I did this work.

<Drive>:\<location of repository>\SemanticLogging\packages\EnterpriseLibrary.SemanticLogging.Service.2.0.1406.1\tools

Or, in my case

D:\GitHub\SemanticLogging\packages\EnterpriseLibrary.SemanticLogging.Service.2.0.1406.1\tools

The directory looks like this

D:\GitHub\SemanticLogging\packages\EnterpriseLibrary.SemanticLogging.Service.2.0.1406.1\tools>dir
 Volume in drive D is DATA
 Volume Serial Number is 1655-1BB5

 Directory of D:\GitHub\SemanticLogging\packages\EnterpriseLibrary.SemanticLogging.Service.2.0.1406.1\tools

03/30/2017  05:07 PM    <DIR>          .
03/30/2017  05:07 PM    <DIR>          ..
03/30/2017  05:07 PM    <DIR>          .nuget
03/30/2017  05:07 PM               334 CreateSemanticLoggingDatabase.sql
03/30/2017  05:07 PM             2,872 CreateSemanticLoggingDatabaseObjects.sql
03/30/2017  05:07 PM               150 CreateSemanticLoggingDb.cmd
07/07/2014  05:25 PM            14,668 install-packages.ps1
03/30/2017  05:07 PM           659,120 Microsoft.Data.Edm.dll
03/30/2017  05:07 PM         1,518,256 Microsoft.Data.OData.dll
03/30/2017  05:07 PM           659,120 Microsoft.Data.Services.Client.dll
03/30/2017  05:07 PM         1,240,368 Microsoft.Diagnostics.Tracing.TraceEvent.dll
03/30/2017  05:07 PM            34,560 Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Database.dll
03/30/2017  05:07 PM           122,608 Microsoft.Practices.EnterpriseLibrary.SemanticLogging.dll
07/07/2014  05:25 PM            79,096 Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.dll
03/30/2017  05:07 PM            30,464 Microsoft.Practices.EnterpriseLibrary.SemanticLogging.TextFile.dll
03/30/2017  05:07 PM            37,640 Microsoft.Practices.EnterpriseLibrary.SemanticLogging.WindowsAzure.dll
03/30/2017  05:07 PM            36,528 Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.Data.dll
03/30/2017  05:07 PM            32,432 Microsoft.Practices.EnterpriseLibrary.TransientFaultHandling.dll
03/30/2017  05:07 PM            18,592 Microsoft.WindowsAzure.Configuration.dll
03/30/2017  05:07 PM           790,672 Microsoft.WindowsAzure.Storage.dll
03/30/2017  05:07 PM           456,192 Newtonsoft.Json.dll
07/07/2014  05:25 PM            45,224 SemanticLogging-svc.exe
07/07/2014  05:25 PM             1,241 SemanticLogging-svc.exe.config
03/30/2017  05:06 PM             1,564 SemanticLogging-svc.xml
07/07/2014  05:25 PM            12,590 SemanticLogging-svc.xsd
03/30/2017  05:07 PM           116,912 System.Spatial.dll
			  23 File(s)      5,911,203 bytes
			   3 Dir(s)  995,463,962,624 bytes free

Location is important!

I tried to copy this utility to a Utilities folder, to make it more generally available for other projects and I was unable to do so. You, optionally, may be much more clever and know how best to do this. My lack of persistence has paid off in the sense that I know right where to get at the utility for the given project!