Vikram Ranabhatt
Vikram Ranabhatt

Reputation: 7630

Logging and filtering using log4cxx

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?

Upvotes: 4

Views: 2504

Answers (2)

javier-sanz
javier-sanz

Reputation: 2524

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.

Upvotes: 2

mkaes
mkaes

Reputation: 14129

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.

Upvotes: 0

Related Questions