I have done the same task by this :
In logback.xml file, Add this :
property resource="filename.properties"
<username>${username}</username>
<password>${password}</password>
<to>${email1}</to>
<from>${from}</from>
Question
I think I hit a playframework - logback specific bug, perhaps not, any assistance would be great!
I' ve needed an email appender to send me emails when an error occures.
So I created a simple one with all the properties defined within:
<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
<smtpHost>myhost</smtpHost>
<smtpPort>25</smtpPort>
<STARTTLS>true</STARTTLS>
<username>username</username>
<password>pass</password>
<to>to</to>
<from>from</from>
<subject>Error: %logger{20} - %m</subject>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date %-5level %logger{35} - %message%n</pattern>
</layout>
</appender>
This worked fine.
Then I wanted to refactor all of the properties cause obviously i don't want to commit passwords and stuff like that to the source control.
So i replaced all the properties by ${propname} and added this at the begining
<property file="conf/mail.properties"/>
now emails are not sent anymore.
I debugged and printed out the properties and saw that the problem has to do with quotes.
my to/from are email addresses, when I put them in my properties file I need to surround them with quotes otherwise i get an error like this:
Caused by: com.typesafe.config.ConfigException$Parse: /myconfdir../mail.properties: 19: Reserved character '@' is not allowed outside quotes
Also my password has a "+" symbol in it and if it's unquoted in the properties file i get the same error.
When debugging with these quoted values I see that the quote is included inside them.
So an email is trying to be sent to "a@b.com" and no a@b.com.
Same for from field and for the password.
So obviously it doesn't work.
Any idea how to prevent this?
Solution
I have done the same task by this :
In logback.xml file, Add this :
property resource="filename.properties"
<username>${username}</username>
<password>${password}</password>
<to>${email1}</to>
<from>${from}</from>