In the previous example we have studied that there are many Layout classes for displaying logging output in the desired format. In this section we are going to describe you one of them, SimpleLayout, the simplest of all.
Example of SimpleLayout log message is as
"Debug - and debug log message".
In our example of SimpleLayoutExample we are using FileAppender to append the output log message to a log file "SimpleLog.log". First we have created an object of Logger class by calling static method getLogger(). After creating FileAppender object we have added this appneder to our logger with the addAppender() method.
Here is the example code of SimpleLayoutExample class:
After creating and executing this SimpleLayoutExample class file you will get SimpleLog.log file with the following Log event messages.
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: September 12, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles