I Have JDBC appender configured in log4j2 xml
<JDBC name="databaseAppender" tableName="TL_FX_LOG">
<ConnectionFactory class="org.apache.jmeter.protocol.java.test.ConnectionFactory" method="getDatabaseConnection" />
<Column name="LOG_DATE" isEventTimestamp="true" />
<Column name="LOG_DESC" pattern="%message" />
<Column name="LOG_Batch" literal="someproperty" />
I need to set the value of literal(LOG_Batch) from Java Code.
Logger.debug("hello");
hello will be passed as %message value .But if i have a variable
String log_batch="test";
how to pass the log_batch variable value to JDBC appender.
Any pattern supported by PatternLayout can be used in a column pattern, so you could put that value in the ThreadContext map (ThreadContext.put("log_batch", "test");) in your code and insert it in the DB by configuring the appender with <Column name="LOG_Batch" pattern="%X{log_batch}" />.
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