Back Forum Reply New

How can i Inject a FrontEnd Attribute in Persistence Layer

I want to know how can i inject a frontend attribute , like a jsessionId , in the Persistence layer , example  a Customer DAO.

actually , what i need is insert the user session id in all logs messages! i tried to pass this attribute to logback API without sucess! so , i came here to ask you guys if i can use spring AOP or something else to pass this attribute to all layers.

more over , i have in my system about 98 DAO without correct log

Thanks!

enviroment: spring 2.5 , jsf 1.1 , iceFaces 1.83 , java 1.6 , hibernate , tomcat 6.


Originally Posted by Gustavo Nevadoactually , what i need is insert the user session ID in all logs messages

Take a look at MDC ( Mapped Diagnostic Context ): manual/mdc.html ( it is also there in native log4j )

While the MDC manages contextual information on a per thread basis, what you can do is have a request scoped bean which would have from session autowired:Code:
@Autowired
private fromSession session;
And would have set the session ID to the MDC. This way, you'll have this ID available in all the logging throughout this thread.

/Anatoly
¥
Back Forum Reply New