C# PowerShell Batchfile
Latest commit 494a0f1 Jun 28, 2018
Permalink
Failed to load latest commit information.
HelloWorldTest Merge branch 'develop' into tilee/update_dependencies Jun 28, 2018
SDL sdl script revision (#142) Jan 12, 2018
src NLog ApplicationInsightsTarget - Add support for using GDC for Instru… Jun 28, 2018
test Merge branch 'develop' into tilee/update_dependencies Jun 28, 2018
.gitattributes fix stylecop (#117) Sep 2, 2017
.gitignore Initial commit Nov 13, 2015
35MSSharedLib1024.snk Initial commit Nov 13, 2015
AddXmlLanguage.targets Added injection of language into XML documentation files. Sep 8, 2016
ApplicationInsightsSDKRules.ruleset Switched from stelycop msbuild to stelycop analyzer (#125) Nov 10, 2017
CHANGELOG.md NLog ApplicationInsightsTarget - Add support for using GDC for Instru… Jun 28, 2018
CodeCov.ps1 revert bad edit of codecov.ps1 (#136) Feb 7, 2018
Common.props Switched from stelycop msbuild to stelycop analyzer (#125) Nov 10, 2017
Common.targets Added injection of language into XML documentation files. Sep 8, 2016
Directory.Build.props 4 of many... convert two more projects to generate it's own package (#… Nov 21, 2017
EnlistmentRoot.marker Initial commit Nov 13, 2015
GenerateReleaseMetadata.ps1 new script: GenerateReleaseMetadata (#170) Apr 11, 2018
GlobalStaticVersion.props bump version 2.6.4 May 23, 2018
LICENSE License and Documentation Nov 13, 2015
Logging.sln NLog + log4net added NetStandard support (Unit test projects) Apr 2, 2018
Microsoft-Security-Recommended.ruleset Added rules and enabled code analysis on build. Aug 12, 2016
NuGet.Config DiagnosticSourceListener generates it's own nuget package (#131) Nov 17, 2017
NuGet.exe Update nuget.exe to 4.1 to meet compliance May 1, 2017
PushNugetPackages.cmd Initial commit Nov 13, 2015
README.md Update Readme with short intro about each adapter (#165) Mar 14, 2018
Signing.targets Initial commit Nov 13, 2015
Test.props Switched from stelycop msbuild to stelycop analyzer (#125) Nov 10, 2017
ThirdPartyNotices.txt Adding third party notices Sep 7, 2016
VSOPushNugetPackages.cmd Update nuget package path Jan 22, 2016
buildDebug.cmd Migrate EventSourceListener project to netstandard1.3 Mar 30, 2017
buildRelease.cmd Migrate EventSourceListener project to netstandard1.3 Mar 30, 2017
clean.cmd Tilee/fix unittests2 (#146) Feb 9, 2018
dirs.proj Migrate EventSourceListener project to netstandard1.3 Mar 30, 2017
disablestrongnamevalidation.ps1 Added ps scripts to enable disable strong name verification. This is … Aug 10, 2017
enablestrongnamevalidation.ps1 Added ps scripts to enable disable strong name verification. This is … Aug 10, 2017

README.md

Build codecov.io

Nuget packages

Application Insights logging adapters.

If you use NLog, log4Net or System.Diagnostics.Trace for diagnostic tracing in your application, you can have your logs sent to Application Insights, where you can explore and search them. Your logs will be merged with the other telemetry coming from your application, so that you can identify the traces associated with servicing each user request, and correlate them with other events and exception reports.

Read more:

NLog

Application Insights NLog Target nuget package adds ApplicationInsights target in your web.config (If you use application type that does not have web.config you can install the package but you need to configure ApplicationInsights programmatically; see below).

For more information, see NLog Documentation

  • If you configure NLog though web config then you just need do the following:
// You need this only if you did not define InstrumentationKey in ApplicationInsights.config
TelemetryConfiguration.Active.InstrumentationKey = "Your_Resource_Key";

Logger logger = LogManager.GetLogger("Example");

logger.Trace("trace log message");
  • If you configure NLog programmatically than create Application Insights target in code and add it to your other targets:
var config = new LoggingConfiguration();

ApplicationInsightsTarget target = new ApplicationInsightsTarget();
// You need this only if you did not define InstrumentationKey in ApplicationInsights.config or want to use different instrumentation key
target.InstrumentationKey = "Your_Resource_Key";

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

LogManager.Configuration = config;

Logger logger = LogManager.GetLogger("Example");

logger.Trace("trace log message");

Log4Net

Application Insights Log4Net adapter nuget modifies web.config and adds Application Insights Appender.

For more information, see Log4Net Configuration

// You do not need this if you have instrumentation key in the ApplicationInsights.config
TelemetryConfiguration.Active.InstrumentationKey = "Your_Resource_Key";

log4net.Config.XmlConfigurator.Configure();
var logger = LogManager.GetLogger(this.GetType());

logger.Info("Message");
logger.Warn("A warning message");
logger.Error("An error message");

System.Diagnostics

Microsoft.ApplicationInsights.TraceListener nuget package modifies web.config and adds application insights listener.

For more information, see "Microsoft Docs: "Tracing and Instrumenting Applications"

<configuration>
  <system.diagnostics>
    <trace>
      <listeners>
        <add name="myAppInsightsListener" type="Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener, Microsoft.ApplicationInsights.TraceListener" />
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>

If your application type does not have web.config, add listener programmatically or in the configuration file appropriate to your application type

// You do not need this if you have instrumentation key in the ApplicationInsights.config
TelemetryConfiguration.Active.InstrumentationKey = "Your_Resource_Key";
System.Diagnostics.Trace.TraceWarning("Slow response - database01");

EventSource

EventSourceTelemetryModule allows you to configure EventSource events to be sent to Application Insights as traces.

For more information, see Microsoft Docs: "Using EventSource Events".

ETW

EtwCollectorTelemetryModule allows you to configure events from ETW providers to be sent to Application Insights as traces.

For more information, see Microsoft Docs: "Using ETW Events".

DiagnosticSource

You can configure System.Diagnostics.DiagnosticSource events to be sent to Application Insights as traces.

For more information, see CoreFX: "Diagnostic Source Users Guide".

To enable, edit the TelemetryModules section of the ApplicationInsights.config file:

<Add Type="Microsoft.ApplicationInsights.DiagnsoticSourceListener.DiagnosticSourceTelemetryModule, Microsoft.ApplicationInsights.DiagnosticSourceListener">
      <Sources>
        <Add Name="MyDiagnosticSourceName" />
      </Sources>
 </Add>