In my application, I use a pre determined log messages, something like this:
MESSAGE_ID PROCESS_ID This process is running
I would like to use a JDBC Appender and split my message in three, to get put each part in a particular SQL column.
Is this possible? And How?
Thanks a lot!
One idea is to use the ThreadContext to carry the message ID and process ID, and declare jdbc columns for each item like this:
<Column name="MESSAGE" pattern="%message" />
<Column name="MESSAGE_ID" pattern="%X{messageID}" />
<Column name="PROCESS_ID" pattern="%X{processID}" />
In your code you set the values like this:
ThreadContext.put("messageID", UUID.randomUUID().toString();
ThreadContext.put("processID", getProcessId());
...
logger.debug("this process is running");
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.