E
etienno
Hi,
I have a issu to solve regarding Log4J (or any other logger). This
problem is probably quite common in a multi-layer architecture. I have
a multilayer software, running on the same JVM (not really multilayer
here thaugh, anyway).
Lets say my layers are : View (HttpRequest), Business, Delegates, web
service...
The problem is that the logger from the View knows well the "UserId"
using the system, but from the Business to the Web Service Layers it
lost the "UserId" data because it doesn't need it for its process. But
I would like the logger at the Web Service Layer to log a debug trace
with the "UserId"! A need that because my system admin need a nice log
to do his job efficiently.
View (HttpRequest), [doJob(UserId);]
Business, [doJob()]
Delegates, [doJob()]
web service... [doJob()] -->logger.debug("My userId is..." + "doing web
service job");
I have checked many possibility, I want to know what would be the best
pattern for this issu:
1- Pass the UserId in the parameter: This is obviouly bad.
--- theses next solutions has not be thinked a lot...
2- Put the a kind of ThreadId as a key in a static Map and store
UserData...: I dont like that at first glance.
3- Use some listener and Event handling to get the logs events from the
lower layer and log it from the upper layer. Use ThreadId as a key of
some sort. I prefer that...
It must be a very common problem. There is not common library for this
issue?
I will check at TheServerSide.com...
Thanks for answering
Etienne
Paris
I have a issu to solve regarding Log4J (or any other logger). This
problem is probably quite common in a multi-layer architecture. I have
a multilayer software, running on the same JVM (not really multilayer
here thaugh, anyway).
Lets say my layers are : View (HttpRequest), Business, Delegates, web
service...
The problem is that the logger from the View knows well the "UserId"
using the system, but from the Business to the Web Service Layers it
lost the "UserId" data because it doesn't need it for its process. But
I would like the logger at the Web Service Layer to log a debug trace
with the "UserId"! A need that because my system admin need a nice log
to do his job efficiently.
View (HttpRequest), [doJob(UserId);]
Business, [doJob()]
Delegates, [doJob()]
web service... [doJob()] -->logger.debug("My userId is..." + "doing web
service job");
I have checked many possibility, I want to know what would be the best
pattern for this issu:
1- Pass the UserId in the parameter: This is obviouly bad.
--- theses next solutions has not be thinked a lot...
2- Put the a kind of ThreadId as a key in a static Map and store
UserData...: I dont like that at first glance.
3- Use some listener and Event handling to get the logs events from the
lower layer and log it from the upper layer. Use ThreadId as a key of
some sort. I prefer that...
It must be a very common problem. There is not common library for this
issue?
I will check at TheServerSide.com...
Thanks for answering
Etienne
Paris