Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Relic Solution: Monitoring an ASP.NET CORE application targeting the .NET Framework

level-up

#1

ASP.NET CORE application targeting the .NET Framework

Microsoft’s .NET platform is now made up of two separate forms: the traditional, tried-and-true, Windows-only .NET Framework, and the next generation, open source, cross-platform .NET Core.

The adoption of .NET Core has been on an upswing due to its fantastic performance, ease of maintenance, and ability to run on many different operating systems.

Of course, since Core is an emerging platform that’s still being developed, you may still need to run your ASP.NET Core app on the .NET Framework as not all technologies are yet supported on Core.

Many developers have taken this route and modified the TargetFramework section of their Core app’s .csproj file to target a specific version of the .NET Framework. That section might look like this:

<TargetFramework>net461</TargetFramework>

…instead of the original:

<TargetFramework>netcoreapp2.0</TargetFramework>

Fortunately, as of the .NET Framework agent version 8.1, it’s now possible to monitor this type of application “out of the box” with a few settings added — namely, the environment variables that tell the agent it should monitor a certain process.

Although your app may use an appSettings.json file, you’ll likely need to add the environment variables directly into the app’s processPath found in the web.config file as shown below.

The environment variables are similar to the following but please make sure to specify your .NET Framework agent’s installation path if it’s located elsewhere:

   <aspNetCore processPath="C:\Test\coreframework.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
     <environmentVariables>
       <environmentVariable name="COR_ENABLE_PROFILING" value="1" />
       <environmentVariable name="COR_PROFILER" value="{71DA0A04-7777-4EC6-9643-7D28B46A8A41}" />
       <environmentVariable name="NEWRELIC_INSTALL_PATH" value="C:\Program Files\New Relic\.NET Agent\" />
     </environmentVariables>
   </aspNetCore>
 </system.webServer>
</configuration>

In order to name your application, you can also add the following variable prior to the ending </environmentVariables> tag:

<environmentVariable name="NEW_RELIC_APP_NAME" value="My Application" />

Finally, you’ll need to specify the name of your .exe file so the .NET agent knows to instrument the process.

There are two ways to do this: by modifying your app’s .exe.config file, or the newrelic.config file.

If you’re using the app’s .exe.config file, you’ll want to add the NewRelic.AgentEnabled key/value pair. You can also name the app here if you’d like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="NewRelic.AgentEnabled" value="true" />
    <add key="NewRelic.AppName" value="My App Name" />
  </appSettings>

If you’d prefer to target the application in the newrelic.config file, it is located at C:\ProgramData\New Relic\.NET Agent.

You’ll need to add this information to the newrelic.config file before the ending </configuration> tag:

   <instrumentation>
   <applications>
     <application name="CoreFramework.exe" />
   </applications>
   </instrumentation>

Hopefully, after an app restart, your application appears in New Relic!

UPDATE: Beginning with the release of .NET Agent 8.7.75.0 you can use a local newrelic.config file to enable monitoring for an application:

  • Place the newrelic.config file in the directory containing the application’s executable file.
  • Set the agentEnabled attribute to true.

For example:

<configuration xmlns="urn:newrelic-config"
  agentEnabled="true">

If you still don’t see the app reporting, you can try following the .NET Framework troubleshooting steps here.

Of course, you can always post right here in the community if you run into issues with this, and we’ll be happy to look into it!

Cheers!


Newrelic agent for ASP.NET Core (1.1 and 2.0)
ASP.NET Core app targeting .NET Framework
Newrelic agent for ASP.NET Core (1.1 and 2.0)