Logging Application Block (EntLib 2.0) - Unable to Write to Event Log with ASP.Net RRS feed

  • Question

  • User1324923368 posted

    I've been trying to use the Logging Block that came with EntLib 2.0 to write to the event log but i've not been successful in ASP.Net. I followed the Hands On lab and got it working in WinForms.

    I have no issues logging to a flat file but for some reason, logging to Event Log is just not working. No errors or anything is appearing when I compile or during run time.

     My web.config is below. I have also added reference to Microsoft.Practices.EnterpriseLibrary.Logging.dll and followed the


    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
        <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null" />
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=null" />
      <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
        defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
          <add source="Oswin" formatter="Text Formatter" log="Application"
            machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null"
            traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null"
            name="Formatted EventLog TraceListener" />
          <add template="Timestamp: {timestamp}
    Message: {message}
    Category: {category}
    Priority: {priority}
    EventId: {eventid}
    Severity: {severity}
    Machine: {machine}
    Application Domain: {appDomain}
    Process Id: {processId}
    Process Name: {processName}
    Win32 Thread Id: {win32ThreadId}
    Thread Name: {threadName}
    Extended Properties: {dictionary({key} - {value}
            type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=, Culture=neutral, PublicKeyToken=null"
            name="Text Formatter" />
          <add switchValue="All" name="General">
              <add name="Formatted EventLog TraceListener" />
          <allEvents switchValue="All" name="All Events">
              <add name="Formatted EventLog TraceListener" />
          <notProcessed switchValue="All" name="Unprocessed Category">
              <add name="Formatted EventLog TraceListener" />
          <errors switchValue="All" name="Logging Errors & Warnings">
              <add name="Formatted EventLog TraceListener" />
        <roleManager enabled="true" />
        <authentication mode="Forms" />
        <compilation debug="true">
            <add assembly="System.Management, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Configuration.Install, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
            <add assembly="System.Data.OracleClient, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Messaging, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
    Thursday, February 22, 2007 3:50 AM

All replies

  • User-1527971941 posted

    Hi there,


    I have the same issue. I can write logs using flat file listener but not from Database trace listener. I have all the Stored procedures and tables which i can write to from Sql Server and they are working fine.

    Please help if someone knows what is wrong.



    Wednesday, April 4, 2007 2:47 PM
  • User810271707 posted

    What is the detailed error message you r gettin?

     It works perfectly fine when I configured.



    Wednesday, May 23, 2007 11:09 AM
  • User-1590055599 posted
    I'm using it with Asp.net, and if I change the source attribute from "Enterprise Library Logging" to anything else (in your case "Oswin"), it stops working.
    Try to use "Enterprise Library Logging" instead of "Oswin" to see if it works.

          <add source="Oswin" ..... 

    Maybe something different is happening to you. Anyway, I'd like to know why I can't change this property in my config file.



    Thursday, May 24, 2007 10:45 AM
  • User632768314 posted
    /* Deleted */
    Tuesday, June 12, 2007 9:33 AM
  • User-1167551343 posted

    Hi.  I am also having issues writing to the Event Log.  Although it works in my Windows XP box with VS2005, when I deploy to the DEV machine it does not.  The DEV box has Windows Server 2000 SP4.  I've added another loggingConfiguration listener that instead uses the FlatFileTraceListenerData instead of the FormattedEventLogTraceListenerData and it also works both on my local machine and on the DEV server.

    Just to ensure permissions are not an issue I've setup my website to use a local admin account for Anonymous Access under Authentication Methods.


    Any help would greatly be appreciated! 



    Tuesday, January 8, 2008 4:15 PM
  • User2012053744 posted

     Hi Sal,

    I do not know if this will be helpful but... This was necessary for p&p June/2005;

    Double click on "regedit.exe“ and locate \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog after that, use right click on "EventLog" and select "permissions“ then add "APS.NET" or “Security” account and grant it with "Full Control“.

    At that time, was necessary to give permission to ASP.NET or Security account to write events to Event Log.

    Monday, March 10, 2008 6:01 PM
  • User-1167551343 posted
    Thanks Roberto! We've upgraded our servers to 2003 so hopefully I will not have any issues. Thanks again, Sal
    Friday, March 28, 2008 10:57 AM
  • User1269507036 posted

    I've come across instance where a 2003 machine is acting strangely.  I have added a customsd for the IUSR_<%machinename%> user and this allows my classic asp pages to log to the application event log - however at some (seemingly random) point during the night, permission starts being denied.  Checked the customsd is still in there and it is.  A reboot sorts it out - but each night access starts being denied.  I've checked all the obvious stuff like the log not being set to overwrite etc, and group policy isn't kicking in overnight.

    I don't expect that anyone has, but anyone else experienced this? 


    Friday, July 18, 2008 5:38 AM