I'm using logback in spring-boot 2.2.5.RELEASE
, I need to get the log object in memory so I can manipulate the info and proccess it.
What I would expect is something like this.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component
public class application {
Logger logger = LoggerFactory.getLogger(application.class);
public void executeTask(Integer queryMinutes) {
logger.info(INICIO_TRANSACCION, metodo);
try {
//Do something
//Log informative messages
} catch (DBException e) {
//Log ERROR messages
logger.error(MENSAJE_EXCEPCION + e, e);
logger.info(ROLBACK_TRANSACCION);
} finally {
//Here I need to call a method to further process the info printed in the log something like
logger.getMessage();
logger.getLineNumber();
logger.getThread();
callSomeMethod(logger);
logger.info(TIEMPO_PROCESO, (System.currentTimeMillis() - tiempoInicial));
logger.info(FIN_TRANSACCION, metodo);
}
}
}
I know that when you work with appenders we usually define a ILoggingEvent
object and this give access to logger.getMessage()
and more,
The question is how to get the log object in my java class so I can access the properties.