Quantcast
Channel: patterns & practices – Enterprise Library
Viewing all 1928 articles
Browse latest View live

Commented Unassigned: Semantic Logging Issue "string length greater than 32723" in Out of Process [33838]

$
0
0
Dear Randy,

I have created a discussion http://entlib.codeplex.com/discussions/574964.

To know what is causing issue while I logging string length more than 32723 in Out of Process.

Because I have created a class and the method for writing logs in to blob and it was working fine in “In-Process” type of logging with large length of allowable string data type.

But the same source code is converted as dll and placed in out-of-process semantic logging folder called via xml file through custom sink tag but unfortunately it was not logging large size string (>32723) and also it was not throwing (log) any error.

Initially it was throwing proxy error and I have fixed proxy error by put some code and now it is running fine.

Be simple, Out-of-Process is not logging payload string which is having length more than 32723.

I’m using Event level as Log always.

Also I’m using semantic logging custom sink unhandled fault method to write logs when exception happen in a method. Error logging is not happen. 

SemanticLoggingEventSource.Log.CustomSinkUnhandledFault()

If I’m using above code , definitely this should get some error log when method is throwing error. Am I right?

Moreover , How to disable events and close the listener in custom sink out of process. Please guide me.

Share me the event life cycle of the Semantic Logging custom sink.

1. OnCompleted – Not implemented
2. OnError – Here I’m calling custom sink unhandled fault()
3. OnNext – Here I’m calling my own method for writing logs to blob

