Can't write to Event Log

Topics: Logging Application Block
Nov 19, 2008 at 4:45 PM
Hi,

This is my first time using Enterprize Libraries and after reading all that it has to offer, I've set out to implement some of its features in our BizTalk Applications. Specifically the Application Logging Block. I am using version 4.1.

My problem is that I cant get anything to write to the Event Log.  I've created the config file which i then added to the BizTalk BTSNTSvc.exe.config. After fixing several permission problems my application runs and throws no errors which would indicate that the write to the Event Log is failing. 

The following is the line i sent to the logger write function : 

Logger

 

.Write(strMessage, "Hatch.BizTalk.Router", iPriority, iEventID, convertedEventType, "EXTRA STUFF");

Any help would be greatly appreciated.

Thank you
Greg

Nov 20, 2008 at 2:41 AM
Could you post your logging configuration section here?


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 20, 2008 at 12:46 PM
Edited Nov 20, 2008 at 2:50 PM
The following is the config file; 

 

<?xml version="1.0" ?>

<configuration>

      <configSections>

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

    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>

  </configSections>

  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"

    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

    <listeners>

      <add source="Enterprise Library Logging" formatter="Text Formatter"

        log="Application" machineName="IDCBTSDEV" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Formatted EventLog TraceListener" />

      <add source="Hatch.BizTalk.Router" formatter="Text Formatter"

        log="Application" machineName="IDCBTSDEV" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Hatch.BizTalk.Router.Replication.Listener" />

    </listeners>

    <formatters>

      <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=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

        name="Text Formatter" />

    </formatters>

    <categorySources>

      <add switchValue="All" name="General">

        <listeners>

          <add name="Formatted EventLog TraceListener" />

        </listeners>

      </add>

      <add switchValue="All" name="Hatch.BizTalk.Router">

        <listeners>

          <add name="Hatch.BizTalk.Router.Replication.Listener" />

        </listeners>

      </add>

    </categorySources>

    <specialSources>

      <allEvents switchValue="All" name="All Events" />

      <notProcessed switchValue="All" name="Unprocessed Category" />

      <errors switchValue="All" name="Logging Errors &amp; Warnings">

        <listeners>

          <add name="Formatted EventLog TraceListener" />

        </listeners>

      </errors>

    </specialSources>

  </loggingConfiguration>

    <runtime>

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

            <probing privatePath="BizTalk Assemblies;Developer Tools;Tracking;Tracking\interop" />

        </assemblyBinding>

    </runtime>

   

    <system.runtime.remoting>

   

        <channelSinkProviders>

            <serverProviders>

                <provider id="sspi" type="Microsoft.BizTalk.XLANGs.BTXEngine.SecurityServerChannelSinkProvider,Microsoft.XLANGs.BizTalk.Engine" securityPackage="ntlm" authenticationLevel="packetPrivacy" />

            </serverProviders>

        </channelSinkProviders>

   

        <application>

            <channels>

                <channel ref="tcp" port="0" name="">

                     <serverProviders>

                         <provider ref="sspi" />

                        <formatter ref="binary" typeFilterLevel="Full"/>

                    </serverProviders>

                </channel>

            </channels>

        </application>

    </system.runtime.remoting>

   

</configuration>

 

Nov 20, 2008 at 3:19 PM
I tried your configuration and it works if I set the MachineName to my machine name or to an empty string.  Did you specify the machine name correctly? The call to TraceListener's TraceData throws an exception when you specify an incorrect machine name.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Nov 20, 2008 at 3:36 PM
Thank you Sarah for checking it. In the Event Log the computer name is IDCBTSDEV but in System Properties the full computer name is different. I will try putting in the full computer name and see what happens.

Thank you again.
Greg
Nov 20, 2008 at 3:56 PM
I tried, I think it might work because at least now I get an error and it seems that its trying to write.  Now I get the following error

{"Request for the permission of type 'System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

As soon as I get this one figured out i will send an update.

Greg
Dec 5, 2008 at 7:27 PM
Hi,

I have fixed the problem. Unfortunetly I ended up reinstalling windows. It is writing to the event log.

Thanks Sarah for all your help.

Cheers,
Greg