Logback の定義内で、次のSMTPAppender
ようにメール構成情報を指定できます。
<smtpHost>my.smtp.host</smtpHost>
<to>john.smith@example.com</to>
<from>no-reply@example.com</from>
<username>my_smtp_user</username>
<password>my_smtp_password</password>
<subject>%logger{20} - %m</subject>
フィールドをハードコーディングする代わりに<to>john.smith@example.com</to>
、Java アプリが実行されているアカウント/マシンのローカル ユーザー名を取得したいと考えています。たとえば、Ubuntu のユーザー名が の場合、フィールドticketMonster
は次のようになります。<to>
<to>ticketMonster@example.com</to>
または、オペレーティング システムのユーザー名が の場合はbgates
、次のようにします。
<to>bgates@example.com</to>
したがって、動的なユーザー名の評価を探しています。私は試した:
<to>${username}@example.com</to>
しかし、それはうまくいきません...アイデアや提案はありますか? 前もって感謝します!