---
schema_version: "1"
id: 27cd05c0c39cabb31a9d066159092ad90967fe57163295596e5e844e4198b3b1
title: Log4j を使用したログシステムとのインテグレーション
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/runtime-fabric/2.5/use-log4j-appender.md
canonical_url: https://docs.mulesoft.com/jp/runtime-fabric/2.5/use-log4j-appender
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2d5e3511e8a202ee4c9263b048f451f660b979728d5a354076b59ff8de1639c8
description: MuleSoft Documentation Site
release: "2.5"
latest: false
---
# Log4j を使用したログシステムとのインテグレーション

Log4j アペンダーを使用して、ログシステムを Runtime Fabric にデプロイされたアプリケーションと統合できます。

任意の Log4j アペンダーを使用できます。​`log4j2.xml`​ の設定については、 [「Log4j の設定構文」](https://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax)​を参照してください。

## [](#要件と制限事項)要件と制限事項

- MuleSoft のサポートは、カスタムログ設定の実装や、カスタムログ設定に起因する問題の解決については、支援しません。
- MuleSoft では、以下のような Log4j アペンダーの設定ミスによる問題については責任を負いません。
    
    - ログデータの消失
    - パフォーマンスの低下
    - ディスクスペースの不足
- 同期ログアペンダーは使用しないでください。
    
    非同期ログアペンダーのみを使用してください。
- FileAppender、RollingFileAppender、AnypointMonitoringFileAppender、RandomAccessFileAppender などのファイルアペンダーは自動的に削除されます。
- カスタム Log4j 設定を使用する場合、Mule Runtime Engine とアプリケーションログの両方を Anypoint Monitoring で引き続き使用できます。

## [](#log4j-の有効化)Log4j の有効化

カスタム Log4j 設定はデフォルトで無効化されています。Runtime Fabric をインストールすると、パラメーターは ​`Values.yaml`​ で無効化 (​`false`​ に設定) されます。この値を ​`true`​ に設定する必要があります。

また、次の手順でカスタム Log4j 設定を有効化することもできます。

1. クラスター内から次を実行します。
    
    kubectl -nrtf patch secret custom-properties -p '{"data":{"CUSTOM\_LOG4J\_ENABLED":"dHJ1ZQ=="}}'
2. Runtime Fabric エージェントポッドを再起動します。
3. カスタム Log4j 設定に関連付けられているアプリケーションを再起動します。

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content">カスタム Log4j は、Mule バージョン 4.3.0 以降の Mule Runtime エンジンインスタンスで動作している Mule アプリケーションでのみサポートされます。Mule イメージは、2022 年 11 月 17 日より後にビルドされている必要があります。詳細は、​<a href="https://docs.mulesoft.com/jp/release-notes/runtime-fabric/runtime-fabric-runtimes-release-notes#november-14-2022" class="xref page">「Runtime Fabric リリースノート」</a>​を参照してください。</td></tr></tbody></table>

## [](#例-splunk-を使用して-log4j-設定を作成する)例: Splunk を使用して Log4j 設定を作成する

ログを Runtime Fabric で表示可能にし、Splunk に送信するには、​`SplunkHttp`​ Log4j アペンダーを設定します。

Log4j アペンダーを有効にする手順は、次のとおりです。

1. `log4j2.xml`​ 設定ファイルを自分のロガー設定で更新し、​`SplunkHttp`​ Log4j アペンダーを含めます。
    
    Anypoint Studio では、​`log4j2.xml`​ ファイルは ​`src/main/resources`​ ディレクトリにあります。

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" name="cloudhub" packages="com.mulesoft.ch.logging.appender">
    <Appenders>
    	<Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n"/>
        </Console>
        <SplunkHttp name="SPLUNK"
        	source="${env:APP_NAME}"
        	host="${env:POD_NAME}"
        	sourceType="mule-app"
            url="${sys:splunk.host}"
            token="${sys:splunk.token}"
            index="main">
            <PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n" />
        </SplunkHttp>
    </Appenders>
    <Loggers>
        <AsyncRoot level="INFO">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="SPLUNK"/>
        </AsyncRoot>
    </Loggers>
</Configuration>
```

1. 設定に Splunk 連動関係が含まれていることを確認します。
    
    ```xml
    <dependency>
       <groupId>com.splunk.logging</groupId>
       <artifactId>splunk-library-javalogging</artifactId>
       <version>x.x.x</version>
    </dependency>
    *********
    ******************
    <repository>
       <id>splunk-artifactory</id>
       <name>Splunk Releases</name>
       <url>https://splunk.jfrog.io/splunk/ext-releases-local</url>;
    </repository>
    ```
    
    Splunk の最新バージョンについては、 [GitHub](https://github.com/splunk/splunk-library-javalogging/tags)​ を参照してください。

アプリケーションが起動すると、カスタム Log4j アペンダーへのログの送信が開始され、対象ログシステムでログを参照できるようになります。

## [](#関連情報)関連情報

- [MDC ログ](https://docs.mulesoft.com/mule-runtime/latest/logging-mdc)