How to copy my log4j logs to email using javamail API ans log4j
<p>I have created a xml validating tool with log4j logs to get the Error Details using java.
Now I need to mail the Entire Content of what I am getting in my log4j logfiles( with background color in mail).</p>

<p>Please guide me to achieve this,and I have attached the screenshot of my log4j logfile and email format.</p>

<p><a href="https://i.stack.imgur.com/sEZB4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sEZB4.jpg" alt="Screenshot for log and email"></a></p>

<p>Below are the piece of my java code.</p>

<p>Log 4j Properties:</p>

<pre><code>#Log to Console as STDOUT
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd 
HH:mm:ss}     %-5p %c %3x - %m%n
#Log to file FILE
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=D:\logfile.log
log4j.appender.file.DatePattern='.'dd/MM/yyyy
log4j.appender.file.append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern= %m%n
# LOG4J daily rolling log files configuration
log4j.rootLogger=DEBUG, RollingAppender
log4j.appender.RollingAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RollingAppender.File=D:\logfile.log
log4j.appender.RollingAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.RollingAppender.layout.ConversionPattern= %m%n
</code></pre>

<p>Code for java mail:</p>

<pre><code>MimeMessage message = new   
MimeMessage(session);                                   
m_toterr=validatexml.Total_err;
message.setFrom(new InternetAddress(from));   
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to1));
String htmlBody = "&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Page Title&lt;/title&gt;"
                        + "&lt;/head&gt;&lt;body&gt;&lt;center&gt;&lt;table " 
                        +"   border-width:5px;  "
                        +"   border-style:dotted;"
                        +"border-style: double;"
</code></pre>

<p>.
.
.
.</p>