Sorry about that, I hit send before I was done..


// Set up the MDC info so we can pull the variables out in the layouts
private void mapToMDC(Map map) {

//    MDC.getContext().putAll(map);

    Iterator itr = map.entrySet().iterator();

    while (itr.hasNext()) {

      Map.Entry entry = (Map.Entry)itr.next();

      MDC.put(entry.getKey().toString(), entry.getValue().toString());
    }

  }

ok, now...those are the helper functions..

// Code to log in the main server
// All requests go through this method
public void processLogRequest(Map evt) {



     String mesg = (String)evt.get("message");
     if (mesg.startsWith("ROLEVENT)) {
          Map m = new HashMap();
          try {
            StringUtils.createNVList(mesg.substring("ROLEVENT".length()),
";", m);

           } catch (Exception ex) {
            ex.printStackTrace();
          }

      // Set the MDC data
      mapToMDC(m);
     }

      // Create the category to log to
     Category c = Category.getInstance(((String)evt.get("category_name")));

     // Create the logging event from the fields in the Map (evt)
     LoggingEvent e = new LoggingEvent((String)evt.get("fqn"), c,
Priority.toPriority((String)evt.get("priority")),
                                      mesg, null);

     c.callAppenders(e);
}


In my XML mapping for the category i have:

<!-- Appender to the CONSOLE -->
     <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

          <layout class="org.apache.log4j.PatternLayout">
               <param name="ConversionPattern" value="%d %-5p %c [%t]
%X{user_id} %X{trans_id} - %m%n"/>
          </layout>


     </appender>

// Process the category
<category name="tim.mulle.test" >
     <appender-ref ref="CONSOLE" />
     <priority value="debug" />
</category>


I know the category I am receiving all the data becuase I can print it out,
it just isn't showing up on the console or in the files, etc.

Thanks,
 Tim
____________________________________________________
Timothy G. Mullé
Senior Software Architect
Reuters Valley Forge Solutions Center
1000 Madison Avenue
Norristown, PA 19403-2432

Phone: (610) 650-8600 x8340
Fax:      (610) 650-8170


                                                                                       
                                         
                    tmulle@moneyn                                                      
                                         
                    et.com               To:     [EMAIL PROTECTED]         
                                         
                                         cc:                                           
                                         
                    08/14/2001           Subject:     MDC "%X" still supported in 
latest release?                               
                    03:11 PM                                                           
                                         
                    Please                                                             
                                         
                    respond to                                                         
                                         
                    "LOG4J Users                                                       
                                         
                    Mailing List"                                                      
                                         
                                                                                       
                                         
                                                                                       
                                         




Hi,

     Is the %X{var} pattern still supported in the latest CVS build? I'm
trying to use it in the console appender and nothing is printing out.

I have a central logger, which when it receives logging request will try to
build the MDC data so I can use the %X{var} patterns.

Code:


// After receiving the log request

Map m = new HashMap();
      try {
        StringUtils.createNVList(mesg.substring("ROLEVENT".length()), ";",
m);
//        System.out.println("Map: " + m);
//        System.out.println("user_id: " + m.get("user_id"));
      } catch (Exception ex) {
        ex.printStackTrace();
      }

      // Set the MDC data
      mapToMDC(m);



private void mapToMDC(Map m) {

}
____________________________________________________
Timothy G. Mullé
Senior Software Architect
Reuters Valley Forge Solutions Center
1000 Madison Avenue
Norristown, PA 19403-2432

Phone: (610) 650-8600 x8340
Fax:      (610) 650-8170


---------------------------------------------------------------------
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]

Reply via email to