I want to use MDC to set a context in my program, and then be able to set a filter in the config file to only show messages from a logger in a certain context.
MDC mdc;
mdc.put("fieldName", "foo");
LOG4CPLUS_DEBUG(log, "ABC");
mdc.put("fieldName", "bar");
LOG4CPLUS_DEBUG(log, "XYZ");
I only want to print from log
when "fieldName"
is "bar"
, so only "XYZ" should be printed to my log.
In log4j this can be done using the XML format config file with filters. Can log4cplus use an XML config file? Can filters like this be set up in the XML log?
Also, is there a way to make log4cplus verbose, so I can see if it is finding my config file, and if it is able to read it, etc.
I am having trouble finding even one example of a log4cplus XML config file or how to read one.