[logback-user] HTMLLayout programmatically - How?

Michael Wiedau Michael.Wiedau at avt.rwth-aachen.de
Thu Feb 28 14:07:07 CET 2013


Dear all,

 

I have a question to HTMLLayout. 

I have written the following code: 

 

           LayoutWrappingEncoder htmlEncoder = new LayoutWrappingEncoder();

           HTMLLayout htmlLayout = new HTMLLayout();

           htmlLayout.setPattern("%relative%thread%mdc%level%logger%msg");

           htmlLayout.start();

           htmlEncoder.setContext(loggerContext);

           htmlEncoder.setLayout(htmlLayout);

           htmlEncoder.start();

           

           PatternLayoutEncoder encoder = new PatternLayoutEncoder();

           encoder.setContext(loggerContext);

           encoder.setPattern("%r %thread %level - %msg%n");

           encoder.start();

 

              

              fileAppender.setContext(this.loggerContext);

           fileAppender.setFile(FilenameUtils.concat(storeLocation,
"logFile.log.html"));

           fileAppender.setName("File Validation Log");

           fileAppender.setEncoder(htmlEncoder);

 

           fileAppender.start();

           this.logger.addAppender(fileAppender);

           

           StatusPrinter.print(loggerContext);

 

But it does not log anything. It creates a html file but only includes the
header line. 

Using the "encoder" it works fine. 

I don't want to use Logfiles and do this programmatically. 

Can anyone give me a hint what is wrong here?

 

Best regards,

Michael

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130228/482dc894/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5504 bytes
Desc: not available
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20130228/482dc894/attachment.p7s>


More information about the Logback-user mailing list