Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the log file created when debugging Azure Function in Visual Studio

I have a Timer Azure Function which I execute in VS. Right click on the Azure Function project and Debug. The function has an ILogger log.

Inspecting the log object I can see that is has two loggers

  • Azure.Functions.Cli.Diagnostics.ColoredConsoleLogger
  • Microsoft.Azure.WebJobs.Script.Diagnostics.FileLogger

I also can see that the RootLogPath is %temp%\LogFiles\Application\Functions.

However at that location there is only a "Host" folder. I expected to find a "Function" folder as well with the log file.

Do I need to enable somehow the File Logger? Do I miss anything?

like image 823
Nicolae Daian Avatar asked Mar 04 '23 12:03

Nicolae Daian


1 Answers

To get file logs in local dev, we do have to modify the fileLoggingMode to always in host.json. The default debugOnly setting doesn't make function write file logs locally.

For v2 Functions

{
  "version": "2.0",
  "logging": {
    "fileLoggingMode": "always"
  }
}

For v1 Functions

{
    "tracing": {
      "fileLoggingMode": "always"
    }
}
like image 137
Jerry Liu Avatar answered Mar 11 '23 11:03

Jerry Liu