I have a java application. I am using a log formater object. All log messages should have this object. for example
log.debug(new LogFormatter(x,y,z))
But I have to create new LogFormatter object each and everything i want to log. If I use static method for example
log.debug(LogFormatter.format(x,y,z))
Than I don’t have to create new objects. But in a multithreaded application would it work right.
if two threads call with diff values, woud the logging get messed up.
Or is thread local the best way to go
I would use
as the formatter is immutable it can be shared.