Azure Funtions C# How to log custom messages from a class using reflection to azure monitoring logs or analytics monitorlng logs

Viewed 242

I'm using WebJobsStartup with my azure function. In Startup.cs file , I'm loading say abc.dll from my another project using reflection and invoking it's main method. I want to get logs from this called method(abc.dll) along with HttpTrigger function.

In main method of abc.dll, I'm using ILogger to log messages and same with my azure function.

When I deploy this function to azure (Azure functions), I'm able to see logs related to azure function only and not of abc.dll (called method). I have checked that abc.dll is getting loaded (by calling logging on webpage)

I've tried application insights and live metrics, updated host.json as various options provided at in documentation of Azure links below:

              "fileLoggingMode": "debugOnly",
               "logLevel": {
               "Function.HttpTriggerAzureCSharp1":"Information",
               "Host.Results": "Error",
               "Host.Aggregator": "Trace",
               "default": "Information"
              },

which seems not working.

Please suggest options to show logs of abc.dll (called method) with azure function.

I am using azure funtions with below details:

  • OS : Linux
  • Plan : consumption
  • Platform : .net-core
  • Dev Env:Visual Studio Code
  • Language : C#

I have already tried this this2

1 Answers

As Peter mentioned in comments, you can register them in DI configuration of the function. enter image description here

Here is a sample for your reference, you can refer to it to know how to develop the code of your service and log provider. enter image description here

enter image description here

Related