Using log4j to send email reports via the SMTPAppender

后端 未结 3 1170
粉色の甜心
粉色の甜心 2020-12-02 23:58

I\'m trying to use log4j to send emailable reports that contain the logging statements from a background process. I want one email sent for each process run, not one email

3条回答
  •  盖世英雄少女心
    2020-12-03 00:30

    Log4j 2.x onwards, the following configuration for log4j.xml can be used. It's pretty straightforward and can be used to send emails.

    You need to edit it and enter your smtp host, username, password, port and subject.

    
    
        
    
            
                Mail1
                SUBJECT
                TO_EMAIL
                FROM_EMAIL
                smtp.gmail.com
                487
                false
                username
                password
                smtps
                
                
            
        
        
            
                
            
        
    
    

    Reference: Log4j SMTP Appender

提交回复
热议问题