> Source: https://www.ymotongpoo.com/works/otel-specs-ja/semconv/general/logs/


# ログの汎用属性

**ステータス**: [Development][DocumentStatus]

この節で説明する属性は、かなり汎用的なものです。これらは、適用可能な任意のログレコードで使用できます。

ログに関しては、次のセマンティック規約が定義されています。

* **[General](#ログ識別に関する汎用属性): ログレコードの記述に使用できる汎用のセマンティック属性。**
* [Exceptions](/works/otel-specs-ja/semconv/exceptions/exceptions-logs/): ログにおける例外の記述に使用できるセマンティック属性。

ログに関するセマンティック規約とは別に、[イベント](/works/otel-specs-ja/semconv/general/events/)、[トレース](/works/otel-specs-ja/semconv/general/trace/)、[メトリクス](/works/otel-specs-ja/semconv/general/metrics/)についても、OpenTelemetryは、独自の[リソースセマンティック規約](https://opentelemetry.io/docs/specs/semconv/resource/)を持つ包括的な[リソース](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.59.0/specification/resource/sdk.md)という概念を定義しています。

## ログ識別に関する汎用属性

これらの属性は、ログレコードを識別するために使用できます。

<!-- semconv log.record -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`log.record.original`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | string | 元の完全なログレコード。 [1] | `77 <86>1 2015-08-06T21:58:59.694Z 192.168.2.133 inactive - - - Something happened`; `[INFO] 8/3/24 12:34:56 Something happened` |
| [`log.record.uid`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | string | ログレコードの一意な識別子。 [2] | `01ARZ3NDEKTSV4RRFFQ69G5FAV` |

**[1] `log.record.original`:** この値は、ログレコードが元々文字列または同等のデータ型として送信され、かつそのログレコードの Body フィールドが同じ値を含んでいない場合に処理する際に追加してもかまいません（MAY）（例: syslogやファイルから読み取ったログレコード）。

**[2] `log.record.uid`:** IDが提供される場合、同じIDを持つ他のログレコードは重複と見なされ、安全に削除できます。つまり、区別可能な2つのログレコードは異なる値を持たなければなりません（MUST）。
このIDは[Universally Unique Lexicographically Sortable Identifier（ULID）](https://github.com/ulid/spec)であってもかまいませんが、必要に応じて他の識別子（例: UUID）を使ってもかまいません。

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

## ログメディア

この節では、OpenTelemetryにおけるログメディアの属性について説明します。ログメディアとは、ログが伝送される仕組みのことです。メディアの種類には、ファイル、ストリーム、ネットワークプロトコル、journaldやWindowsイベントログなどOS固有のロギングサービスが含まれます。

**注:** OpenTelemetryの仕様は、[リソース](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.59.0/specification/resource/sdk.md)を「テレメトリーを生成するエンティティの不変な表現」として定義しています。
以下の属性は、テレメトリーを生成するエンティティを記述するものではありません。むしろ、ログの伝送の仕組みを記述するものです。
そのため、これらは適用可能な場合はログレコードの属性として記録すべきです。リソース属性として記録すべきではありません。

### ログファイル

**説明:** ログが出力されたファイル。

<!-- semconv attributes.log.file -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`log.file.name`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Recommended` | string | ファイルのベース名。 | `audit.log` |
| [`log.file.name_resolved`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | string | シンボリックリンクを解決した後のファイルのベース名。 | `uuid.log` |
| [`log.file.path`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | string | ファイルへの完全なパス。 | `/var/log/mysql/audit.log` |
| [`log.file.path_resolved`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | string | シンボリックリンクを解決した後のファイルへの完全なパス。 | `/var/lib/docker/uuid.log` |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

### I/Oストリーム

**説明:** ログが出力されたI/Oストリーム。

<!-- semconv attributes.log -->
<!-- NOTE: THIS TEXT IS AUTOGENERATED. DO NOT EDIT BY HAND. -->
<!-- see templates/registry/markdown/snippet.md.j2 -->
<!-- prettier-ignore-start -->

**Attributes:**

| Key | Stability | [Requirement Level](/works/otel-specs-ja/semconv/general/attribute-requirement-level/) | Value Type | Description | Example Values |
| --- | --- | --- | --- | --- | --- |
| [`log.iostream`](https://opentelemetry.io/docs/specs/semconv/registry/attributes/log/) | ![Development](https://img.shields.io/badge/-development-blue) | `Opt-In` | string | ログに関連付けられたストリーム。既知の値の一覧を以下に示します。 | `stdout`; `stderr` |

---

`log.iostream` には、次のよく知られた値の一覧があります。いずれかが該当する場合はその値を使用しなければならず（MUST）、それ以外の場合は独自の値を使ってもかまいません（MAY）。

| Value | Description | Stability |
| --- | --- | --- |
| `stderr` | stderrストリームからのイベント | ![Development](https://img.shields.io/badge/-development-blue) |
| `stdout` | stdoutストリームからのログ | ![Development](https://img.shields.io/badge/-development-blue) |

<!-- prettier-ignore-end -->
<!-- END AUTOGENERATED TEXT -->
<!-- endsemconv -->

[DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status

