Creating log entrys takes a lot of time in debug mode

Topics: Logging Application Block
Nov 22, 2010 at 1:36 PM
Edited Nov 23, 2010 at 8:11 AM

Hi, i migrated my first project from Enterprise Library 4.1 to 5.0 and have now problems when stepping through the project. Each log entry takes a long time (about 2 min). It does not matter whether i log into a database or a file. Does anyone know how to fix this problem?

Nov 23, 2010 at 1:28 AM
Edited Nov 23, 2010 at 9:13 AM

Are you talking about instantiating a LogEntry object or the code which actually writes the LogEntry?

The closest thing to this which have been posted here is the scenario where it is slow when first time retrieving an instance LogWriter

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 23, 2010 at 8:32 AM
Edited Nov 23, 2010 at 9:31 AM

Hi, thanks for the quick response.

I do not instantiating a LogEntry object, i use the static method Logger.Write like this: 

Logger.Write("Der Copyjob was cancelled by "+ currIdent.Name, "General", 99, 1234, TraceEventType.Information "de.abc.layer.presentation.cwarchiver|PCopyView|CopyFiles()|" + currIdent.Name);

 The problem occurs each time when i actually write the LogEntry and only in debugmode. For your information: I use Visual 2010, maybe there are some options i have to check?

Best regards Michael

 

Nov 23, 2010 at 9:12 AM

Did you check out the link I posted above?  Actually, I stated it incorrectly.  The problem mentioned actually is that there's a delay occurring when running an application that uses EntLib.  Try the suggestion posted there which is to include this in your config:

<runtime>
  <generatePublisherEvidence enabled="false"/>
</runtime>

I actually tried this and got 5-second difference when I added this in the config.

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 23, 2010 at 9:38 AM

Hi, i've checked the link above and included this in my config file without any effect on the behavior.

The mentioned target .NET framework is 3.5 but the UnitTest Project i use to start debugging, have to be .NET 4.0 prescribed by Visual 2010, maybe thats the Problem?

Nov 24, 2010 at 6:20 AM

You're right, it shouldn't be an issue in .NET 4.0 as mentioned in the thread in Chris Tavares's response.  I can't think of anything right now which might cause the problem.  Does this always happen when calling Logger.Write or only on the first call?  Could you debug through the entlib source code and see what exact line of code which is taking too much time to execute?  I can't repro it on my end using Visual Studio 2010 targeting .NET Framework 4.0.

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 30, 2010 at 10:45 AM

Hi, the line of code is:

Writer.Write(message, category, priority, eventId, severity, title);


at


public static void Write(object message, string category, int priority, int eventId, TraceEventType severity, string title) in Logger.cs

 

I use a flatfile when an error occurs and see sometimes problems with the SQLConnectionString:  



Process Name: C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\JetBrains.ReSharper.TaskRunner.CLR4.MSIL.exe
Thread Name:
Win32 ThreadId:6392
Extended Properties:
--> MachineName: XXXX

--> TimeStamp: 19.11.2010 10:32:48
--> FullName: Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
--> AppDomainName: IsolatedAppDomainHost: Test_Nunit
--> WindowsIdentity: XXX\xxxxxx

Exception Information Details:
======================================
Exception Type: System.ArgumentException
Message: Keyword not supported: 'XXXas906;initial catalog'.
ParamName: NULL
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Data.Common.NameValuePair ParseInternal(System.Collections.Hashtable, System.String, Boolean, System.Collections.Hashtable, Boolean)
HelpLink: NULL
Source: System.Data

This error occurs sometimes :(, the connSting i use looks like this: connectionString="Server=XXXAS906;Database=Logging;Trusted_Connection=True;"

 

Dec 1, 2010 at 1:51 AM

 Ah, so was the delay caused by the exception?  But I don't understand why would there be a problem in the connection string if you're using a flat file trace listener.   In addition, the exception message regarding the connection string doesn't match the connection string you're using.  Didn't you use a database trace listener somwhere in your config?

 

Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 24, 2011 at 3:16 PM

Hello Sarah,

Sorry, I could not answer earlier.

The problem persists, but i think now it's up to my visual installation because some other tools also do not work properly.

 

Thanks 4 support and best regards