Reputation: 23
I am using Log4C and enjoy the functionality but is lacking one feature: Multiple appenders per category.
Quote from http://log4c.sourceforge.net/: "Future versions will handle multiple appenders per category".
I need to output a single log message to multiple locations and formats (XML file, text file and stdout)
I've created 3 appenders with appropriate formats and they all work fine on their own but if I try to assign all three to a single category in the Log4crc config file, it will only do the first entry. e.g.
<category name="log.plugin" priority="debug" appender="file" />
<category name="log.plugin" priority="debug" appender="xml" />
<category name="log.plugin" priority="debug" appender="stdout"/>
In this case it will only write to the "file" appender. Like wise if the "xml" appender was first on the list it will only write to the "xml" appender.
Has anyone successfully implemented multiple appenders per category? or Has a suitable workaround?
The one way I've found is to it to make long category names and take advantage of category hierarchy. e.g.
<category name="log.plugin." priority="debug" appender="file" />
<category name="log.plugin.foo" priority="debug" appender="xml" />
<category name="log.plugin.foo.bar" priority="debug" appender="stdout"/>
Then if I reference "log.plugin.foo.bar" when I initialize the logger, it will write to all three locations. I don't really like this workaround due to the fact it clutters up the configuration file as I will have many categories needing to write to these three appenders.
Thanks for any help!
Upvotes: 2
Views: 679