Home > Net >  How to add variables to appender in log4j2?
How to add variables to appender in log4j2?

Time:02-28

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')"/>

CodePudding user response:

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.

  • Related