Legacy Knowledge Base
公開されました Sep. 10, 2025

一部のログを別のログファイルに書き出す方法

Written By

Daniel Mijarra

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

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

問題

  • トレースをメインのログファイルから別のログファイルに移動したい。

環境

  • DXP 7.3+
  • 四半期リリース

解像度

  • portal-log4j-ext.xmlファイルを使用して、追加ログファイルの名前を指定する新しいアペンダーを追加することができます:

    1. portal-log4j-ext.xml を編集する。 2. ログファイル(myLog....log)に新しいアペンダーを追加します:

    <appender class="org.apache.log4j.rolling.RollingFileAppender" name="MY_LOG_TEXT_FILE">
    <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
    <param name="FileNamePattern" value="@liferay.home@/logs/myLog@spi.id@.%d{yyyy-MM-dd}.log" />
    </rollingPolicy>
    <layout class="org.apache.log4j.EnhancedPatternLayout">
    <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%t][%c{1}:%L] %m%n" />
    </layout>
    </appender>

    3. 新しいアペンダーを<ルート>タグに追加します:

    <root>
    <priority value="INFO" />

    <appender-ref ref="CONSOLE" />
    <appender-ref ref="TEXT_FILE" />
    <appender-ref ref="XML_FILE" />
    <appender-ref ref="MY_LOG_TEXT_FILE" />
    </root>

    4. トレースをテキストでフィルタリングする一つの方法は、そのテキストを含むトレースを表示するかしないか、各アペンダーにフィルタを追加することで実現できます。
    ログにトレースを表示します:

    <filter class="org.apache.log4j.varia.StringMatchFilter">
    <param name="StringToMatch" value="Tex to filter" />
    <param name="AcceptOnMatch" value="true" />
    </filter>

    ログにトレースを表示しない:

    <filter class="org.apache.log4j.varia.StringMatchFilter">
    <param name="StringToMatch" value="Tex to filter" />
    <param name="AcceptOnMatch" value="false" />
    </filter>

追加情報

Did this article resolve your issue ?

Legacy Knowledge Base