Is there way to specify current line number in log4j pattern

Viewed 9772

I have a pattern to output to console and log file in following format:

[INFO]  17:31:12 - Checking Bla Bla Bla 
[INFO]  17:31:12 - ************* Starting *********************
[INFO]  17:31:12 - Testing Begins

is there any way to append line count so that it looks like:

[001][INFO] 17:31:12 - Checking Bla Bla Bla 
[002][INFO] 17:31:12 - ************* Starting *********************
[003][INFO] 17:31:12 - Testing Begins
3 Answers

Try below conversion pattern

ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Related