Achieving a specific format in Apache Log4j

106 views Asked by At

I want to have following format in my log file in Log4j

{date:yyyy-MM-dd HH:mm:ss:SSS} {level} [{thread name- thread Id}]:[{file}:{line}] {message}

How do I go about it?

1

There are 1 answers

1
hveiga On BEST ANSWER

You should take a look to the javadoc about the pattern layout. You can find the javadoc for log4j 1.2.17 here.

However, I would recommend you to use Apache Log4j2 (even if it is currently in beta) or LogBack. Log4j2 provides many more options to do different pattern layouts, you can check it here