log4net SDK Reference

OptionConverter.SubstituteVariables Method 

Performs variable substitution in string val from the values of keys found in props.

[Visual Basic]
Public Shared Function SubstituteVariables( _
   ByVal value As String, _
   ByVal props As IDictionary _
) As String
[C#]
public static string SubstituteVariables(
   string value,
   IDictionary props
);

Parameters

value
The string on which variable substitution is performed.
props
The dictionary to use to lookup variables.

Return Value

The result of the substitutions.

Remarks

The variable substitution delimiters are ${ and }.

For example, if props contains key=value, then the call

[C#]
string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");

will set the variable s to "Value of key is value.".

If no value could be found for the specified key, then substitution defaults to an empty string.

For example, if system properties contains no value for the key "nonExistentKey", then the call

[C#]
string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");

will set s to "Value of nonExistentKey is []".

An Exception is thrown if value contains a start delimiter "${" which is not balanced by a stop delimiter "}".

See Also

OptionConverter Class | log4net.Util Namespace