Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.LoggingEvent


  {
    AdtMessage adtmsg;
    TLogQueue datalog;
   
      Priority priority = null;
      LoggingEvent  event;
      String        fqnOfCategoryClass = "fqnOfCategoryClass";
      Throwable     myThrowable = null;
   
    try{
     
      // convert the JMS message in the Oracle type TLogQueue
      adtmsg = (AdtMessage) JmsMsg;
        datalog =(TLogQueue)(adtmsg.getAdtPayload());
         
          Category logger = Logger.getLogger(datalog.getLuser()+ "." +datalog.getLsection());
         
          // convert the PL/SQL log level in LOG4J level
          Level level = (DynamicLevel)htLevels.get(new Integer (datalog.getLlevel().intValue()));
 
          if (level != null) {
             priority = level;
          } else {
            priority = Level.toLevel("UNDEFINED",  Level.ERROR );
          }   
         
          // create the LOG4J event
          NDC.push("DatabaseLoginDate:"+datalog.getLdate()) ;
          event = new LoggingEvent(fqnOfCategoryClass,
                                   logger,
                                   priority,
                                   datalog.getLtext(),
                                   myThrowable);
 
View Full Code Here


    Throwable t = new UnsupportedOperationException("Test");
    logger.throwing(t);
    logger.throwing(XLogger.Level.DEBUG,t);
    assertEquals(2, listAppender.list.size());
    verifyWithException((LoggingEvent) listAppender.list.get(0), "throwing", t);
    LoggingEvent event = (LoggingEvent)listAppender.list.get(1);
    verifyWithLevelAndException(event, XLogger.Level.DEBUG,
        "throwing", t);
  }
View Full Code Here

    logger.debug("hello");

    assertEquals(2, listAppender.list.size());

    {
      LoggingEvent e = listAppender.list.get(0);
      LocationInfo li = e.getLocationInformation();
      assertEquals(this.getClass().getName(), li.getClassName());
      assertEquals(""+line, li.getLineNumber());
    }
   
    {
      LoggingEvent e = listAppender.list.get(1);
      LocationInfo li = e.getLocationInformation();
      assertEquals(this.getClass().getName(), li.getClassName());
      assertEquals(""+(line+1), li.getLineNumber());
    }

  }
View Full Code Here

    data[1].put("FileName", "/etc/hosts");
    EventLogger.logEvent(data[1]);

    assertEquals(2, listAppender.list.size());
    for (int i=0; i < 2; ++i) {
      LoggingEvent event = listAppender.list.get(i);
      verify(event, data[i].toXML());
      LocationInfo li = event.getLocationInformation();
      assertEquals(this.getClass().getName(), li.getClassName());
      assertEquals(event.getMDC("hostname"), "localhost");
    }
  }
View Full Code Here

  public void testSmoke() {
    SLF4JBridgeHandler.install();
    String msg = "msg";
    julLogger.info(msg);
    assertEquals(1, listAppender.list.size());
    LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
    assertEquals(LOGGER_NAME, le.getLoggerName());
    assertEquals(msg, le.getMessage());

    // get the location info in the event.
    // Note that this must have been computed previously
    // within an appender for the following assertion to
    // work properly
    LocationInfo li = le.getLocationInformation();
    System.out.println(li.fullInfo);
    assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
    assertEquals("testSmoke", li.getMethodName());
  }
View Full Code Here

    java.util.logging.Logger julResourceBundleLogger = java.util.logging.Logger
        .getLogger("yay", resourceBundleName);

    julResourceBundleLogger.info(msg);
    assertEquals(1, listAppender.list.size());
    LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
    assertEquals(LOGGER_NAME, le.getLoggerName());
    assertEquals(expectedMsg, le.getMessage());
  }
View Full Code Here

    julLogger.log(Level.INFO, resourceKey3, params3)// 4th log

    assertEquals(4, listAppender.list.size());

    LoggingEvent le = null;

    le = (LoggingEvent) listAppender.list.get(0);
    assertEquals("foo", le.getLoggerName());
    assertEquals(expectedMsg1, le.getMessage());

    le = (LoggingEvent) listAppender.list.get(1);
    assertEquals("foo", le.getLoggerName());
    assertEquals(expectedMsg2, le.getMessage());

    le = (LoggingEvent) listAppender.list.get(2);
    assertEquals("foo", le.getLoggerName());
    assertEquals(expectedMsg3, le.getMessage());

    le = (LoggingEvent) listAppender.list.get(3);
    assertEquals("yay", le.getLoggerName());
    assertEquals(expectedMsg3, le.getMessage());
  }
View Full Code Here

    assertEquals("yay", le.getLoggerName());
    assertEquals(expectedMsg3, le.getMessage());
  }

  void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
    LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
    assertEquals(expectedLevel, le.getLevel());
  }
View Full Code Here

  public void printLog(Printer printer) throws RegainException {
    synchronized (mCache) {
      Iterator iter = mCache.iterator();
      while (iter.hasNext()) {
        Object[] itemArr = (Object[]) iter.next();
        LoggingEvent evt = (LoggingEvent) itemArr[0];
        String formattedEvt = (String) itemArr[1];

        if (formattedEvt == null) {
          formattedEvt = getLayout().format(evt);
          itemArr[1] = formattedEvt;
View Full Code Here

      final Appender forcedAppender = getForcedAppender();
     
      // force the logging and modify the log message (the latter might return the original message)
      if (forcedAppender!=null) {
        // only call the forced appender
        forcedAppender.doAppend(new LoggingEvent(fQCN, this, priority, modifyLogMessage(message), t));
      } else {
        // go via the normal appenders
        forcedLog(fQCN, priority, modifyLogMessage(message), t);
      }
   
View Full Code Here

TOP

Related Classes of org.apache.log4j.spi.LoggingEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.