Remote Service Trace Listener not receiving logging data

Topics: Logging Application Block
Jan 9, 2012 at 2:24 PM
Edited Jan 9, 2012 at 2:41 PM

Hi, I have been struggling with this for a while now and decided to ask for some help. I have been trying to get the Remote Service Trace Listener to work in my production application with very little success so then I decided to scale it down to the bare minimum and I'm still not having to much joy.

I have watched the videos on channel 9 about the logging block (, although very informative, it doesn't demo the Remote Service Trace Listener.
I found a post on the discussion forum about adding the Remote Service Trace Listener to that project (, in that post Gino Terrado explains  how he got it all to work... which is what I've tried to do and I'm still not getting and logging information.

I have followed all the steps from the Enterprise Library 5.0 Silverlight Integration Pack Guide with some minor changes to get to where I currently am.
This is what I've done and the the code in my project at present.

I created an new Silverlight project which has an ASP Website and a Silvelight project.

In the ASP Website I've created a SVC file called LogService.svc, all it has in the file is


<%@ ServiceHost Language="C#" Debug="true" Service="Microsoft.Practices.EnterpriseLibrary.Logging.Service.LoggingService" %>


In the ASP Website Config file I added the binding and endpoint configuration for the service.


		<binding name="Microsoft.Practices.EnterpriseLibrary.Logging.Service.customBinding0">
			<binaryMessageEncoding />
			<httpTransport />
	    <service name="Microsoft.Practices.EnterpriseLibrary.Logging.Service.LoggingService">
		<endpoint address="" binding="customBinding" 
bindingConfiguration="Microsoft.Practices.EnterpriseLibrary.Logging.Service.customBinding0" contract="Microsoft.Practices.EnterpriseLibrary.Logging.Service.ILoggingService" /> </service> </services> </system.serviceModel> </configuration>

The only notable difference to the documentation is that I had to specify the Binding to be a customBinding.
Next I added the loggingConfiguration to the ASP Website config file, I used the console config tool to do
this and added a Flat File listener for extra verification, I thought that if it didnt write to the Event Log
maybe it would write to a Flat File.

  <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />

 <loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
   <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    source="Enterprise Library Logging" formatter="Text Formatter"
    log="" machineName="." traceOutputOptions="None" />
   <add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    fileName="trace.log" formatter="Text Formatter" />
   <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
    name="Text Formatter" />
   <add switchValue="All" name="General">
     <add name="Event Log Listener" />
     <add name="Flat File Trace Listener" />
   <allEvents switchValue="All" name="All Events">
     <add name="Event Log Listener" />
     <add name="Flat File Trace Listener" />
   <notProcessed switchValue="All" name="Unprocessed Category" />
   <errors switchValue="All" name="Logging Errors &amp; Warnings">
     <add name="Event Log Listener" />
     <add name="Flat File Trace Listener" />


Alright, that should be all of it for the Website, now to move on to the Silverlight app.
So, first step was to add the ServiceReferences.ClientConfig file and its been build action
has been set to "Content"

                <binding name="CustomBinding_ILoggingService">
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
            <endpoint address="/LogService.svc"
					  binding="customBinding" bindingConfiguration="CustomBinding_ILoggingService"

I also tried setting the address="http://localhost:30978/LogService.svc" as suggested in the post I mentioned but it
didn't do anything either.

So then onto the last step, the config in the Silverlight app, I did this through the console config tool as well and the
following was produced.

<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary xmlns="" xmlns:x="" xmlns:el="">
  <el:LoggingSettings DefaultCategory="General" x:Key="loggingConfiguration">
            <el:RemoteServiceTraceListenerData LoggingServiceFactory="CustomBinding_ILoggingService" SubmitInterval="00:01:00" Name="Remote Service Trace Listener" SendImmediately="True" />
      <el:TraceSourceData Name="General">
          <el:TraceListenerReferenceData Name="Remote Service Trace Listener" />
          <el:TraceSourceData Name="All Events">
              <el:TraceListenerReferenceData Name="Remote Service Trace Listener" />
          <el:TraceSourceData Name="Unprocessed Category" />
          <el:TraceSourceData Name="Logging Errors &amp; Warnings">
              <el:TraceListenerReferenceData Name="Remote Service Trace Listener" />

This file is called configuration.xaml as per the convention and the build action has been set to Resource. I also
made sure that the category names are the same in the silverlight config file as in the website config file. Both are
set as "General"

In my App.xaml I instantiate the EnterpriseLibraryContainer by resolving the MainPage.

private void Application_Startup(object sender, StartupEventArgs e)
    //this.RootVisual = new MainPage();
    this.RootVisual = EnterpriseLibraryContainer.Current.GetInstance<MainPage>();

And that is pretty much the whole project... everything is by the book as far as I can see.

In my main page I resolve the LogWriter through Unity and I just have a button event which writes the log.

private void DoLog()
        "Message: " + this.Message.Text,
        string.IsNullOrEmpty(this.category.Text) ? new string[0] : new[] { this.category.Text },

I don't get any exceptions anywhere but I also don't get any logging action anywhere.
Any help would be greatly appreciated


Jan 9, 2012 at 7:43 PM

Thanks for posting all of your information.  It all looks good to me.

I'm wondering if this is a permission problem?  Is the Event Source for "Enterprise Library Logging" set up for the event log?  You can see if it is by opening up the EventVwr and selecting Windows Logs -> Application and then clicking on the Filter Current Log Action and see if Enterprise Library Logging is in the list of Event Sources.  Or ou can also check the registry if you prefer by verifying the following key exists:  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\Enterprise Library Logging

Another thing to try is to put the flat file listener before the event log listener and ensure that the location of trace.log is writable by the ASP.NET process identity.  (If there are any permission issues with the event log the flat file should still be logged if it is the first trace listener.)

Randy Levy
Enterprise Library support engineer 

Jan 10, 2012 at 3:15 PM

Hi Randy

I have checked my Event log and didn't find "Enterprise Library Logging" in the source drop down of the
filter, I also didn't find the registry key. Is there any reference material on how this is done?

Having said that, I have added a few more pieces to the project. I added a event listener to the configuration.xaml
file and then a added a event handler to the Dispather in my MainPage.xaml.cs, I just did that to see if the logging is
working on the client side, and it is.

I then tried your recommendation of placing the Flat File Trace listener before the Remote Trace Listener, I then created
a "Logs" folder and gave it Full/Write/Read/Modify permission to "Everyone". I still didn't get any logging action.

I figured that if I implement the ExtendedLoggingService as in the documentation, a breakpoint in there should be hit before
any logging gets done which would indicate whether the log is actually reaching the server/web site. So I added the
ExtendedloggingService class, changed the web.config and svc files to point to the ExtendedLoggingService but the breakpoint
never got hit.

I hope all this additional information helps, in the mean time I'll try and find out how to add the
"Enterprise Library Logging" to the event viewer.

Jan 11, 2012 at 1:38 AM

The easiest way to create the registry keys is to log something as administrator:

    EventLog.WriteEntry("Enterprise Library Logging", "Test");

That will set up all the required keys.

The flat file should be changed to be before the event log listener on the web.config -- not before remote service trace listener.

To check if the WCF service is being called you can enable tracing in the web.config:

      <source name="System.ServiceModel"
	switchValue="Information, ActivityTracing"
          <add name="traceListener"
		initializeData= "Traces.svclog" />

It could also be that you are making a cross domain call and are getting blocked.  See Making a Service Available Across Domain Boundaries to create a ClientAccessPolicy.xml file if that is the case.

Randy Levy
Enterprise Library support engineer 

Jan 12, 2012 at 4:14 PM

Hi Randy

I added the key to the registry as you advised, I had also moved the flat file above the event
listener, I just made a mistake while writing my previous reply.

I added the system diagnostic to my web.config and that proved to be the key to finding the solution. In the trace
file I got the following error.

<Message>Could not load file or assembly 'Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' ... </Message>
I looked through all the Prism, EntLib and EntLib Silverlight Integration Pack Bin and Lib folders looking for the
new version but didnt find it. I didn't realize that I needed to download Unity 2.1 as a separate download.

I found the new Unity 2.1 here (, once I added that to
the solution everything started working perfectly.

Thanks very much for your help, the tracing really sorted it out quick-sticks, if only I did that a week ago.

Jan 12, 2012 at 4:47 PM

Good to hear that you got it working. 

FYI: Microsoft Enterprise Library 5.0 Optional Update 1, which includes Unity 2.1, is listed as a requirement for Silverlight Integration Pack.

Randy Levy
Enterprise Library support engineer