Hi,

I use log4j2 beta 6 and I would like to add a prefix to all my messages.
This prefix is passed to the constructor parameter and it depends on the
instance of the class. So we're at the object level (not class or thread).

For example, I have an A class instantiated like new A(152), so when I use
log.error("message") on this class, 152: is written just before the
message. For new A(155),155: will be displayed instead.

I try to use ThreadContext.put on the constructor but, I don't know when
logger wiil be call consequently the prefix is set to the last
ThreadContext called but that does not necessarily correspond to the
correct class instance
I ask to stackoverflow (
http://stackoverflow.com/questions/16723016/how-do-i-add-a-prefix-to-log4j-messages-at-the-object-level)
but
it has not solved my problem.

-- 
Lucie

Reply via email to