Is it possible to create a log4net custom PatternLayoutConverter that allows an \"index\" value to be configured? I know about the \"property\" conversion string that allow
I did not try it but this should work. In log4net you can pass an option string to a pattern converter like this:
%converterName{converterOptions}
The date pattern converter for instance can be used like this:
%date{HH:mm:ss,fff}
This means you can write your pattern converter the way you suggested. A simple example for such a converter can be found here.
In the Convert
method you can access the the property string with the property 'Option' (defined in the PatternConverter
class) and use the thread context to get the desired entry from the dictionary. You can also implement the IOptionHandler
interface if your options consist of more then just the dictionary key: This way you can parse the options upon activation of the log4net configuration.