---
schema_version: "1"
id: eb97d0045655dba16354d1f6888b5b67db37e56b33f0d221e3df5396d94c9190
title: ポリシーログの設定
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/pdk/1.4/policies-pdk-configure-features-logging.md
canonical_url: https://docs.mulesoft.com/jp/pdk/1.4/policies-pdk-configure-features-logging
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 95bb6379c9ef3e02ab56361cef23480e0ef06ac48ce1d9a1170e629a03e24058
description: MuleSoft Documentation Site
release: "1.4"
latest: false
---
# ポリシーログの設定

Flex Gateway ポリシー開発キット (PDK) は、API インスタンス ID、ポリシー ID、要求 ID を含むログメッセージを生成するログメカニズムを提供します。

`Pdk::logger;`​ パッケージを使用して、以下のマクロでカスタムログを挿入します。

- `logger::debug!`
- `logger::info!`
- `logger::warn!`
- `logger::error!`

マクロは [Rust std::format! macro](https://doc.rust-lang.org/std/macro.format.html)​ と同じ動作をします。最初のパラメーターは形式文字列リテラルである必要があります。リテラルでは ​`{}`​ を使用してパラメーターを渡します。例:

```Rust
use pdk::logger;

// [...]

let value = "there!";
logger::debug!("Hello there!");
logger::info!("Hello {}", value);
logger::warn!("Hello {value}");
logger::error!("Hello {}", "there!");
```

すべての例は、次の形式で Flex Gateway のログに表示されます。

\[flex-gateway-envoy\]\[<log-level>\] wasm log <policy-name>.<api-instance-name> main: \[policy: <policy-name>\]\[api: <api-instance-name>\]\[req: <request-id> \] Hello there!

Flex Gateway ログの表示に関する詳細は、[Monitoring Omni Gateway](https://docs.mulesoft.com/gateway/latest/gateway-monitor)を参照してください。