logging creates log file - but nothing written

Topics: Logging Application Block
Apr 15, 2010 at 7:46 AM
Edited Apr 15, 2010 at 9:05 AM


I'm trying to use the the EntLib logging application block with a WCF service using EntLib 4.1.


The service is ultimately be to installed on a win 2008 server as a windows service.

I have tested the logging using the following scenarios:

  • As a console app on WinXp - works
  • As a WCF service hosted in ISS on WinXP - no file created.
  • As a WCF service hosted in Visual Studio web server - creates file, but nothing written.
  • As a Windows service in Win 2008 - file created, but nothing written.


It seems like a permission issue, but I'm unsure why in some cases the file is created but nothing is written.

Also, how can I give the 'Local System' account write permissions on the Win 2008 box?


Many thanks.




I noticed something interesting in the log that was being generated from the console:

I use: log.Message = "Time is: " + System.DateTime.Now; to write the time into the log.

And in the log I get the following:

All Events Information: 300 : Timestamp: 15/04/2010 9:02:24 a.m.
Message: Time is: 15/04/2010 11:02:24 a.m.

How can the two times be out by 2 hours?



Apr 15, 2010 at 9:05 AM


Please see this FAQ item if it would help http://entlib.codeplex.com/wikipage?title=Why%20are%20messages%20not%20logged%3f&referringTitle=EntLib%20FAQ.

Also, could you check if there is generated log by the Errors and Warnings Category and what exception does it throws?

Gino Terrado
Global Technology and Solutions
Avanade, Inc.

Apr 15, 2010 at 9:12 AM

Please note that timestamp value is defaulted to UTC. If you want to use your local timezone you can set in your TextFormatter this token {timestamp(local)}, which is also documented in FAQ item http://entlib.codeplex.com/wikipage?title=How%20can%20I%20change%20the%20timestamp%20format%20of%20my%20log%20entries%20to%20my%20local%20time%3f&referringTitle=EntLib%20FAQ

Gino Terrado
Global Technology and Solutions
Avanade, Inc.

Apr 15, 2010 at 9:23 AM

H Gino


Thanks for the reply. I have checked the link you provided, but I dont think it is any of those points as I am not using any filtering, and the same settings are working on a console app.


Here is my entlib logging settings:

<?xml version="1.0" encoding="utf-8" ?>
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
        defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
            <add fileName="C:\OpenGIS\SLD\SLDsvc\Tests\SLDsvc.Host\consoletrace.log"
                header="----------------------------------------" footer="----------------------------------------"
                formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="FlatFile TraceListener" />
            <add template="Timestamp: {timestamp}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity: {severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended Properties: {dictionary({key} - {value}&#xD;&#xA;)}"
                type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="Text Formatter" />
            <add switchValue="All" name="General">
                    <add name="FlatFile TraceListener" />
            <allEvents switchValue="All" name="All Events">
                    <add name="FlatFile TraceListener" />
            <notProcessed switchValue="All" name="Unprocessed Category" />
            <errors switchValue="All" name="Logging Errors &amp; Warnings" />

And here is the code that I am using to write to the l log:


var log = new LogEntry();
            ServiceController service = new ServiceController(serviceName);
                log.EventId = 300;
                log.Message = "Attempt to Restart Geoserver";

                log.Severity = TraceEventType.Information;
                log.Priority = 5;


etc etc...

Apr 15, 2010 at 10:24 AM

I've tried to reproduce your problem in a ConsoleApp and WCF Service hosted in VS Web Server and it's working from my end, though I'm using Win7.

I haven't tried it yet when hosted in IIS and in Win2008 but I'd like to try it out using your actual or sample app.

Can you send a copy of your sample app to us?

Gino Terrado
Global Technology and Solutions
Avanade, Inc.

Apr 15, 2010 at 11:17 AM

Hi Gino


Thanks again for your help, and you offer to look at my code. Due to  sensitive nature of some of the code I cannot send it. However, I have done some further testing.

I made a simple WCF web application and added the Entlib logging - and it worked.


The project I am working on uses the Service Factory. I made another simple project using the Service factory, added the EntLib logging to the Service Implementation, and added logging code to the method.

I then added the config settings to the hosting app (Visual Studio web server) - and again, the file was empty.


I can send you the test solution (which uses the service factory - but you will probably need to have the service factory installed).

Apr 15, 2010 at 12:13 PM

I'll let you if we find anything suspicious. You cand send it here entlib.support@avanade.com