Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Question: Application Insights - Write to "exceptions" and not "traces" #102

Closed
hiraldesai opened this issue Jul 13, 2017 · 3 comments
Closed
Labels

Comments

@hiraldesai
Copy link

What do I need to do to write the unhandled exceptions to "exceptions" tab in Application Insights instead of the usual "Traces" tab?

This is what my setup is:

            var config = new LoggingConfiguration();
            var target = new ApplicationInsightsTarget
            {
                InstrumentationKey = _instrumentationKey
            };

            var rule = new LoggingRule("*", LogLevel.Trace, target);
            config.LoggingRules.Add(rule);

            LogManager.Configuration = config;

And this is how I'm logging:

private readonly ILogger<ClassName> _logger;
public ClassName(ILoggerFactory loggerFactory) 
{
_logger = loggerFactory.CreateLogger<CustomErrorHandlingMiddleware>();
}
...
...
_logger.LogError(0, exception, exception.Message);
...

Everything is ending up under "traces" tab, nothing under "exceptions" tab.

image

@SergeyKanzhelev
Copy link
Contributor

I get you are using NLog target? It suppose to track exception as long as LogEventInfo item has it not empty. See here.

Do you know if ILogger -> NLog initializes this field properly? I do not have experience with this combination of loggers.

@hiraldesai
Copy link
Author

Thank you for the reference @SergeyKanzhelev. Yes, I'm using NLog target, I will look into more details to figure out if it's populating it correctly.

@SergeyKanzhelev
Copy link
Contributor

@hiraldesai I'll close the issue for now. Please re-open if you discovered there is an issue that needs to be addressed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants