You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by VERNIER Dominique <dv...@relaystar.com> on 2005/09/02 08:59:12 UTC

Add enviroment variable into PatternLayout

Hi,

I setup my application to receive email on error via STMPAppender. I
have multiple environment (Dev, Test, Staging and Production) and I
would like to have the environment name in the message.

I have an envionment variable target-environment on I tried to put it in
the parternLayout like:

		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern"
value="${target-environment} %d{HH:mm:ss} %-5p %.11X{StationConfig}
%.20c{1} - %.100m%n"/>
		</layout>

But it doesn't work, the logger crashes.

Does somebody have an idea or should I extend the SMTPAppender to add
this environment variable as parameter and insert it in the message
myself.

Regards
Dominique