How to get the current real-time log data from log4js?

120 Views Asked by At

I have a requirement now, when log4js is printing logs, I need to get the current real-time log data, a complete piece of log information (log4js processed).Does log4js has such an interface?

logger.error("Cheese is too ripe!");

When the code is executed,I get

[2020-07-15T11:19:07.452] [ERROR] cheese - Cheese is too ripe!

How can I get this whole string from log4js in my code rather than 'Cheese is too ripe'

1

There are 1 best solutions below

0
On

I just find a way to solve it by use recording appender. Use replay and layout method to make the same log sentence.