6

Cargo Mavenプラグインを使用してWARをリモートサーバーにデプロイしていますが、問題が発生しています。おそらくその問題について2番目の質問を作成しますが、これはMavenプラグインのlog4j構成をオーバーライドすることに関するものです。CargoはJBossのクライアントライブラリを使用して、JBossサーバーにデータを送信します(これを実行しようとしています)。JBossライブラリはlog4jを使用します。Cargoは、私が知っているようなマッピングレイヤーを設定していません。

したがって、基本的に、ログメッセージはMavenプラグインの依存ライブラリで発生します。-Dlog4j.debugを設定してみて、次の情報を取得しました。

log4j: Trying to find [log4j.xml] using ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]] class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]].
log4j: Using URL [jar:file:/C:/Users/username/.m2/repository/org/jboss/jbossts/jbossjts/4.13.1.Final/jbossjts-4.13.1.Final.jar!/log4j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL jar:file:/C:/Users/username/.m2/repository/org/jboss/jbossts/jbossjts/4.13.1.Final/jbossjts-4.13.1.Final.jar!/log4j.properties
log4j: Could not find root logger information. Is this OK?
log4j: Parsing for [com.arjuna] with value=[INFO, default, stdout].
log4j: Level token is [INFO].
log4j: Category com.arjuna set to INFO
log4j: Parsing appender named "default".
log4j: Parsing layout options for "default".
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c - %m%n].
log4j: End of parsing for "default".
log4j: Setting property [maxBackupIndex] to [2].
log4j: Setting property [file] to [transaction.log].
log4j: Setting property [maxFileSize] to [500KB].
log4j: setFile called: transaction.log, true
log4j: setFile ended
log4j: Parsed "default" options.
log4j: Parsing appender named "stdout".
log4j: Parsing layout options for "stdout".
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c - %m%n].
log4j: End of parsing for "stdout".
log4j: Setting property [threshold] to [WARN].
log4j: Parsed "stdout" options.
log4j: Handling log4j.additivity.com.arjuna=[null]
log4j: Finished configuring.
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
log4j:WARN Please initialize the log4j system properly.

次に、-Dlog4j.configuration = mylog4j.propertiesを設定しようとしましたが、次のようになりました。

log4j: Trying to find [mylog4j.properties] using context classloader ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]].
log4j: Trying to find [mylog4j.properties] using ClassRealm[plugin>org.codehaus.cargo:cargo-maven2-plugin:1.0.5, parent: ClassRealm[maven.api, parent: null]] class loader.
log4j: Trying to find [mylog4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resource: [mylog4j.properties].
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
log4j:WARN Please initialize the log4j system properly.

log4j構成ファイルはMavenプラグインのクラスパスにある必要があるように見えますが、そこにランダムファイルを含める方法がわかりません。依存関係のみです。問題のトラブルシューティングのためにJBossライブラリからデバッグ情報を取得できるように、この情報を設定したいと思います。

4

1 に答える 1

10

log4j.configurationリソース文字列を設定します。log4jのデフォルトの初期化プロセスと例を見てください。

このような構文を使用する場合

-Dlog4j.configuration=mylog4j.properties

ファイルはクラスパスに含まれている必要があります。ただし、次のような構文を使用することもできます

-Dlog4j.configuration=file:/<path>/mylog4j.properties

完全修飾ファイルの場所を指定します。

于 2011-08-23T19:19:00.560 に答える