title: Exceptions of my Azure Function are logged 3 times in Application Insights
body: <p>I have created a Blob Trigger Azure Function, and I wanted to be able to create mail alerts when I have an exception, and among the information sent in the mail alert, there should be the name of the file the exception occurred on.</p>
  <p>I noticed that exceptions are automatically logged in Azure, but I found no way of customizing the message or the information sent along the exception. So I decided to inject a telemetry service in my Function App, and add the file name as a custom property, as you can see in the code below :</p>
  <pre><code>public class Function1
  {
      private readonly IGremlinService _gremlinService;
      private readonly TelemetryClient _telemetryClient;
      public Function1(IGremlinService gremlinService, TelemetryConfiguration telemetryConfiguration)
      {
          this._gremlinService = gremlinService;
          this._telemetryClient = new TelemetryClient(telemetryConfiguration);
      }
  
      [FunctionName(nameof(Function1))]
      public async Task Run([BlobTrigger(&quot;files/{directory}/{name}.00.pdf&quot;, Connection = &quot;AzureWebJobsStorage&quot;)] Stream myBlob, string name, ILogger logger)
      {
          try
          {
               //some code not related to the issue
          }
          catch (Exception e)
          {
              var properties = new Dictionary&lt;string, string&gt;
                  {{&quot;Filename&quot;, name}};
              _telemetryClient.TrackException(e, properties);
              if (e is ResponseException)
              {
                  ResponseException re = (ResponseException) e;
  
                  var statusCode = (long) re.StatusAttributes[&quot;x-ms-status-code&quot;];
                 
                  _telemetryClient.TrackTrace(&quot;Error on file &quot; + name + &quot;. Status code: &quot; + statusCode + &quot; &quot; + re.StackTrace, SeverityLevel.Error, properties);
              }
              else
              {
                  _telemetryClient.TrackTrace(&quot;Error on file &quot; + name, SeverityLevel.Error, properties);
              }
              throw;
          }
      }
  }
    }   
  </code></pre>
  <p>But I still cannot customize the message to provide the user with additional information. I know I can send alerts on trace messages instead, and send customized messages this way, and this is currently what I'm doing, but I would find it cleaner to send alert on exceptions.</p>
  <p>My second issue is that my exceptions are still logged automatically on top of being logged by the telemetry service, and for some reason I can't understand, they are logged twice, as you can see in the screenshot below from Application Insights :</p>
  <p><a href="https://i.stack.imgur.com/7VsYL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7VsYL.jpg" alt="enter image description here" /></a></p>
  <p>Is there a way I can turn off the automatic logging of exceptions ? Or is there a way to customize these exceptions messages that I'm not aware of, instead of using the telemetry service ?</p>