Since Log4J2's org.apache.logging.log4j.core.layout.PatternLayout
Class is final
, I can't extend it to create headers for my CSV.
I referred docs, it doesn't provide info on how to extend existing Layout. http://logging.apache.org/log4j/2.x/manual/extending.html#Layouts
Previous approach of extending PatternLayout doesn't work.
My goal is to add header to log file & headers should be configured through configuration file for below log,
<File name="MttPerformance" fileName="logs\MyLog.csv" append="true">
<PatternLayout pattern="%d{dd MMM yyyy},%d{HH:mm:ss,SSS},%m%n"/>
</File>
<PatternLayout pattern="%d{dd MMM yyyy},%d{HH:mm:ss,SSS},%m%n" header="Date,Time,Inf,Time(ms)${sys:line.separator}"/>
Log4j2 has header tag..! https://logging.apache.org/log4j/2.x/manual/layouts.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With