Entlib 5.0 not working on Windows Server Standard 2012

Topics: Exception Handling Application Block, Logging Application Block
Oct 16, 2013 at 9:50 AM
Edited Oct 16, 2013 at 9:50 AM
I have a Windows Server Standard 2012 (x64) on the client location. I have installed my .net solution 4.5 on the same server. I have thoroughly checked / re-checked all my configurations on the dev machine and Server machine, but there are no differences, as such.

My problem is that Exception logger is not logging any details in a plain text file, as it used to do normally in my dev machine.

Can you please help? It is a critical issue and I need to put in production on Thursday.

Below is my web.config file on the server.

Note: I have not installed Entlib5.0 on the server. Please let it me know, if it is mandatory and other configurations to be done on the server.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
  <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="NADSErrorTrace.log" formatter="Text Formatter" rollFileExistsBehavior="Increment" rollInterval="Midnight" rollSizeKB="1000" timeStampPattern="dd-MM-yyyy" traceOutputOptions="DateTime, Timestamp" />
</listeners>
<formatters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.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" />
</formatters>
<categorySources>
  <add switchValue="All" name="General">
    <listeners>
      <add name="Rolling Flat File Trace 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="Rolling Flat File Trace Listener" />
    </listeners>
  </errors>
</specialSources>
</loggingConfiguration>
<exceptionHandling>
<exceptionPolicies>
  <add name="NADS Policy">
    <exceptionTypes>
      <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow">
        <exceptionHandlers>
          <add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" priority="0" />
        </exceptionHandlers>
      </add>
    </exceptionTypes>
  </add>
</exceptionPolicies>
</exceptionHandling>
<dataConfiguration defaultDatabase="NADSConnect" />
<connectionStrings>
<add name="NADSConnect" connectionString="server=<sqlserver>;initial catalog=<dbname>;User ID=sa;Password=xxxxx" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ExcelDBConnection" value="Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=Excel 12.0;Data Source=" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
    <identity impersonate="false" />
</system.web>
<system.serviceModel>
<!-- Start: For Connecting to BL for NADS -->
<serviceHostingEnvironment>
  <serviceActivations>
    <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./AdminService.svc" service="SATRA.NADS.Service.AdminService" />

    <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./MapViewService.svc" service="SATRA.NADS.Service.MapViewService" />

    <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./MasterDataService.svc" service="SATRA.NADS.Service.MasterDataService" />

    <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./UserRegistrationService.svc" service="SATRA.NADS.Service.UserRegistrationService" />

    <add factory="System.ServiceModel.Activation.ServiceHostFactory" relativeAddress="./ReportService.svc" service="SATRA.NADS.Service.ReportService" />

  </serviceActivations>
</serviceHostingEnvironment>
<!-- End: For Connecting to BL for NADS -->
<behaviors>
  <serviceBehaviors>
    <behavior name="SATRA.NADS.Service.NADSServiceBehavior">
      <!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata
endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="True" />
      <!-- To receive exception details in faults for debugging
purposes, set the value below to true. Set to false before
deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<!-- <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> -->
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
<directoryBrowse enabled="false" />
</system.webServer>
</configuration>

Oct 16, 2013 at 12:19 PM
It looks like you are running a web application. The configuration is set to log to relative path file located under the web root. In most environments the account running the application will not have permissions to log to the web root. So either give the application account write permission (which is not recommended for security reasons) or change the configuration to set the log file to some other location where the application account does have permissions.

To help troubleshoot, set the errors specialSources to use a different trace listener (that writes to a location with proper permissions) than the rolling listener used for the rest of the application. This will let you see any errors resulting for the application's rolling listener.

Another way to troubleshoot is to use Process Monitor to look for permission issues while running the application.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to