4

I am working on the application where I need logging and filtering feature. I am using c++. I came to know about the log4cxx support logging.

I am getting difficulty in filtering .

I have five fields

  1. MAcID
  2. Date and time
  3. Command type
  4. Status
  5. Text Msg

I need to store these 5 fields in the log file and filter it as well based on below filtering option. Logging and filtering will be done at run time itself. Once the file size reaches 10 MiB, it will start rewriting the file from the beginning.

Filtering Options
1. MAcID
2. date and time

Filtering can done by filtering either one or both. Result should return all the field in the log file .

  1. Is it possible to store more than one field in the log file using log4CXX?
  2. How to filter the information based on above mentioned criteria?
  3. Do I need to write my own filter class inheriting from existing filter classes?
  4. Do I need to write customise logger class to store 5 field in the log file?
4

2 に答える 2

2

ポイント1と4と同様の問題に一度直面しました。log4cxxコードを読んで、可能な解決策を見つけました。仕事仲間が解決策をテストし、それを進めました。彼の結論はここにあります。

log4cxx メーリング リストで、それが正しい解決策であるかどうかを尋ねたところ、これがられた回答です。それが役立つことを願っています。

于 2011-05-25T16:44:14.207 に答える
0

log4cxx があなたのタスクに適したツールだとは思いません。また、log4cxx でこれができるかどうかもよくわかりません。

カスタム アペンダー、独自のログ レベル、独自のフィルターから始めることができます。
ログレベルを設定し、使用するフィルターフィールドを決定する必要があります。フィルターを変更するたびに、フィルターをクリアして新しいフィルターを設定する必要があります。次に、ログ文字列を抽出し、フィルターを検索して、ログ メッセージを出力するかどうかを決定します。

于 2011-05-23T13:23:54.070 に答える