Forums: Open Discussion (Thread #22654)

【バッチFW】ログ設定(AOP) (2009-05-07 19:35 by Anonymous #43644)




以下の処理前後にlog4jにてクラス名等をログ出力させようと考えています。(AOPにて)

・主処理(Blogic)
・親ジョブ前処理
・親ジョブ後処理
・ジョブ前処理
・ジョブ後処理
・先頭チャンク前処理
・最終チャンク後処理

出力イメージ:  ***.class処理開始
         ***.class処理終了
※要はクラスの処理が開始(終了)したかがわかればよいです。


BLogicについては、log4j.propertiesに以下の設定がありましたが、
この設定ですと、各BLogicの処理ごとにログがでてしまいます。

#BLogic:BLogic実行毎の結果ログ出力
#log4j.category.jp.terasoluna.fw.batch.core.StandardBLogicExecutor=DEBUG


ログの流れとして、

ジョブ前処理開始(&完了)⇒主処理開始(&完了)⇒ジョブ後処理開始(&完了)
などのような流れでログに出力させたいのですが、
どのように実装すればよいのでしょうか?

Reply to #43644×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 【バッチFW】ログ設定(AOP) (2009-05-08 10:15 by ahn #43661)

主処理(Blogic)以外は実装したクラスが実行される前後にAOPにて
ログ出力を追加すれば問題なく出力できると思います。
ただし、主処理(Blogic)はF/Wがループ処理をしているため
AOPを使った制御は難しく、F/Wを拡張する必要があります。

基本的に主処理(Blogic)のループを制御するのは以下のクラスになります。
jp.terasoluna.fw.batch.standard.QueueProcessor
上記クラスのソースを見ると180行以降に
protected void printStartLog(String message, JobStatus jobStatus)と
protected void printEndLog(String message, JobStatus jobStatus)
メソッドがあり、それぞれ実行前後にログを出力しており、
正確に言うとこのログが「主処理(Blogic)」の開始、終了ログになります。
ログ出力の内容を変更する場合は上記のクラスを拡張する必要があります。
※ F/Wが提供するログをそのまま利用する場合は、log4j.propertiesに以下の設定をして下さい。
  log4j.category.jp.terasoluna.fw.batch.standard.QueueProcessor=DEBUG

ただし、主処理(Blogic)のループを制御するクラスはモデル別に違う場合や
親ジョブと子ジョブが同じQueueProcessorを使う場合がありますので注意が必要です。
従って、QueueProcessorを拡張する場合は各モデルのテンプレート
(batchapps/template内のxml)ファイルを確認し、使用するモデル用の
QueueProcessorを拡張する必要があります。
また、親ジョブと子ジョブが同じ「QueueProcessor」を使っている場合は
それぞれ判別できるよう拡張することをお勧めします。

※ 親ジョブと、子ジョブが同じモデルの例:PartitionChunkTransactionBean.xml
親の定義:53行目:<bean id="partitionChunkTransactionQueueProcessor" parent="baseQueueProcessor">
子の定義:96行目:<bean id="partitionChunkTransactionChildQueueProcessor" parent="baseQueueProcessor">

※ baseQueueProcessor以外を使用しているモデルの例:PartitionSingleTransactionBean.xml
親の定義:53行目: <bean id="partitionSingleTransactionQueueProcessor" parent="baseQueueProcessor">
子の定義:96行目:<bean id="singleTransactionChildQueueProcessor" class="jp.terasoluna.fw.batch.springsupport.transaction.TransactionalQueueProcessor">





Reply to #43644

Reply to #43661×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 【バッチFW】ログ設定(AOP) (2009-05-08 16:23 by Anonymous #43670)


ご回答ありがとうございます。
主処理に関して、QueueProcessorの拡張は影響が大きいので、
ご教授頂いたデバッグ文を出力することにしました。
その他の処理はAOPにて実装できました。
ご丁寧な解答ありがとうございました。
Reply to #43644

Reply to #43670×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login