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?
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Vikram Ranabhatt
  • 7,268
  • 15
  • 70
  • 133
  • 3
    Filter by logger? By log level? Or maybe by some content in the log message? You have to be more specific about what you want. –  May 13 '11 at 13:27
  • @Chris_vr your question is still not clear. What do you want to filter? Typically logging frameworks filter based on the severity of the logging level. – Sam Miller May 13 '11 at 13:46
  • see apart from above mentioned field there are other fields also in the log file like **event text msg** I wanted to filter this field – Vikram Ranabhatt May 13 '11 at 13:49
  • If you use C++ and want a nice logger mechanism maybe you want to try log4cpp.sourceforge.net. – ritter May 13 '11 at 13:35
  • @Chris_vr Can you be more specific? You want to filter during runtime or filter a log file that is already present? And what do you mean with 5 fields. Log4cxx accepts only two params. A Level and a message. – mkaes May 20 '11 at 15:45
  • I want to filter during run time.See I need store 5 five field in the log file.user can query all the five field based on MAcID or date and time or both the option and the result should return 1.MAcID 2. date and time 3.Command type 4.Status 5. Text Msg – Vikram Ranabhatt May 23 '11 at 04:10

2 Answers2

2

I faced once a similar problem than points 1 and 4. I read log4cxx code and I found a possible solution. A job mate tested the solution and progressed it. His conclusions can be found here.

We asked in the log4cxx mailing list if it was the right solution and this is the answer we got. I hope that helps.

javier-sanz
  • 2,504
  • 23
  • 23
0

I don't think that log4cxx is the right tools for your task, and I am not really sure if this can be done at all with log4cxx.

You can start with a custom appender and your own log level and your own filter.
Do get it running you need to set a log level do determine which filter field should be used and when ever you change the filter you need to clear the Filters and set a new one. Then you can extract the log string, search for your filter and let it decide if you want to output the log message or not.

mkaes
  • 13,781
  • 10
  • 52
  • 72
  • Is there any other way to do so.I mean is there other free third party free api I can use it for this purpose. – Vikram Ranabhatt May 23 '11 at 13:27
  • You could go with log4cxx. Always log your fields and try to filter the output with chainsaw. http://logging.apache.org/chainsaw/index.html. You can use regex to some decent filtering with it. – mkaes May 23 '11 at 14:02