Application Insights Backend: System.OverflowException: 'Arithmetic operation resulted in an overflow.'

Esben Bach's Avatar

Esben Bach

06 Dec, 2017 11:40 AM

I have a library that I have instrumented using the postsharp provided "Log" attribute.
Now in one of my applications consuming said library i am logging to an insightsbackend.

One of my methods in that library serializes an object to a json string. Causing the insightsbackend to throw an overflowexception whenever the string goes beyond a specific length (havent tried to figure out said length). What are my options here?
Removing the log from the specific attribute or am I able to do some configuration to ignore the overflow?

  1. Support Staff 1 Posted by PostSharp Techn... on 06 Dec, 2017 05:32 PM

    PostSharp Technologies's Avatar


    The issue with the OverflowException in the logging library is related to a known bug (#15686). We will get back to you once the bug fix is released.

    The logging configuration API allows you to set a custom buffer size, the default size is 2048. For example:

    var backend = new PostSharp.Patterns.Diagnostics.Backends.ApplicationInsights.ApplicationInsightsLoggingBackend();
    backend.Options.ActionMaxLength = 65536;
    backend.Options.ContextMaxLength = 65536;

    Documentation articles:

    Please note, that the configuration changes might not work for ApplicationInsightsLoggingBackend until the bug #15686 is fixed.

    In the meantime you can temporarily exclude the affected method from logging by applying the [Log] attribute with AttributeExclude = true:


  2. 2 Posted by Esben Bach on 07 Dec, 2017 07:56 AM

    Esben Bach's Avatar

    Im aware of the AttributeExclude property, problem is that I actually needed the output :p

    I will attempt to increase the buffer size and see what happens.

  3. 3 Posted by Esben Bach on 07 Dec, 2017 08:38 AM

    Esben Bach's Avatar

    Apparently, setting the buffer size is either irrelevant for the given error, or is not taking into consideration. So back to disabling the logging or using another backend.

  4. Support Staff 4 Posted by PostSharp Techn... on 10 Dec, 2017 09:16 PM

    PostSharp Technologies's Avatar


    the bug #15686 has been fixed in the current release of PostSharp 5.0.41.
    Should you need further help with this issue, don't hesitate to re-open this discussion.


  5. PostSharp Technologies closed this discussion on 10 Dec, 2017 09:16 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac