In this part of Log4j tutorial we are going to discuss about the TTCCLayout which is extending DateLayout. It is another layout format for representing log events output.
It consists of following in its output log event:
For example in our output as "16 [main] INFO TTCCLayoutExample.class - First Log".
Note : One of the most important thing while using TTCCLayout is that "You should not use same TTCCLayout instance from the different appenders because it is not fully thread safe.
Here is the example code of TTCCLayoutExample file :
TTCCLayoutExample.java
import org.apache.log4j.*;
|
Output:
After compiling and executing TTCCLayoutExample.java you will have following output in your TTCCoutput.txt file.
| 16 [main] INFO TTCCLayoutExample.class - First Log 16 [main] INFO TTCCLayoutExample.class - Second Log 16 [main] INFO TTCCLayoutExample.class - Third Log 16 [main] INFO TTCCLayoutExample.class - Fourth Log 16 [main] INFO TTCCLayoutExample.class - See your TTCCoutput.txt 16 [main] INFO TTCCLayoutExample.class - Exiting from the Main method |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: TTCCLayout in Log4j
Post your Comment