If you're using log4j 1.3, you can use reflectionFilter and pass JavaBeans into the debug/info call instead of a string, and it will build properties for each attribute of the bean.
There is also MapFilter which works the same way, but for a map (pass a map into logger.info() and it will build properties for each entry in the map. ReflectionFilter: http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk/src/java/org/apache/log4j/filter/ReflectionFilter.java?view=markup MapFilter: http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk/src/java/org/apache/log4j/filter/MapFilter.java?view=markup Scott -----Original Message----- From: Bender Heri [mailto:[EMAIL PROTECTED] Sent: Thu 12/1/2005 10:38 AM To: Log4J Users List Subject: RE: Putting additional info in LoggingEvent MDC is only a tool which, amongst others, can be used to separate context's. You didnt yet explain what additional info you want have to be logged. Is it only the name of the module/component? And I dont understand this: <snip> But I have some threads which interacts with different modules of my app. <snip> vs. <snip> Since my app have single thread accessing different components sequentially <snip> The first says to me, that you have more than one thread. Thread A is sometimes part of module x, sometimes part of module Y. The second say to me, that you only have one thread in your application which operates sequentially on different modules. Does this (or these) thread(s) know in which module it is working? If that is the case, you can can put the desired information into the MDC before each call to log (or each series of calls). Annother idea: The object which you pass to a logging call (lets say myLog.INFO() ) is a Object and not a String. Log4J knows how to render Strings (this is the message within the layout), but you are free to pass any other self written class with all the information you need. By configuration you define a renderer class (also self written, impementing ObjectRenderer) which is able to render your passed class. This rendering class returns then the rendered message to the log4J framework: <renderer renderedClass="your.passed.class" renderingClass="your.renderer"/> Heri > -----Original Message----- > From: George Sebastian [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 01, 2005 3:02 PM > To: [email protected] > Subject: Putting additional info in LoggingEvent > > > Hi > I have a requirement for the detailed logging of an application. > > And my application consist of different modules and each > module is loaded by > a single process. > > There are also different threads running with the application > > But I have some threads which interacts with different > modules of my app. > > I need each module is some what big (but runs in a single > process) so I like > to have some common naming (like component name) for a log > request so that i > can easily identify from which module the request came from. > > How can I put such a kind of information using log4j's LoggingEvent. > > With very my little knowledge I feel like the MDC and NDC > cannot be used > here as they are defined per thread (Since my app have single > thread accessing different components sequentially. > > Can someone please correct me if I am wrong. > > If i am right is there any other solution to this problem. > > Like extending LoggingEvent to put my own custom event or so > > Please help > > Thanks > -George Sebastian > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
