在log4j.properties文件SMTP Appender中隐藏或加密密码 [英] Hiding or Encrypting Password in log4j.properties file SMTP Appender

查看:209
本文介绍了在log4j.properties文件SMTP Appender中隐藏或加密密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自定义gmail smtp附件从我的gmail帐户发送错误日志. 按照说明进行操作: http://www.tgerm.com/2010 /05/log4j-smtpappender-gmail-custom.html -一切正常. 除了一件事: 在我的log4j.properties中:我不想输入密码"log4j.appender.EMAIL.SMTPPassword = somepass",以便可以与队友共享此项目.有人有建议吗?

I am using custom gmail smtp appendar for sending error logs from my gmail account. Following the instructions: http://www.tgerm.com/2010/05/log4j-smtpappender-gmail-custom.html - Everything works great. Except one thing: In my log4j.properties: I don't want to type my password "log4j.appender.EMAIL.SMTPPassword=somepass" so that I can share this project with my team mates. Does anyone have a suggestion ?

下面是log4j.properties部分:

Below is log4j.properties part:

log4j.appender.EMAIL=com.tgerm.log4j.appender.GmailSMTPAppender
log4j.appender.EMAIL.SMTPHost=smtp.gmail.com
log4j.appender.EMAIL.SMTPDebug=true
log4j.appender.EMAIL.From=from@gmail.com
log4j.appender.EMAIL.To=to@tgerm.com
log4j.appender.EMAIL.SMTPUsername=smtpuser@gmail.com
log4j.appender.EMAIL.SMTPPassword=somepass //this is the problematic part
log4j.appender.EMAIL.Subject=Email Notification from Gmail SMTP Appender
log4j.appender.EMAIL.cc=cc@gmail.com
log4j.appender.EMAIL.layout=org.apache.log4j.PatternLayout
log4j.appender.EMAIL.layout.ConversionPattern=%p %t %c - %m%n
log4j.appender.EMAIL.BufferSize=1

推荐答案

对于初学者:请不要使用您的个人电子邮件地址-创建一个要与您的团队成员共享的新帐户.

For starters: don't use your personal email address - create a new account to be shared with your team members.

如果您仍要加密,请将加密的信息放在单独的属性或xml文件中,编写代码以对其进行加密和解密,然后以编程方式配置log4j的该部分.

If you still want to encrypt, put the encrypted information in a separate properties or xml file, write code to encrypt and decrypt it, and configure that portion of log4j programatically.

(而且,如gdt所述,请记住,如果应用程序可以解密密码,其他应用程序也可以.没有100%安全的解决方案.保护文件访问权限通常比加密更有效.)

(And, as gdt says below, remember, if the application can decrypt the password, others can too. There is no 100% safe solution. Protecting the file access permissions is often more effective than encrypting.)

这篇关于在log4j.properties文件SMTP Appender中隐藏或加密密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