Note that there are some explanatory texts on larger screens.

plurals
  1. POLogging bean id into log4j logfile without BeanNameAware interface
    primarykey
    data
    text
    <p>Given a set of classes wired together by spring. There are several classes that are used with different configuration in multiple instances in the environment. They have different beanid of course.</p> <p>The problems:</p> <ul> <li>When they make log entries, we dont know exactly which bean made the log, since the log4j displays the classname only</li> <li>I know that I could use logger instantiated by spring InitializationBean+BeanNameAware interface methods, but I do not want to do it, since I do not want to implement them in all classes</li> </ul> <p>The solution could be:</p> <ul> <li>Having some effect on bean factory to store the id of the beans in a map with the bean reference (key is the ref, name is the value)</li> <li>Creating an aspect to be applied on every method, that would set an "BeanName" MDC entry in Log4j before the call, and would restore it to the previous value after the call. Meanwhile the previous beannames could be stored in a threadlocal in a stack.</li> </ul> <p>The questions:</p> <ul> <li>How can I change/configure the bean factory to do this trick for me? Is there any customization point I could use to this aim?</li> <li>How can I avoid memory leaks in the map in the beanid registry? Maybe the registry is not needed at all, if somehow spring can look up the id for a reference.</li> <li>Do you have any better idea, that would not result in changing ten thousand classes?</li> </ul> <p>Thanks in advance.</p> <p>UPDATE: - Does anyone have solution for the prototype beans?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload