legacy-knowledge-base
公開されました Sep. 10, 2025

クラスタ環境で、ログレベルの変更が反映されない場合がある

written-by

Shimada Taro

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

事象

  • クラスタ環境を使用しています。
  • コントロールパネル>サーバー管理>ログレベル からログレベルを変更した際に、そのログが出力されませんでした。
  • アクセスするたびに、設定したログレベルの内容が変わる場合があります。

環境

  • DXP 7.0+

解決

  • アクセス毎に設定が異なって見えたのは、アクセス先のノードがロードバランサによって振り分けられた事によるものと思われます。
    また、Masterノードでのみ実行されるタスクも存在するため、SlaveでDEBUGに設定したカテゴリの操作を行っても、ログがスローされない可能性も考えられます。
  • 各ノードでDEBUGログを有効にするか、log4jを使った恒久的なログレベルの変更が必要となります。

追加情報

  • 機能リクエストLPS-162159
  • ワークアラウンドとして、以下のGroovyスクリプトを実行することで、クラスタ全体のログ レベルを更新でききます
// Specify the new log levels

def newLogLevels = [
"com.liferay.petra.mail": "DEBUG",
]

// Create a cluster request to update the log level on every cluster node

import com.liferay.petra.log4j.Log4JUtil
import com.liferay.petra.reflect.ReflectionUtil
import com.liferay.portal.kernel.cluster.ClusterExecutorUtil
import com.liferay.portal.kernel.cluster.ClusterRequest
import com.liferay.portal.kernel.util.MethodHandler
import java.lang.reflect.Method

Method method = ReflectionUtil.getDeclaredMethod(Log4JUtil.class, "setLevel", String.class, String.class, Boolean.TYPE)

newLogLevels.each({
MethodHandler methodHandler = new MethodHandler(method, it.key, it.value, Boolean.TRUE)
ClusterRequest clusterRequest = ClusterRequest.createMulticastRequest(methodHandler)
ClusterExecutorUtil.execute(clusterRequest)
})

 

did-this-article-resolve-your-issue

legacy-knowledge-base