Name your .NET application

New Relic's .NET agent gives you several ways to change the application name reported and displayed in APM. This document gives you an overview of those naming options.

For a general overview of APM app naming (not .NET-specific), see Name your application. To change an application's name without breaking data continuity, use the UI alias-change option.

Set your app name (recommended method)

When you first deploy your app, you can change the default name to a more descriptive one. Since New Relic collects metrics using these names, customizing them allows you to run the same application on multiple hosts and get metrics from all their instances.

Typically, configuring your app-local newrelic.config file is the most convenient naming method.

Naming method Description

Recommended:

Configure your app-local newrelic.config file

This method lets you give your app a unique name with specific configuration settings. It also works for both IIS and non-IIS hosted apps.

  1. Copy the newrelic.config file from the agent home directory into your app's root folder.

    Default: %ALLUSERSPROFILE%\New Relic\.NET Agent

  2. Open the copy and set your app name as follows:
    <application>
        <name> App Name </name>
    </application>
    
  3. Restart your application.

As long as your app is active, data should appear within a few minutes. If not, follow our troubleshooting procedures.

Other methods

If you have a specific use or purpose in mind, you may prefer a different naming method. Here's a full list of the alternative methods:

Some methods take precedence over others. Before choosing a naming method, make sure you understand how your configurations may be affected.

Naming method Description
Configure your web.config file

If you have apps hosted on IIS and prefer not to have a local newrelic.config file, you can configure the naming settings in your web.config file.

Steps

For .NET Framework apps:

  1. Add the following entry to the appSettings section of your file, and then restart your application.
    <appSettings>
        <add key = "NewRelic.AppName" value = "App Name" />
    </appSettings>

For .NET Core apps:

  1. Add the NEW_RELIC_APP_NAME environment variable to your file as follows, and then restart your application.
    <aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" >
        <environmentVariables>
            <environmentVariable name="NEW_RELIC_APP_NAME" value="App Name" />
        </environmentVariables>
    </aspNetCore>
Set app name using environment variables

If you want to easily set app names during the deployment of containers, set an environment variable in the application's environment.

Steps
  1. Set the environmental variable NEW_RELIC_APP_NAME in your application's environment:
    NEW_RELIC_APP_NAME = "App name"

This method only works if you're using .NET agent version 6.17.387.0 or higher.

Name after app pools

If your IIS application pools already have unique names you like, or if you're using a shared network content infrastructure (SNCI), you can name your app after its assigned app pool.

Steps
  1. Remove any NewRelic.AppName keys from the <appSettings> section in web.config. Make sure not to delete the surrounding <appSettings> tags.
  2. Remove any <name> child elements from the <application> parent element in newrelic.config. Make sure not to delete the surrounding <application> tags.

Each app will then report according to its app pool name.

Configure your app.config file

If you have applications not hosted on IIS and prefer not to have a local newrelic.config file, you can configure the naming settings in your app.config file.

Steps
  1. Add the following entry to your app.config file (for example, applicationname.exe.config), and then restart your application.
    <appSettings>
        <add key = "NewRelic.AppName" value = "App Name" />
    </appSettings>
    

Use the .NET agent API

If you want to rename your app programmatically, you can use the SetApplicationName() agent API call to set the app name at run time. This name will take priority over all other application naming sources.

As long as your app is active, data should appear within a few minutes. If not, make sure you've performed an IISRESET from an administrative command prompt if you've changed your .NET app's configuration file (newrelic.config or app.config). Otherwise, follow our troubleshooting procedures.

Use multiple app names

You can use multiple app names to aggregate data from your applications. We sometimes call this "rolling up" your data.

For the .NET agent, you can set up to three application names. The first name is the primary application name, and the second and third names are used for the more general data aggregation categories. For more about how multiple app names work, see Use multiple app names.

Newrelic.config file

Here's an example of setting multiple names in your app-local newrelic.config file:

<application>
    <name>Primary App Name</name>
    <name>Second App Name</name>
    <name>Third App Name</name>
</application>
Web.config file

Here's an example of setting multiple names in your web.config file:

<appSettings>
    <add key="NewRelic.AppName" value="App Name, App Name 2, App Name 3" />
</appSettings>
App.config file

Here's an example of setting multiple names in your app.config file:

<appSettings>
    <add key="NewRelic.AppName" value="App Name, App Name 2, App Name 3" /
</appSettings>

For more help

If you need more help, check out these support and learning resources: