码迷,mamicode.com
首页 > 其他好文 > 详细

【Azure Function】开启Azure Function输出详细Debug日志 ( --verbose)

时间:2021-01-16 12:02:08      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:span   rod   ram   点击   python   src   run   fda   tac   

When func.exe is run from VS, it suggests "For detailed output, run func with --verbose flag." 

问题描述

在本地调式Azure Function时候,默认输出的日志都是比较简洁的。如果需要详细的日志输出,可以在启动func命令中添加--verbose参数。那如何来添加呢?

日志输出对比:

开启前日志 开启后日志
Hosting environment: Production
Content root path: /home/pont/projects/fibre-collective/packages/certification
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
Value cannot be null. (Parameter ‘provider‘)
Azure Functions Core Tools (3.0.2358 Commit hash: d6d66f19ea30fda5fbfe068fc22bc126f0a74168)
Function Runtime Version: 3.0.13159.0
[5/19/2020 12:09:26 PM] FUNCTIONS_WORKER_RUNTIME set to node. Skipping WorkerConfig for language:python
[5/19/2020 12:09:26 PM] FUNCTIONS_WORKER_RUNTIME set to node. Skipping WorkerConfig for language:java
[5/19/2020 12:09:26 PM] FUNCTIONS_WORKER_RUNTIME set to node. Skipping WorkerConfig for language:powershell
[5/19/2020 12:09:26 PM] Building host: startup suppressed: ‘False‘, configuration suppressed: ‘False‘, startup operation id: ‘190e8a62-6b3e-48f1-83d1-a3ede0bce239‘
[5/19/2020 12:09:26 PM] Reading host configuration file ‘/home/pont/projects/fibre-collective/packages/certification/host.json‘
[5/19/2020 12:09:26 PM] Host configuration file read:
[5/19/2020 12:09:26 PM] {
[5/19/2020 12:09:26 PM]   "version": "2.0",
[5/19/2020 12:09:26 PM]   "logging": {
[5/19/2020 12:09:26 PM]     "applicationInsights": {
[5/19/2020 12:09:26 PM]       "samplingExcludedTypes": "Request",
[5/19/2020 12:09:26 PM]       "samplingSettings": {
[5/19/2020 12:09:26 PM]         "isEnabled": true
[5/19/2020 12:09:26 PM]       }
[5/19/2020 12:09:26 PM]     }
[5/19/2020 12:09:26 PM]   },
[5/19/2020 12:09:26 PM]   "extensionBundle": {
[5/19/2020 12:09:26 PM]     "id": "Microsoft.Azure.Functions.ExtensionBundle",
[5/19/2020 12:09:26 PM]     "version": "[1.*, 2.0.0)"
[5/19/2020 12:09:26 PM]   }
[5/19/2020 12:09:26 PM] }
[5/19/2020 12:09:26 PM] Reading functions metadata
[5/19/2020 12:09:26 PM] 1 functions found
[5/19/2020 12:09:26 PM] Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /tmp/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle
[5/19/2020 12:09:26 PM] Fetching information on versions of extension bundle Microsoft.Azure.Functions.ExtensionBundle available on https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/index.json
[5/19/2020 12:09:27 PM] Downloading extension bundle from https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/1.1.1/Microsoft.Azure.Functions.ExtensionBundle.1.1.1.zip to /tmp/d87a8cf9-a864-42f0-a891-b7e41a7d103d/Microsoft.Azure.Functions.ExtensionBundle.1.1.1.zip
Hosting environment: Production
Content root path: /home/pont/projects/fibre-collective/packages/certification
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[5/19/2020 12:11:22 PM] Executing HTTP request: {
[5/19/2020 12:11:22 PM]   "requestId": "90571ec9-f3f7-4606-b012-62097466c9a3",
[5/19/2020 12:11:22 PM]   "method": "GET",
[5/19/2020 12:11:22 PM]   "uri": "/"
[5/19/2020 12:11:22 PM] }
System.ArgumentNullException: Value cannot be null. (Parameter ‘provider‘)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Azure.Functions.Cli.Actions.HostActions.StartHostAction.RunAsync() in D:\a\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 252
   at Azure.Functions.Cli.ConsoleApp.RunAsync[T](String[] args, IContainer container) in D:\a\1\s\src\Azure.Functions.Cli\ConsoleApp.cs:line 66
Application is shutting down...
[5/19/2020 12:11:45 PM] Stopping host...
[5/19/2020 12:11:45 PM] Host shutdown completed.

 

开启方式

方式一:在VS Code中修改.vscode\launch.json文件中的启动命令

默认通过VS Code创建一个Java Azure Function的文件目录结构为:

PS C:\Function>  tree /f
Folder PATH listing for volume OSDisk
Volume serial number is 4A75-5D11
C:.
│   .classpath
│   .gitignore
│   .project
│   host.json
│   local.settings.json
│   pom.xml
│
├───.settings
│       org.eclipse.core.resources.prefs
│       org.eclipse.jdt.apt.core.prefs
│       org.eclipse.jdt.core.prefs
│       org.eclipse.m2e.core.prefs
│
├───.vscode
│       extensions.json
│       launch.json
│       settings.json
│       tasks.json
│
├───src
│   ├───main
│   │   └───java
│   │       └───com
│   │           └───function
│   │                   Function.java
│   │
│   └───test
│       └───java
│           └───com
│               └───function
│                       FunctionTest.java
│                       HttpResponseMessageMock.java

 

在launch.json文件中,添加启动参数 --verbose

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Java Functions",
      "type": "java",
      "request": "attach",
      "hostName": "127.0.0.1",
      "port": 5005,
      "preLaunchTask": "func: host start --verbose"
    }
  ]
}

点击F5,从VS Code中启动Azure Function,根据提示,在tasks.json也需要添加--verbose参数

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "func",
      "command": "host start --verbose",
      "problemMatcher": "$func-java-watch",
      "isBackground": true,
      "options": {
        "cwd": "${workspaceFolder}/target/azure-functions/myFunction-0115"
      },
      "dependsOn": "package"
    },
    {
      "label": "package",
      "command": "mvn clean package",
      "type": "shell",
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

 

方式二:直接通过命令行启动Azure Funciton,使用完整命令: func host --verbose 

PS C:\Function> func  start --verbose

 

效果展示:

技术图片

 

参考资料:

Value cannot be null. (Parameter ‘provider‘)https://github.com/Azure/azure-functions-core-tools/issues/2232

在 Azure 中使用 Visual Studio Code 创建 Java 函数https://docs.azure.cn/zh-cn/azure-functions/create-first-function-vs-code-java

 

【Azure Function】开启Azure Function输出详细Debug日志 ( --verbose)

标签:span   rod   ram   点击   python   src   run   fda   tac   

原文地址:https://www.cnblogs.com/lulight/p/14283989.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!