If I want to continue on the path I've started... Any idea why it's not
working?
Any help would be greatly appreciated.
David
James Stauffer wrote:
>
> Have you tried setting the subject in the config file with a system
> property?
> log4j.appender.EMAIL.Subject=Fatal error encountered on
> ${currentEnvironment}
>
> You may only be able to do that with XML config.
>
> On 10/10/06, pantichd <[EMAIL PROTECTED]> wrote:
>>
>> Hello,
>>
>> My app is setup to send e-mails using the email appender when fatal log4j
>> messages are generated.
>>
>> I want to programatically prepend a string to the subject to indicate
>> what
>> "environment" (local, test, qa, prod) generated the message.
>>
>> If I step through the code below in my debugger I can see that the
>> appender's subject is changed and when I come through the servlet the 2nd
>> time I see that the modified subject is still there.
>>
>> However, the e-mail that arrives in my inbox does NOT have the modified
>> subject.
>>
>> Can anyone tell me what I'm doing wrong?
>>
>> log4j.properties snippet
>> ...
>> log4j.appender.EMAIL=org.apache.log4j.net.SMTPAppender
>> log4j.appender.EMAIL.Threshold=FATAL
>> log4j.appender.EMAIL.BufferSize=10
>> log4j.appender.EMAIL.Subject=Fatal error encountered
>> og4j.appender.EMAIL.layout=org.apache.log4j.PatternLayout
>> log4j.appender.EMAIL.layout.ConversionPattern=%d %c %-5p - %m%n
>> ...
>>
>> servlet code snippet
>> ...
>> ServletContext context = getServletContext();
>> String currEnv = (String)context.getAttribute("CurrentEnvironment");
>> SMTPAppender appender =
>> (SMTPAppender)Logger.getRootLogger().getAppender("EMAIL");
>> appender.setSubject(currEnv.toUpperCase()+": "+appender.getSubject());
>> log.fatal("There was a fatal error doing ...");
>> ...
>>
>> Thanks!l
>> --
>> View this message in context:
>> http://www.nabble.com/Can%27t-figure-out-how-to-change-email-appender-subject-dynamically-tf2416386.html#a6735604
>> Sent from the Log4j - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> James Stauffer http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Can%27t-figure-out-how-to-change-email-appender-subject-dynamically-tf2416386.html#a6740334
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]