Kindly expedite and I Need your help.
Comments: What you are seeing is a limitation in the size of an ETW event. ETW is what is used to communicate between the event producing process (event provider) and the OOP service (event consumer). From [About Event Tracing](http://msdn.microsoft.com/en-us/library/windows/desktop/aa363668%28v=vs.85%29.aspx): # > Events can be lost for a number of reasons: The total event size is greater than 64K. This includes the ETW header plus the data or payload. A user has no control over these missing events since the event size is configured by the application. # You are hitting the 64K limit but the string length does not necessarily have to be 32723 -- it depends on the total size of the event (e.g. in my testing I hit a slightly different number). The reason why a single string of about ~32000 characters is hitting the 64K limit is that 2 bytes is allocated per character. What happens is that the in-process ETW buffer is too small to accept the incoming data so the status ERROR_MORE_DATA is returned and the message is never published. You can see that the message is not published by enabling exceptions on the EventSource (pass true to the EventSource base constructor) to see that an exception is being raised: ``` c# public sealed class MyMessagingEventSource : EventSource { public static MyMessagingEventSource Log = new MyMessagingEventSource(); private MyMessagingEventSource() : base(true) { } } ``` Finally, the occurrence of an error is delivered out of band to the the OOP service and will be written if the "Microsoft-SemanticLogging" EventSource is configured to log. The output would look something like the following: ``` ProviderId : d1ed7ec7-5701-5554-2c5e-796dc42511c5 EventId : 811 Keywords : 4 Level : LogAlways Message : Out of band event level 0 for provider 00000000-0000-0000-0000-000000000000 on session Microsoft-SemanticLogging-Etw-ConsoleEventSink. Message: Opcode : Info Task : 64723 Version : 0 Payload : [sessionName : Microsoft-SemanticLogging-Etw-ConsoleEventSink] [providerId : 00000000-0000-0000-0000-000000000000] [eventLevel : 0] [eventKeywords : 0 ] [eventMessage : ] EventName : TraceEventServiceOutOfBandEventInfo Timestamp : 2014-12-17T18:35:27.2873067Z ProcessId : 10884 ThreadId : 11240 ``` Unfortunately, there is not much useful information in that message. Also, since the limitation is baked into ETW there is not much that can be done short of splitting/truncating long strings or perhaps implementing a retry to try to split/truncate long strings and log multiple smaller messages (assuming that fits with the application requirements). ~~ Randy Levy [entlib.support@live.com](mailto:entlib.support@live.com) Enterprise Library support engineer [Support How-to](http://entlib.codeplex.com/wikipage?title=Support%20How-to)

Created Unassigned: Cryptography [33839]

$
0
0
Hi,
we have a dll “Microsoft.Practices.EnterpriseLibrary.Security” in Enterprise Library 5
but I didn’t find the dll for cryptography in Enterprise Library 6. Please suggest, how can we achieve that.
Thanks in Advance,
Hemanth.

New Post: SLAB confusing tasks and events

$
0
0
I have to agree that this is unfortunately. We were really hoping the Task and Opcode could be used as further discriminators of events, in addition to the EventName. Combining them in this way is limiting.

New Post: How to use accessors when stored procedure return multiple resultsets

$
0
0
Hi,

Could someone please provide a sample on how to map multiple resultsets returned from a stored procedure using Enterprise Library accessors. We also need to create a parent-child relation between these entities.

The documentation says it is possible by implementing the interface IResultSetMapper but there are no sample examples of how to do it.

Thanks

New Post: SqlDatabaseTransientErrorDetectionStrategy and timeouts

$
0
0
The class SqlDatabaseTransientErrorDetectionStrategy specifically defines exceptions of type TimeoutException as transient but does not consider SqlException with number -2 to be transient. The -2 also indicates a timeout.

Could somebody provide some background on this; Is there a reason why I should not automatically retry when I get -2 error?

Link to the source code:
https://topaz.codeplex.com/SourceControl/latest#source/Source/TransientFaultHandling.Data/SqlDatabaseTransientErrorDetectionStrategy.cs

Commented Unassigned: Cryptography [33839]

$
0
0
Hi,
we have a dll “Microsoft.Practices.EnterpriseLibrary.Security” in Enterprise Library 5
but I didn’t find the dll for cryptography in Enterprise Library 6. Please suggest, how can we achieve that.
Thanks in Advance,
Hemanth.
Comments: The Security Application Block has been deprecated and removed from Enterprise Library 6. See [Enterprise Library 6 Release Notes](http://entlib.codeplex.com/wikipage?title=EntLib6ReleaseNotes). The options you have are: * Use built-in .NET cryptographic functionality (I think the preferred approach) * Use (or keep using) Enterprise Library 5 (which uses the block) * Create a custom EntLib 6 release which includes a ported Security Application Block.

New Post: How to use accessors when stored procedure return multiple resultsets

$
0
0
The IResultMapper interface looks like:
publicinterface IResultSetMapper<TResult>
{
  IEnumerable<TResult> MapSet(IDataReader reader);
}
Basically you need to create a class that implements the interface and internally process an IDataReader to return an IEnumerable of whatever type you are creating.

For example:
publicclass ProductResultMapper : IResultSetMapper<Product>
{
        public IEnumerable<Product> MapSet(IDataReader reader)
        {
            List<Product> products = new List<Product>();

            while (reader.Read())
            {
                Product prod = new Product();
                prod.ID = int.Parse(reader["ProdID"].ToString());
                prod.ProdName = reader["ProdName"].ToString();
                prod.Price = double.Parse(reader["Price"].ToString());

                products.Products.Add(prod);
            }

            return products;
        }
}
One use case that is fairly typical is to create an object with a parent/child relationship. That could look something like this (assuming that multiple results are returned):
publicclass OrderResultMapper : IResultSetMapper<Order>
{
    public IEnumerable<Order> MapSet(IDataReader reader)
    {
        List<Order> orders = new List<Order>();
        Order order = null;

        while (reader.Read())
        {
            order = new Order();
            order.Id = reader.GetInt32(0);
            // etc.
            orders.Add(order);
        }

        reader.NextResult();

        while (reader.Read())
        {
            int orderId = reader.GetInt32(0);
                
            order = orders.Single(o => o.Id == orderId);

            OrderItem item = new OrderItem();
            item.Id = reader.GetInt32(1);
            // etc.
            order.Items.Add(item);
        }

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

New Post: How to display Reference ID or HandlingInstanceId in page?

$
0
0
If you are using a ReplaceHandler, you can actually put the handlingInstanceID in your custom error message:
<exceptionHandling>
  <exceptionPolicies>
    <add name="ReplacingException">
      <exceptionTypes>
        <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          postHandlingAction="ThrowNewException">
          <exceptionHandlers>
            <add name="Replace Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ReplaceHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
              exceptionMessage="An application error occurred and has been logged with error code: {handlingInstanceID}"
              exceptionMessageResourceName="" exceptionMessageResourceType=""
              replaceExceptionType="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </exceptionHandlers>
        </add>
      </exceptionTypes>
    </add>
  </exceptionPolicies>
</exceptionHandling>

New Post: Entlib 3.1 set sp_approle within transactionscope

$
0
0
Hi,
I have same problem. Please explain what you did to resolve this issue.
  1. As for I know if you call sp_setapprole on connection object. you should call the other command on the same connection object. scope for set_approle is same connection.

New Post: Is DateTime allowed as a parameter?

$
0
0
For the benefit of anyone getting here from a web search, there are now additional valid types:

The .NET version currently supports the following types (taken from ManifestBuilder.GetTypeName):
Enum, Boolean, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double, DateTime, String, Guid
(Note that while DateTime is supported, EventSourceAnalyzerwill report an error)

The NuGet distribution adds support for the following types:
Char, IntPtr, Byte*, Byte[]

For more information see http://ohadsc.wordpress.com/2014/10/13/getting-started-with-etw-using-nets-eventsource/

New Post: Performance - System Diagnostics vs Enterprise Logging Block

$
0
0
I recently had a project to move tracing for an application from System Diagnostics (.Net 4.5) tracing to Enterprise Library Logging (v6)

Trace - http://msdn.microsoft.com/en-us/library/system.diagnostics.trace%28v=vs.110%29.aspx
Enterprise Library v6 - http://msdn.microsoft.com/en-us/library/dn169621.aspx

However when I bench marked the time taken to write 100, 000 messages I was quite surprised by the result

System Diagnostics ~2s
Enterprise Library ~12s

When I moved the Enterprise Library to async (see http://msdn.microsoft.com/en-us/library/dn440731%28v=pandp.60%29.aspx#sec23), the performance was even worse at around 3 minutes.

I have sample code that can be made available

Any suggestions on how or if I can improve the performance of the Enterprise Library?

Many thanks - Vince

New Post: Enterprise Library Windows 2012 Support

$
0
0
Hello All,
Is Enterprise Library 5.0 supported in Windows 2012 and Windows 2012 R2?

Created Unassigned: Semantic Logging Out Of Process issue - write logs several time [33840]

$
0
0
Dear Randy,

I have created custom sink for writing logs in to azure blob via semantic logging out of process method. Here problem that I’m facing was, It is writing entries to log file several time in ascending order.

Scenario:

When I log first time it writes a single entry
When I log second time it writes double entry
When I log 3rd time it writes three entry

..
When I log nth time it writes n entry in log file.


Kindly guide me where I have to look for fixing the issue. Attached my custom sink code and here onnext() method is executed several times. Please review and reply.

Thanks in advance.

New Post: Performance - System Diagnostics vs Enterprise Logging Block

$
0
0
An update
I write a simple log formatter and found that the speed of Enterprise Library increased to take ~4s instead of 12s
So beware of what formatter you use for the Enterpise Library

New Post: Multiple versions Ent.Lib and configuration files

$
0
0
I try simplify my issue.

I use Console Application .NET 4.0.

Console Application .NET 4.0 has an App.config file.

I have DLL Project .NET 2.0, that uses (Dependency Reference) Enterprise Library 3.1.

I have another DLL Project .NET 4.0, that uses (Dependency Reference) Enterprise Library 5.0.


Console Application .NET 4.0 uses (Dependency Reference) DLL Project .NET 2.0 and DLL Project .NET 4.0,


Problem here: Enterprise Library configuration conflict 5.0 and 3.1 versión in Console Application .NET 4.0 App.config file.

Any suggestions using both Enterprise Library 5.0 and 3.1 ?
Is it possible ?
Good patterns and practices?

New Post: Semantic Logging - RollingFlatFileSink - Real-Time Logging

$
0
0
We're currently using semantic logging and are able to both save to rolling flat files and a sql database. A difference we're seeing is that the sql sink inserts every x seconds while the rolling flat file sink doesn't insert data until the file rolls over or the service stops.

Is there a way to have inserts happen in real-time for the rollingFlatFileSink?

Created Unassigned: Activation error occurred while trying to get instance of type ICacheManager [33841]

$
0
0
I have the issue shows below in the title,

my app.config is attached,

Commented Unassigned: Activation error occurred while trying to get instance of type ICacheManager [33841]

$
0
0
I have the issue shows below in the title,

my app.config is attached,
Comments: When i tried to get the instance of the cache : ICacheManager cache = CacheFactory.GetCacheManager("wsdataCache"); Exception is thrown. Somebdy pls help with that, i'am stuck. Best regards.

Commented Unassigned: Activation error occurred while trying to get instance of type ICacheManager [33841]

$
0
0
I have the issue shows below in the title,

my app.config is attached,
Comments: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" /> </configSections> <cachingConfiguration defaultCacheManager="wsdataCache"> <cacheManagers> <add name="wsdataCache" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching" expirationPollFrequencyInSeconds="1000000000" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="NullBackingStore" /> </cacheManagers> <backingStores> <add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching" name="NullBackingStore" /> </backingStores> </cachingConfiguration> <system.serviceModel> <bindings> <customBinding> <binding name="ClientsResponsableSecteurServiceSoapBinding"> <textMessageEncoding messageVersion="Soap12" /> <httpTransport /> </binding> </customBinding> </bindings> <client> <endpoint address="http://192.168.1.96:8080/services/ClientsResponsableSecteurService" binding="customBinding" bindingConfiguration="ClientsResponsableSecteurServiceSoapBinding" contract="ClientsResponsableService.IClientsResponsableSecteur" name="ClientsResponsableSecteurService" /> </client> </system.serviceModel> </configuration>

New Post: Dynamically Change Log File Name in each run

$
0
0
Hi,

After spending a lot of time searching for a suitable code to change the log file name in each run of the code, I found one given by Randy Levy but that uses Enterprise Library 5 and our project is built on version 6.

so the following code is not working any more and frankly speaking I am not very good at coding and getting a hard time to use all the options provided in useful websites.

Can someone please help me rewrite the following section using Enterprise Library 6 or point me towards a way to get help on this particular scenario?

Thanks in advance.
 static void InitializeContainer(SerializableConfigurationSource loggingXmlConfigSource)
        {
            // Create the container
            IUnityContainer container = new UnityContainer();
            container.AddNewExtension<>();// <EnterpriseLibraryCoreExtension>();

            // Configurator will read Enterprise Library configuration 
            // and set up the container
            UnityContainerConfigurator configurator = new UnityContainerConfigurator(container);

            // Configure the container with our own custom logging
            EnterpriseLibraryContainer.ConfigureContainer(configurator, loggingXmlConfigSource);

            // Wrap in ServiceLocator
            IServiceLocator locator = new UnityServiceLocator(container);

            // And set Enterprise Library to use it
            EnterpriseLibraryContainer.Current = locator;
        }
Viewing all 1928 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>