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

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

Took a quick look at the code. Looks like {{subject}} already supports $$ 
runtime lookups (Benjamin, could you verify this?).

The following attributes are used for each email that is sent, and it should be 
possible to support runtime lookups for these attributes:
* from
* replyto
* to
* cc
* bcc
* subject (already a runtime lookup)

However, the current SMTPManagerFactory implementation creates a 
{{javax.mail.Session}} when the configuration is parsed and the appender is 
initialized. This makes sense from a performance perspective since creating a 
Session is too expensive to do for each log event. Since the Session is created 
only once, these attributes are read only once at initialization time...
* protocol
* host
* port
* username
* password

Benjamin, can you give us some more background on whether your use case 
requires runtime lookups for the {{javax.mail.Session}} -related attributes?

> 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