The ${foo} syntax was added as a quick fix to allow environment
variables to be used.
The preferred way of using an environment variable is to use a
PatternString with %env{foo}
<file type="log4net.Util.PatternString"
value="%env{OUTPATH}\log-file.txt" />
However to be backward compatible we must still support the ${foo}
syntax.
I don't think that we should enhance the ${foo} syntax further as we
should really be encouraging users to use the PatternString instead.
Having said that I don't see any problem storing values on the
Repository object and having a pattern extract them. The Repository
already has a Properties map, however this is not examined by the
current %property patterns. The Reporitory's Properties is not much used
at the moment, but does provide a convenient place for Repository wide
custom properties.
I think we could easily add a method for the XmlConfigurator to set
properties on the Repository and either update the %env pattern or add a
new pattern that looks in this properties map.
What do you think?
Nicko
> -----Original Message-----
> From: Ron Grabowski [mailto:[EMAIL PROTECTED]
> Sent: 06 October 2005 03:52
> To: [email protected]
> Subject: Extending support for ${foo} notation
>
> The ${foo} notation searches the environment for a key and
> uses its value. I wonder if it would be useful to introduce
> the idea of a local environment that would allow locally
> scoped temporary environment
> variables:
>
> <log4net>
> <localEnvironment name="LOG4NET_PATH" value="c:\logs\staging" />
> <localEnvironment name="DEFAULT_LAYOUT" value="%message%newline" />
> <appender name="FileAppender" type="log4net.Appender.FileAppender">
> <file value="${LOG4NET_PATH}\log.txt" />
> <layout
> type="log4net.Layout.PatternLayout"
> value="${DEFAULT_LAYOUT}" />
> </appender>
>
> If the item was not found in the local environment,
> System.Environment would be searched.
>
> Comments?
>
> - Ron
>