Package org.apache.log4j.spi

Examples of org.apache.log4j.spi.LoggingEvent


  //System.err.println("-------------------------Finalize called");
  // System.err.flush();
  //}

  public void run() {
  LoggingEvent event;
  Category remoteCategory;
  String strClientName;

  // Get the client name.
  InetAddress addr = socket.getInetAddress();
View Full Code Here


   * Tests formatted results.
   * @throws Exception if parser can not be constructed or source is not a valid XML document.
   */
  public void testFormat() throws Exception {
    Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest");
    LoggingEvent event =
      new LoggingEvent(
        "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null);
    XMLLayout layout = (XMLLayout) createLayout();
    String result = layout.format(event);
    Element parsedResult = parse(result);
    checkEventElement(parsedResult, event);
View Full Code Here

   * @throws Exception if parser can not be constructed or source is not a valid XML document.
   */
  public void testFormatWithException() throws Exception {
    Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest");
    Exception ex = new IllegalArgumentException("'foo' is not a valid name");
    LoggingEvent event =
      new LoggingEvent(
        "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", ex);
    XMLLayout layout = (XMLLayout) createLayout();
    String result = layout.format(event);
    Element parsedResult = parse(result);
    checkEventElement(parsedResult, event);
View Full Code Here

   */
  public void testFormatWithNDC() throws Exception {
    Logger logger = Logger.getLogger("org.apache.log4j.xml.XMLLayoutTest");
    NDC.push("NDC goes here");

    LoggingEvent event =
      new LoggingEvent(
        "org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null);
    XMLLayout layout = (XMLLayout) createLayout();
    String result = layout.format(event);
    NDC.pop();

View Full Code Here

      Hashtable mdcMap = MDC.getContext();
      if (mdcMap != null) {
          mdcMap.clear();
      }
      MDC.put(problemName, problemName);
      LoggingEvent event =
        new LoggingEvent(
          problemName, logger, level, problemName, ex);
      XMLLayout layout = (XMLLayout) createLayout();
      layout.setProperties(true);
      String result = layout.format(event);
      mdcMap = MDC.getContext();
View Full Code Here

    public void testNDCWithCDATA() throws Exception {
        Logger logger = Logger.getLogger("com.example.bar");
        Level level = Level.INFO;
        String ndcMessage ="<envelope><faultstring><![CDATA[The EffectiveDate]]></faultstring><envelope>";
        NDC.push(ndcMessage);
        LoggingEvent event =
          new LoggingEvent(
            "com.example.bar", logger, level, "Hello, World", null);
        Layout layout = createLayout();
        String result = layout.format(event);
        NDC.clear();
        Element parsedResult = parse(result);
View Full Code Here

      */
    public void testExceptionWithCDATA() throws Exception {
        Logger logger = Logger.getLogger("com.example.bar");
        Level level = Level.INFO;
        String exceptionMessage ="<envelope><faultstring><![CDATA[The EffectiveDate]]></faultstring><envelope>";
        LoggingEvent event =
          new LoggingEvent(
            "com.example.bar", logger, level, "Hello, World", new Exception(exceptionMessage));
        Layout layout = createLayout();
        String result = layout.format(event);
        Element parsedResult = parse(result);
        NodeList throwables = parsedResult.getElementsByTagName("log4j:throwable");
View Full Code Here

            greeter.run();
            rootLogger.error("That's all folks.");
        }
        async.close();
        Vector events = blockableAppender.getVector();
        LoggingEvent initialEvent = (LoggingEvent) events.get(0);
        LoggingEvent discardEvent = (LoggingEvent) events.get(events.size() - 1);
        PatternLayout layout = new PatternLayout();
        layout.setConversionPattern("%C:%L %m%n");
        layout.activateOptions();
        String initialStr = layout.format(initialEvent);
        assertEquals(AsyncAppenderTestCase.class.getName(),
View Full Code Here

            greeter.run();
            rootLogger.error("That's all folks.");
        }
        async.close();
        Vector events = blockableAppender.getVector();
        LoggingEvent initialEvent = (LoggingEvent) events.get(0);
        LoggingEvent discardEvent = (LoggingEvent) events.get(events.size() - 1);
        PatternLayout layout = new PatternLayout();
        layout.setConversionPattern("%C:%L %m%n");
        layout.activateOptions();
        String initialStr = layout.format(initialEvent);
        assertEquals("?:? ", initialStr.substring(0, 4));
View Full Code Here

            rootLogger.info(buf);
            buf.append(", World.");
        }
        async.close();
        Vector events = blockableAppender.getVector();
        LoggingEvent event = (LoggingEvent) events.get(0);
        PatternLayout layout = new PatternLayout();
        layout.setConversionPattern("%m");
        layout.activateOptions();
        String msg = layout.format(event);
        assertEquals("Hello", msg);
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.