Rolling Flat File Trace Listener not written in Production

Topics: Logging Application Block
Oct 8, 2008 at 2:32 PM
Edited Oct 8, 2008 at 2:33 PM
Hello,
we are currently facing an issue with the logging block not writting in Production.

The current configuration I have is:

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">

<listeners>

 <add fileName="rolling.log" footer="----------------------------------------" formatter="Text Formatter" header="----------------------------------------" rollFileExistsBehavior="Overwrite" rollInterval="Day" rollSizeKB="10000" timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Rolling Flat File Trace Listener"/>

 </listeners>

<formatters>

 <add template="Timestamp: {timestamp} Message: {message} Category: {category} Priority: {priority} EventId: {eventid} Severity: {severity} Title:{title} 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=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 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 & Warnings">

<listeners>

 <add name="Rolling Flat File Trace Listener"/>

 </listeners>

 </errors>

 </specialSources>

 </loggingConfiguration>


The logging happens normally on my development machine but not on the production server.

While reading some discussions about the exact same problem, I used Process Monitor in order to sniff the files accesses happening on the machine.... Nothing related to the rolling.log file... Not even a single error.

I tried to give 'NETWORK SERVICE' (the user running the w3wp.exe process) modify access to the file. It didn't solve my problem. I even tried with 'EVERYONE' full control on the log file... nothing...

May it be related to my configuration?

Thanks in advance,

Emmanuel
Oct 9, 2008 at 2:56 PM
Edited Oct 10, 2008 at 9:57 AM
Well I was facing the same issues with the logging block, the problem is it gives no clue what is causing this behaviour. 
For my situation it was happening on my development machine, this is a WIN 2008 Server running Sharepoint 2007. On this machine I created a WCF service which logs exceptions using the logging application block. But alas nothing was logged . I too gave the 'NETWORK SERVICE' account full access.

Here are some things you can try (although my situation is different from yours I guess):

1 Put the web application in another (newly created) Application Pool (for my situation everything resided in the Sharepoint application pool).

2 Install the Enterprise Library dll's into the GAC (using gacutil). Here are the steps:

2.1 Open notepad

2.2 Copy the following list into the 'pad'

Microsoft.Practices.EnterpriseLibrary.AppSettings.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Caching.Cryptography.dll
Microsoft.Practices.EnterpriseLibrary.Caching.Database.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Caching.Database.dll
Microsoft.Practices.EnterpriseLibrary.Caching.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.Design.HostAdapter.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.Design.UI.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.EnvironmentalOverrides.dll
Microsoft.Practices.EnterpriseLibrary.Data.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.Data.SqlCe.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.dll
Microsoft.Practices.EnterpriseLibrary.PolicyInjection.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.PolicyInjection.dll
Microsoft.Practices.EnterpriseLibrary.Security.AzMan.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Security.AzMan.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cache.CachingStore.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cache.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Security.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll
Microsoft.Practices.EnterpriseLibrary.Security.dll
Microsoft.Practices.EnterpriseLibrary.Validation.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Validation.dll
Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet.dll
Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WCF.dll
Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms.dll
Microsoft.Practices.ObjectBuilder2.dll
Microsoft.Practices.Unity.Configuration.dll
Microsoft.Practices.Unity.dll
Microsoft.Practices.Unity.StaticFactory.dll

2.3 Save file to 'C:\Program Files\Microsoft Enterprise Library 4.0 - May 2008\Bin' and name it 'DeployToGAC.txt' for example.

2.4 Open command box and navigate to folder above.

2.5 run 'gacutil /il 'DeployToGAC.txt'

NOTE:
Do not delete the dll's of the original folder because they are needed when you want to add a reference (with Copy Local set to 'False') in your project to one of the dlls's (add reference does unfortunately not work 'custom added' GAC assemblies). You don't have to worry about conflicts because GAC assemblies have a higher priority.

3. Investigate your security settings (for example are your Enterprise Library assemblies strongly signed). I found a 'temporary' solution on my Sharepoint machine by setting my trust level to 'Full' (not very smart). I came to this idea because at first I could not get the debugger working inside my WCF service. But after restart of my PC, it worked at gave the following error at statement 'Logger.Write(...):

---------
Exception:
The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception

Stacktrace:
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(LogEntry log)\r\n   at WUR.ICT.PathogenCombat.Services.SiteWcfService.SynchronizeSharePointWithModel(SiteAction siteAction)\r\n   at SyncInvokeSynchronizeSharePointWithModel(Object , Object[] , Object[] )\r\n   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)\r\n   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)"

Type:
 "Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource"

------

Fact remains why nothing is written is sometimes very hard to find, we need a logger instrument on the logging block itself ;-)

Hope my info can help you a little bit


Your sincerely,

Evert Wiesenekker

 
Oct 10, 2008 at 11:35 AM
For development machines running custom websites/WCF services running beside SharePoint (and trust level 'WSS_Minimal') and using the Logging Application Block with the dll's installed into the GAC can get the following subsequent errors after doing a first 'Logger.Write':

Error:
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Solution:
Open 'wss_minimaltrust.config' (directory: 'C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\CONFIG') and look for 'IPermission' tags. Add the following new IPermission class:

<IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="True" />

Save and do a iisreset!

Error:
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter, null]) failed: Request for ConfigurationPermission failed while attempting to access configuration section 'loggingConfiguration'. To allow all callers to access the data for this section, set section attribute 'requirePermission' equal 'false' in the configuration file where this section is declared. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2)

Solution:
Open the web.config of your custom website/WCF service and look for section 'loggingConfiguration'. Add 'requirePermission="false" '.


This was created with the help of the info inside the following links:

http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2007/09/05/how-to-get-enterprise-library-working-with-sharepoint.aspx
http://www.devx.com/dotnet/Article/32951/1954