当前位置: 首页>>代码示例>>Java>>正文


Java Priority.ERROR属性代码示例

本文整理汇总了Java中org.apache.log4j.Priority.ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java Priority.ERROR属性的具体用法?Java Priority.ERROR怎么用?Java Priority.ERROR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.log4j.Priority的用法示例。


在下文中一共展示了Priority.ERROR属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addIdeFatalMessage

@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
  Object data = aEvent.getData();
  final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
  if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
    if (myFatalsGrouper.addToGroup(message)) {
      return message;
    }
  } else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
    String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
    LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
    myFatalsGrouper.addToGroup(tooMany);
    return tooMany;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:MessagePool.java

示例2: getLogPriority

public Priority getLogPriority() {
     if ( this.traceLevel == TRACE_INFO ) {
        return Priority.INFO;
    } else if ( this.traceLevel == TRACE_ERROR ) {
        return Priority.ERROR;
    } else if ( this.traceLevel == TRACE_DEBUG) {
        return Priority.DEBUG;
    } else if ( this.traceLevel == TRACE_TRACE) {
        return Priority.DEBUG;
    } else {
        return Priority.FATAL;
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:13,代码来源:LogWriter.java

示例3: testCreateSummaryText

/**
 * Tests the trimming feature of summary text creation, in order to stay within
 * the maximum summary length of Jira.
 * @see <a href="http://java.net/jira/browse/LOG4J_APPENDER_JIRA-1">Problem occurring previously with summary length</a>
 */
@Test
public void testCreateSummaryText() throws Exception {
    final LoggingEvent le = new LoggingEvent(null, Logger.getLogger("LOGGER_NAME_WITH_A_LENGTH_OF_31"), Priority.ERROR, "MESSAGE_WITH_A_LENGTH_OF_27", null);

    // Length of summary will be sum of:
    //   27   "(Auto-generated, labelled '"
    //   ..   label
    //    3   "') "
    //   31   "LOGGER_NAME_WITH_A_LENGTH_OF_31"
    //    1   ":"
    //   27   "MESSAGE_WITH_A_LENGTH_OF_27"
    //  --- +
    //   89   PLUS label length
    final char[] labelCharsJustWithinLimits = new char[JIRALog4jAppender.MAXIMUM_SUMMARY_LENGTH - 89];
    final char[] labelCharsJustBeyondLimits = new char[JIRALog4jAppender.MAXIMUM_SUMMARY_LENGTH - 89 + 1];
    Arrays.fill(labelCharsJustWithinLimits, '*');
    Arrays.fill(labelCharsJustBeyondLimits, '*');
    
    final String summaryForJustWithinLimits = JIRALog4jAppender.getSummary(le, new String(labelCharsJustWithinLimits));
    final String summaryForJustBeyondLimits = JIRALog4jAppender.getSummary(le, new String(labelCharsJustBeyondLimits));
            
    Assert.assertTrue(
        "Summary for just within limits was not as expected: " + summaryForJustWithinLimits,
        summaryForJustWithinLimits.endsWith("MESSAGE_WITH_A_LENGTH_OF_27")
    );
    Assert.assertTrue(
        "Summary for just beyond limits was not as expected: " + summaryForJustBeyondLimits,
        summaryForJustBeyondLimits.endsWith("MESSAGE_WITH_A_LENGTH_ ...")
    );
}
 
开发者ID:marviq,项目名称:log4j-appender-jira,代码行数:35,代码来源:JIRALog4jAppenderTest.java

示例4: append_error

@Test
public void append_error() {
  MockLoggingChannel log = new MockLoggingChannel();
  KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
  Logger testLogger = Logger.getLogger(getClass());
  testLogger.setLevel(Level.ALL);

  // ERROR and FATAL map to "error" messages
  Layout layout = new Log4jKettleLayout();
  @SuppressWarnings("deprecation")
  LoggingEvent errorEvent1 = new LoggingEvent("org.test", testLogger, Priority.ERROR, "Testing", null);
  Exception errorException = new Exception("something went wrong!");
  @SuppressWarnings("deprecation")
  LoggingEvent errorEvent2 = new LoggingEvent("org.test", testLogger, Priority.ERROR, "Testing", errorException);
  @SuppressWarnings("deprecation")
  LoggingEvent fatalEvent1 = new LoggingEvent("org.test", testLogger, Priority.FATAL, "Testing", null);
  Exception fatalException = new Exception("something went fatally wrong!");
  @SuppressWarnings("deprecation")
  LoggingEvent fatalEvent2 = new LoggingEvent("org.test", testLogger, Priority.FATAL, "Testing", fatalException);

  appender.doAppend(errorEvent1);
  appender.doAppend(errorEvent2);
  appender.doAppend(fatalEvent1);
  appender.doAppend(fatalEvent2);

  assertEquals(0, log.getDebugMessages().size());
  assertEquals(0, log.getDetailedMessages().size());
  assertEquals(0, log.getBasicMessages().size());
  assertEquals(0, log.getMinimalMessages().size());
  assertEquals(0, log.getRowLevelMessages().size());

  assertEquals(4, log.getErrorMessages().size());
  assertEquals(layout.format(errorEvent1), log.getErrorMessages().get(0).getMessage());
  assertEquals(layout.format(errorEvent1), log.getErrorMessages().get(1).getMessage());
  assertEquals(errorException, log.getErrorMessages().get(1).getThrowable());
  assertEquals(layout.format(fatalEvent1), log.getErrorMessages().get(2).getMessage());
  assertEquals(layout.format(fatalEvent2), log.getErrorMessages().get(3).getMessage());
  assertEquals(fatalException, log.getErrorMessages().get(3).getThrowable());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:39,代码来源:KettleLogChannelAppenderTest.java

示例5: convertLog4JPriority

public static LogPriority convertLog4JPriority(Priority priority) {
    LogPriority pri = LogPriority.INFO; // a reasonable default
    if (priority == Priority.DEBUG) {
        pri = LogPriority.DEBUG;
    } else if (priority == Priority.ERROR) {
        pri = LogPriority.ERROR;
    } else if (priority == Priority.FATAL) {
        pri = LogPriority.FATAL;
    } else if (priority == Priority.INFO) {
        pri = LogPriority.INFO;
    } else if (priority == Priority.WARN) {
        pri = LogPriority.WARN;
    }
    return pri;
}
 
开发者ID:NCIP,项目名称:cagrid-core,代码行数:15,代码来源:StreamGobbler.java

示例6: main

static public void main(String[] args) {

    JFrame frame = new JFrame("JListView test");
    Container container = frame.getContentPane();

    JListView view = new JListView(new JListViewModel(Integer.parseInt(args[0])));


    JScrollPane sp = new JScrollPane(view);
    sp.setPreferredSize(new Dimension(250, 80));
    
    container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
    //container.add(view);
    container.add(sp);

    JButton b1 = new JButton("Add 1");
    JButton b10 = new JButton("Add 10");
    JButton b100 = new JButton("Add 100");
    JButton b1000 = new JButton("Add 1000");
    JButton b10000 = new JButton("Add 10000");

    JPanel panel = new JPanel(new GridLayout(0,1));
    container.add(panel);

    panel.add(b1);
    panel.add(b10);
    panel.add(b100);
    panel.add(b1000);
    panel.add(b10000);
    

    AddAction a1 = new AddAction(view, 1);
    AddAction a10 = new AddAction(view, 10);
    AddAction a100 = new AddAction(view, 100);
    AddAction a1000 = new AddAction(view, 1000);
    AddAction a10000 = new AddAction(view, 10000);

    b1.addActionListener(a1);
    b10.addActionListener(a10);
    b100.addActionListener(a100);
    b1000.addActionListener(a1000);
    b10000.addActionListener(a10000);

    frame.setVisible(true);
    frame.setSize(new Dimension(700,700));

    long before = System.currentTimeMillis();

    int RUN = 1000;
    int i = 0;
    while(i++ < RUN) {      
      LoggingEvent event0 = new LoggingEvent("x", cat, Priority.ERROR, 
					     "Message "+i, null);
      
      Throwable t = new Exception("hello "+i);
      LoggingEvent event1 = new LoggingEvent("x", cat, Priority.ERROR, 
					     "Message "+i, t);
      

      if(i % 10 == 0) {	
	event1.getThreadName();
	view.add(event1);
      } else {
	event0.getThreadName();
	view.add(event0);
      }
    }

    long after = System.currentTimeMillis();
    System.out.println("Time taken :"+ ((after-before)*1000/RUN));

  }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:72,代码来源:JListView.java

示例7: main

static public void main(String[] args) {

    JFrame frame = new JFrame("JListView test");
    Container container = frame.getContentPane();

    JTableAppender appender = new JTableAppender();
    
    JTableAppenderModel model = new 
                              JTableAppenderModel(Integer.parseInt(args[0]));
    appender.setModel(model);
    //appender.createDefaultColumnsFromModel();    


    JScrollPane sp = new JScrollPane(appender);
    sp.setPreferredSize(new Dimension(250, 80));
    
    container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
    //container.add(view);
    container.add(sp);

    JButton button = new JButton("ADD");
    container.add(button);
    

    button.addActionListener(new JTableAddAction(appender));

    frame.setVisible(true);
    frame.setSize(new Dimension(700,700));

    long before = System.currentTimeMillis();

    int RUN = 10000;
    int i = 0;
    while(i++ < RUN) {      
      LoggingEvent event = new LoggingEvent("x", cat, Priority.ERROR, 
					    "Message "+i, null);
      event.getThreadName();
      if(i % 10 == 0) {
	//event.throwable = new Exception("hello "+i);
      }
      appender.add(event);
    }

    long after = System.currentTimeMillis();
    System.out.println("Time taken :"+ ((after-before)*1000/RUN));

  }
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:47,代码来源:JTableAppender.java


注:本文中的org.apache.log4j.Priority.ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。