[ 
https://issues.apache.org/jira/browse/LOG4J2-1450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15356507#comment-15356507
 ] 

Remko Popma commented on LOG4J2-1450:
-------------------------------------

Apart from the fact that the subject lookup may have an issue, it sounds like 
the approach of using runtime lookups to dynamically change the SMTP Appender 
settings is not a good approach because you may also want to change the 
{{javax.mail.Session}} settings.

In that case, reloading the configuration is probably the way to go. One way 
you could implement this is to have a "template" log4j2.xml configuration with 
placeholders for the SMTP Appender settings. When the user uses the separate 
app to configure the SMTP settings, use this template to generate the new 
config text. You can then either overwrite the existing configuration file, or 
use the [Log4j 2 JMX 
interface|https://logging.apache.org/log4j/2.x/manual/jmx.html] to replace the 
configuration text in memory.

> SMTPAppender support for runtime lookup
> ---------------------------------------
>
>                 Key: LOG4J2-1450
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1450
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Benjamin Jaton
>
> http://logging.apache.org/log4j/2.x/manual/configuration.html#RuntimeLookup
> "Not all elements support resolving variables at runtime."
> The SMTPAppender doesn't support using:
> {noformat}{
>         "type" : "smtp",
>         "name" : "EmailAppender",
>         "subject" : "$${email.subject}",
>         "to" : "$${email.recipient}",
>         "from" : "$${email.from}",
>         "smtpProtocol" : "$${email.smtp.protocol}",
>         "smtpHost" : "$${email.smtp.host}",
>         "smtpPort" : "$${email.smtp.port}",
>         "smtpUsername" : "$${email.smtp.username}",
>         "smtpPassword" : "$${email.smtp.password}"
> }{noformat}
> However that would be very useful so that the user doesn't have to reload the 
> whole log4j2 configuration when the SMTP parameters have changed.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to