How to add variables to appender in log4j2?

459 Views Asked by At

is there way to add variables from code to appender? e.g. <param name="sql" value="INSERT INTO logs(name,log,log_lvl,log_date) VALUES(" + myClass.getUser().getName() +",'%m','%p','%d')"/>

1

There are 1 best solutions below

0
queeg On BEST ANSWER

I think you are trying to configure Log4j2 with Java code. Check out Programmatic Configuration. It also covers configuring appenders, which is the level at which you can define the appender's sql parameter if you so wish.