Hi,
Currently i am working on log4j stuff for my application. I have a specific requirement of logging. I need to define a logger for a specific call hierarchy.
Meaning all the log messages of a specific call hierarchy should go to a specific appeneder.
I'm not sure this is possible if you're using typical logger declarations (named by Foo.class etc.) because there's no way to differentiate which "flow" a method call is participating in.
The only simple options I can think of quickly is to create new, additional loggers, each having the same name, and track application state through some mechanism, and track state machine progress throughout the app, and use that to determine which logger should be used. Depending on your application, it *might* be possible to encapsulate *all* of that logic using AOP, which might actually be a pretty slick solution if doable.
Venkata Sirish
Ranch Hand
Joined: Apr 09, 2007
Posts: 112
posted
0
Thanks for your reply. This is a stand alone application so i cannot make use of any HTTP scopes like session, application.
Please let me know if it can be achieved in any other way.
Um... my response didn't say anything about a web application or web app scopes--any Java program can store state in a globally-accessible location, either using a singleton, an in-memory DB, or whatever. Any solution would work, and could be used either directly by the app (means modifying source), or via AOP (no source modification, but minor "magic" if you're not aware how it's being done, which can cause maintenance issues).