mirror of https://github.com/dapr/docs.git
Changed api logging feature - docs (#2308)
* Changed api logging feature - docs Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changes based on the review comments Signed-off-by: Amulya Varote <amulyavarote@microsoft.com> * Changes based on the review comments - 2 Signed-off-by: Amulya Varote <amulyavarote@microsoft.com>
This commit is contained in:
parent
7d6c356fae
commit
48b63b2310
|
@ -84,6 +84,10 @@ spec:
|
|||
...
|
||||
```
|
||||
|
||||
## API Logging
|
||||
|
||||
API logging enables you to see the API calls from your application to the Dapr sidecar to debug issues. You can combine both Dapr API logging with Dapr log events. See [configure and view Dapr Logs]({{< ref "logs-troubleshooting.md" >}}) and [configure and view Dapr API Logs]({{< ref "api-logs-troubleshooting.md" >}}) for more information.
|
||||
|
||||
## Log collectors
|
||||
|
||||
If you run Dapr in a Kubernetes cluster, [Fluentd](https://www.fluentd.org/) is a popular container log collector. You can use Fluentd with a [json parser plugin](https://docs.fluentd.org/parser/json) to parse Dapr JSON formatted logs. This [how-to]({{< ref fluentd.md >}}) shows how to configure the Fluentd in your cluster.
|
||||
|
@ -100,3 +104,5 @@ If you are using the Azure Kubernetes Service, you can use [Azure monitor for co
|
|||
|
||||
- [How-to : Set up Fleuntd, Elastic search, and Kibana]({{< ref fluentd.md >}})
|
||||
- [How-to : Set up Azure Monitor in Azure Kubernetes Service]({{< ref azure-monitor.md >}})
|
||||
- [Configure and view Dapr Logs]({{< ref "logs-troubleshooting.md" >}})
|
||||
- [Configure and view Dapr API Logs]({{< ref "api-logs-troubleshooting.md" >}})
|
||||
|
|
|
@ -6,42 +6,36 @@ weight: 3000
|
|||
description: "Understand how API logging works in Dapr and how to view logs"
|
||||
---
|
||||
|
||||
API logging enables you to see the API calls from your application to the Dapr sidecar and debug issues as a result with different verbosity levels. You can also combine Dapr API logging with Dapr log events (see [configure and view Dapr Logs]({{< ref "logs-troubleshooting.md" >}}) into the output, if you want to use the logging capabilities together.
|
||||
API logging enables you to see the API calls from your application to the Dapr sidecar and debug issues as a result when the flag is set. You can also combine Dapr API logging with Dapr log events (see [configure and view Dapr Logs]({{< ref "logs-troubleshooting.md" >}}) into the output, if you want to use the logging capabilities together.
|
||||
|
||||
## Overview
|
||||
|
||||
API logs have different, configurable verbosity levels and is applicable for both HTTP and GRPC calls.
|
||||
The default value of the flag is false.
|
||||
|
||||
1. info
|
||||
2. debug
|
||||
|
||||
The default level is debug, which provides a balanced amount of information for operating Dapr in normal conditions.
|
||||
|
||||
To set the output level, you can use the `--api-log-level` command-line option. For example:
|
||||
To enable API logging, you can use the `--enable-api-logging` command-line option. For example:
|
||||
|
||||
```bash
|
||||
./daprd --api-log-level info
|
||||
./daprd --api-log-level debug
|
||||
./daprd --enable-api-logging
|
||||
```
|
||||
|
||||
This starts the Dapr runtime with a api log level of `info` and `debug` accordingly.
|
||||
This starts the Dapr runtime with API logging.
|
||||
|
||||
## Configuring API logging in self hosted mode
|
||||
|
||||
To set the log level when running your app with the Dapr CLI, pass the `api-log-level` param:
|
||||
To enable API logging when running your app with the Dapr CLI, pass the `enable-api-logging` flag:
|
||||
|
||||
```bash
|
||||
dapr run --api-log-level info node myapp.js
|
||||
dapr run --enable-api-logging node myapp.js
|
||||
```
|
||||
|
||||
### Viewing API logs in self hosted mode
|
||||
|
||||
When running Dapr with the Dapr CLI, both your app's log output and the Dapr runtime log output are redirected to the same session, for easy debugging.
|
||||
|
||||
The below example shows `info` level API logging:
|
||||
The example below shows some API logs:
|
||||
|
||||
```bash
|
||||
dapr run --api-log-level info node myapp.js
|
||||
dapr run --enable-api-logging -- node myapp.js
|
||||
|
||||
ℹ️ Starting Dapr with id order-processor on port 56730
|
||||
✅ You are up and running! Both Dapr and your app logs will appear here.
|
||||
|
@ -55,36 +49,13 @@ INFO[0000] HTTP API Called: DELETE /v1.0/state/statestore app_id=order-processo
|
|||
INFO[0000] HTTP API Called: PUT /v1.0/metadata/cliPID app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
|
||||
```
|
||||
|
||||
The below example is for debug level API logging
|
||||
|
||||
```bash
|
||||
dapr run --api-log-level debug node myapp.js
|
||||
ℹ️ Starting Dapr with id order-processor on port 56730
|
||||
✅ You are up and running! Both Dapr and your app logs will appear here.
|
||||
.....
|
||||
DEBU[0000] HTTP API Called: POST /v1.0/state/statestore app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
|
||||
== APP == INFO:root:Saving Order: {'orderId': '483'}
|
||||
DEBU[0000] HTTP API Called: GET /v1.0/state/statestore/483 app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
|
||||
== APP == INFO:root:Getting Order: {'orderId': '483'}
|
||||
DEBU[0000] HTTP API Called: DELETE /v1.0/state/statestore app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
|
||||
== APP == INFO:root:Deleted Order: {'orderId': '483'}
|
||||
DEBU[0000] HTTP API Called: PUT /v1.0/metadata/cliPID app_id=order-processor instance=QTM-SWATHIKIL-1.redmond.corp.microsoft.com scope=dapr.runtime.http type=log ver=edge
|
||||
```
|
||||
|
||||
## Configuring API logging in Kubernetes
|
||||
|
||||
You can set the log level individually for every sidecar by providing the following annotation in your pod spec template:
|
||||
You can enable the API logs for every sidecar by providing the following annotation in your pod spec template:
|
||||
|
||||
```yml
|
||||
annotations:
|
||||
dapr.io/api-log-level: "info"
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```yml
|
||||
annotations:
|
||||
dapr.io/api-log-level: "debug"
|
||||
dapr.io/enable-api-logging: true
|
||||
```
|
||||
|
||||
### Viewing API logs on Kubernetes
|
||||
|
@ -106,13 +77,3 @@ time="2022-03-16T18:32:02.917629403Z" level=info msg="HTTP API Called: GET /v1.0
|
|||
time="2022-03-16T18:32:03.137830112Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
|
||||
time="2022-03-16T18:32:03.359097916Z" level=info msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-f4f949886-cbnmt scope=dapr.runtime.http type=log ver=edge
|
||||
```
|
||||
|
||||
The below example is for debug level API logging in Kubernetes. The debug level API logs are visible only when the log-level is set to debug.
|
||||
|
||||
```bash
|
||||
time="2022-03-18T21:03:00.03969986Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
|
||||
time="2022-03-18T21:03:00.271463876Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
|
||||
time="2022-03-18T21:03:00.492570204Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
|
||||
time="2022-03-18T21:03:00.705486991Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
|
||||
time="2022-03-18T21:03:00.916868445Z" level=debug msg="HTTP API Called: GET /v1.0/invoke/invoke-receiver/method/my-method" app_id=invoke-caller instance=invokecaller-56894979cd-rt87b scope=dapr.runtime.http type=log ver=edge
|
||||
```
|
||||
|
|
|
@ -30,7 +30,7 @@ This table is meant to help users understand the equivalent options for running
|
|||
| `--unix-domain-socket` | `--unix-domain-socket` | `-u` | not supported | On Linux, when communicating with the Dapr sidecar, use unix domain sockets for lower latency and greater throughput compared to TCP ports. Not available on Windows OS |
|
||||
| `--log-as-json` | not supported | | `dapr.io/log-as-json` | Setting this parameter to `true` outputs logs in JSON format. Default is `false` |
|
||||
| `--log-level` | `--log-level` | | `dapr.io/log-level` | Sets the log level for the Dapr sidecar. Allowed values are `debug`, `info`, `warn`, `error`. Default is `info` |
|
||||
| `--api-log-level` | `--api-log-level` | | `dapr.io/api-log-level` | Sets the API log level for the Dapr sidecar. Allowed values are `debug`, `info`. Default is `debug` |
|
||||
| `--enable-api-logging` | `--enable-api-logging` | | `dapr.io/enable-api-logging` | Enables API logging for the Dapr sidecar |
|
||||
| `--app-max-concurrency` | `--app-max-concurrency` | | `dapr.io/app-max-concurrency` | Limit the concurrency of your application. A valid value is any number larger than `0`
|
||||
| `--metrics-port` | `--metrics-port` | | `dapr.io/metrics-port` | Sets the port for the sidecar metrics server. Default is `9090` |
|
||||
| `--mode` | not supported | | not supported | Runtime mode for Dapr (default "standalone") |
|
||||
|
|
|
@ -36,7 +36,7 @@ dapr run [flags] [command]
|
|||
| `--help`, `-h` | | | Print this help message |
|
||||
| `--image` | | | The image to build the code in. Input is: `repository/image` |
|
||||
| `--log-level` | | `info` | The log verbosity. Valid values are: `debug`, `info`, `warn`, `error`, `fatal`, or `panic` |
|
||||
| `--api-log-level` | | `debug` | The API log verbosity. Valid values are: `debug` or `info` |
|
||||
| `--enable-api-logging` | | `false` | Enable the logging of all API calls from application to Dapr |
|
||||
| `--metrics-port` | `DAPR_METRICS_PORT` | `9090` | The port that Dapr sends its metrics information to |
|
||||
| `--profile-port` | | `7777` | The port for the profile server to listen on |
|
||||
| `--unix-domain-socket`, `-u` | | | Path to a unix domain socket dir mount. If specified, communication with the Dapr sidecar uses unix domain sockets for lower latency and greater throughput when compared to using TCP ports. Not available on Windows OS |
|
||||
|
@ -65,4 +65,7 @@ dapr run --app-id myapp
|
|||
|
||||
# Run a gRPC application written in Go (listening on port 3000)
|
||||
dapr run --app-id myapp --app-port 5000 --app-protocol grpc -- go run main.go
|
||||
|
||||
# Run a NodeJs application that listens to port 3000 with API logging enabled
|
||||
dapr run --app-id myapp --app-port 3000 --enable-api-logging -- node myapp.js
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue