Log Formatting using log4j.properties File - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Community

Log Formatting using log4j.properties File

Share This



If you want to generate logging information, you should specify a format. In this context, you should use a Layout for logging information. The following configuration file has been prepared using PatternLayout.



log = D:\\log4j log4j.rootLogger = DEBUG, FILE log4j.appender.FILE=org.apache.log4j.FileAppender log4j.appender.FILE.File=${log}\\log.out log4j.appender.FILE.layout=org.apache.log4j.PatternLayout log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd}-%t-%x-%-5p-%-10c:%m%n


If you want to generate logging information in an HTML format, you can use HTMLLayout as shown below.



log = D:\\log4j log4j.rootLogger = DEBUG, FILE log4j.appender.FILE=org.apache.log4j.FileAppender log4j.appender.FILE.File=${log}\\htmlLayout.html log4j.appender.FILE.layout=org.apache.log4j.HTMLLayout log4j.appender.FILE.layout.Title=HTML Layout Example log4j.appender.FILE.layout.LocationInfo=true


Happy Exploring!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.