org.apache.log4j.lf5.LogLevel Java Examples

The following examples show how to use org.apache.log4j.lf5.LogLevel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected JMenu createLogLevelMenu() {
  JMenu result = new JMenu("Log Level");
  result.setMnemonic('l');
  Iterator levels = getLogLevels();
  while (levels.hasNext()) {
    result.add(getMenuItem((LogLevel) levels.next()));
  }

  result.addSeparator();
  result.add(createAllLogLevelsMenuItem());
  result.add(createNoLogLevelsMenuItem());
  result.addSeparator();
  result.add(createLogLevelColorMenu());
  result.add(createResetLogLevelColorMenuItem());

  return result;
}
 
Example #2
Source File: DavGatewayTray.java    From davmail with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Open logging window.
 */
public static void showLogs() {
    Logger rootLogger = Logger.getRootLogger();
    LF5Appender lf5Appender = (LF5Appender) rootLogger.getAppender("LF5Appender");
    if (lf5Appender == null) {
        LogBrokerMonitor logBrokerMonitor = new LogBrokerMonitor(LogLevel.getLog4JLevels()) {
            @Override
            protected void closeAfterConfirm() {
                hide();
            }
        };
        lf5Appender = new LF5Appender(logBrokerMonitor);
        lf5Appender.setName("LF5Appender");
        rootLogger.addAppender(lf5Appender);
    }
    lf5Appender.getLogBrokerMonitor().show();
}
 
Example #3
Source File: ConfigurationManager.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void save() {
  CategoryExplorerModel model = _monitor.getCategoryExplorerTree().getExplorerModel();
  CategoryNode root = model.getRootCategoryNode();

  StringBuffer xml = new StringBuffer(2048);
  openXMLDocument(xml);
  openConfigurationXML(xml);
  processLogRecordFilter(_monitor.getNDCTextFilter(), xml);
  processLogLevels(_monitor.getLogLevelMenuItems(), xml);
  processLogLevelColors(_monitor.getLogLevelMenuItems(),
      LogLevel.getLogLevelColorMap(), xml);
  processLogTableColumns(LogTableColumn.getLogTableColumns(), xml);
  processConfigurationNode(root, xml);
  closeConfigurationXML(xml);
  store(xml.toString());
}
 
Example #4
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected JComboBox createLogLevelCombo() {
  JComboBox result = new JComboBox();
  Iterator levels = getLogLevels();
  while (levels.hasNext()) {
    result.addItem(levels.next());
  }
  result.setSelectedItem(_leastSevereDisplayedLogLevel);

  result.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      JComboBox box = (JComboBox) e.getSource();
      LogLevel level = (LogLevel) box.getSelectedItem();
      setLeastSevereDisplayedLogLevel(level);
    }
  });
  result.setMaximumSize(result.getPreferredSize());
  return result;
}
 
Example #5
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * <p>Log a complete message to the Monitor.<p>
 *
 * @param category The category to be used
 * @param level The log level to apply to the message
 * @param message The message
 * @param t The throwable content of the message
 * @param NDC The NDC really only applies to Log4J and the parameter can
 *            usually be ignored.
 */
public void log(String category, LogLevel level, String message,
    Throwable t, String NDC) {
  AdapterLogRecord record = new AdapterLogRecord();
  record.setCategory(category);
  record.setMessage(message);
  record.setNDC(NDC);
  record.setThrown(t);

  if (level == null) {
    record.setLevel(getDefaultLevel());
  } else {
    record.setLevel(level);
  }

  addMessage(record);
}
 
Example #6
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JMenuItem createSubMenuItem(LogLevel level) {
  final JMenuItem result = new JMenuItem(level.toString());
  final LogLevel logLevel = level;
  result.setMnemonic(level.toString().charAt(0));
  result.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      showLogLevelColorChangeDialog(result, logLevel);
    }
  });

  return result;

}
 
Example #7
Source File: ConfigurationManager.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void processLogLevelColors(Map logLevelMenuItems, Map logLevelColors, StringBuffer xml) {
  xml.append("\t<loglevelcolors>\r\n");
  // iterate through the list of log levels being used (log4j, jdk1.4, custom levels)
  Iterator it = logLevelMenuItems.keySet().iterator();
  while (it.hasNext()) {
    LogLevel level = (LogLevel) it.next();
    // for each level, get the associated color from the log level color map
    Color color = (Color) logLevelColors.get(level);
    exportLogLevelColorXMLElement(level.getLabel(), color, xml);
  }

  xml.append("\t</loglevelcolors>\r\n");
}
 
Example #8
Source File: ConfigurationManager.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void processLogLevels(Map logLevelMenuItems, StringBuffer xml) {
  xml.append("\t<loglevels>\r\n");
  Iterator it = logLevelMenuItems.keySet().iterator();
  while (it.hasNext()) {
    LogLevel level = (LogLevel) it.next();
    JCheckBoxMenuItem item = (JCheckBoxMenuItem) logLevelMenuItems.get(level);
    exportLogLevelXMLElement(level.getLabel(), item.isSelected(), xml);
  }

  xml.append("\t</loglevels>\r\n");
}
 
Example #9
Source File: ConfigurationManager.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void processLogLevelColors(Document doc) {
  NodeList nodeList = doc.getElementsByTagName(COLORLEVEL);
  LogLevel.getLogLevelColorMap();

  for (int i = 0; i < nodeList.getLength(); i++) {
    Node n = nodeList.item(i);
    // check for backwards compatibility since this feature was added
    // in version 1.3
    if (n == null) {
      return;
    }

    NamedNodeMap map = n.getAttributes();
    String name = getValue(map, NAME);
    try {
      LogLevel level = LogLevel.valueOf(name);
      int red = Integer.parseInt(getValue(map, RED));
      int green = Integer.parseInt(getValue(map, GREEN));
      int blue = Integer.parseInt(getValue(map, BLUE));
      Color c = new Color(red, green, blue);
      if (level != null) {
        level.setLogLevelColorMap(level, c);
      }

    } catch (LogLevelFormatException e) {
      // ignore it will be on by default.
    }
  }
}
 
Example #10
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JMenu createLogLevelColorMenu() {
  JMenu colorMenu = new JMenu("Configure LogLevel Colors");
  colorMenu.setMnemonic('c');
  Iterator levels = getLogLevels();
  while (levels.hasNext()) {
    colorMenu.add(createSubMenuItem((LogLevel) levels.next()));
  }

  return colorMenu;
}
 
Example #11
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JMenuItem createResetLogLevelColorMenuItem() {
  JMenuItem result = new JMenuItem("Reset LogLevel Colors");
  result.setMnemonic('r');
  result.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      // reset the level colors in the map
      LogLevel.resetLogLevelColorMap();

      // refresh the table
      _table.getFilteredLogTableModel().refresh();
    }
  });
  return result;
}
 
Example #12
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JCheckBoxMenuItem getMenuItem(LogLevel level) {
  JCheckBoxMenuItem result = (JCheckBoxMenuItem) (_logLevelMenuItems.get(level));
  if (result == null) {
    result = createMenuItem(level);
    _logLevelMenuItems.put(level, result);
  }
  return result;
}
 
Example #13
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void showLogLevelColorChangeDialog(JMenuItem result, LogLevel level) {
  JMenuItem menuItem = result;
  Color newColor = JColorChooser.showDialog(
      _logMonitorFrame,
      "Choose LogLevel Color",
      result.getForeground());

  if (newColor != null) {
    // set the color for the record
    level.setLogLevelColorMap(level, newColor);
    _table.getFilteredLogTableModel().refresh();
  }

}
 
Example #14
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected JCheckBoxMenuItem createMenuItem(LogLevel level) {
  JCheckBoxMenuItem result = new JCheckBoxMenuItem(level.toString());
  result.setSelected(true);
  result.setMnemonic(level.toString().charAt(0));
  result.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      _table.getFilteredLogTableModel().refresh();
      updateStatusLabel();
    }
  });
  return result;
}
 
Example #15
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * <p>Creates an instance of LogMonitorAdapter using the
 * log levels inticated by the parameter. Log4J and JDK1.4 both have default
 * LogLevels which are set but these levels can be overriden.<p>
 *
 * @param loglevels An integer representing either Log4J or JDK1.4 logging levels
 * @return LogMonitorAdapter
 */
public static LogMonitorAdapter newInstance(int loglevels) {
  LogMonitorAdapter adapter;
  if (loglevels == JDK14_LOG_LEVELS) {
    adapter = newInstance(LogLevel.getJdk14Levels());
    adapter.setDefaultLevel(LogLevel.FINEST);
    adapter.setSevereLevel(LogLevel.SEVERE);
  } else {
    adapter = newInstance(LogLevel.getLog4JLevels());
    adapter.setDefaultLevel(LogLevel.DEBUG);
    adapter.setSevereLevel(LogLevel.FATAL);
  }
  return adapter;
}
 
Example #16
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private LogMonitorAdapter(List userDefinedLevels) {
  super();
  // set the default level to be the first entry in the list
  _defaultLevel = (LogLevel) userDefinedLevels.get(0);
  _logMonitor = new LogBrokerMonitor(userDefinedLevels);

  _logMonitor.setFrameSize(getDefaultMonitorWidth(),
      getDefaultMonitorHeight());
  _logMonitor.setFontSize(12);
  _logMonitor.show();
}
 
Example #17
Source File: LogFileParser.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private LogLevel parsePriority(String record) {
  String temp = parseAttribute(PRIORITY_DELIMITER, record);

  if (temp != null) {
    try {
      return LogLevel.valueOf(temp);
    } catch (LogLevelFormatException e) {
      return LogLevel.DEBUG;
    }

  }

  return LogLevel.DEBUG;
}
 
Example #18
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void setLeastSevereDisplayedLogLevel(LogLevel level) {
  if (level == null || _leastSevereDisplayedLogLevel == level) {
    return; // nothing to do
  }
  _leastSevereDisplayedLogLevel = level;
  _table.getFilteredLogTableModel().refresh();
  updateStatusLabel();
}
 
Example #19
Source File: UsingLogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void doMyBidding() {
  String logger = this.getClass().getName();

  // will default to debug log level
  _adapter.log(logger, "Doh this is a debugging");

  _adapter.log(logger, LogLevel.INFO, "Hmmm fobidden doughnut");
  _adapter.log(logger, LogLevel.WARN, "Danger Danger Will Robinson",
      new RuntimeException("DANGER"), "32");
  _adapter.log(logger, LogLevel.ERROR, "Exit stage right->");
  _adapter.log(logger, LogLevel.FATAL, "What's up Doc?",
      new NullPointerException("Unfortunate exception"));
}
 
Example #20
Source File: LogTableRowRenderer.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected Color getLogLevelColor(LogLevel level) {
  return (Color) LogLevel.getLogLevelColorMap().get(level);
}
 
Example #21
Source File: LogBrokerMonitor.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void selectAllLogLevels(boolean selected) {
  Iterator levels = getLogLevels();
  while (levels.hasNext()) {
    getMenuItem((LogLevel) levels.next()).setSelected(selected);
  }
}
 
Example #22
Source File: AdapterLogRecord.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static LogLevel getSevereLevel() {
  return severeLevel;
}
 
Example #23
Source File: AdapterLogRecord.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void setSevereLevel(LogLevel level) {
  severeLevel = level;
}
 
Example #24
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * <p>Creates an instance of LogMonitorAdapter using the specified LogLevels.
 * The first LogLevel in the array is used as the default LogLevel unless
 * changed using the setDefaultLevel method.<p>
 *
 * @param userDefined An array of user defined LogLevel objects.
 * @return LogMonitorAdapter
 */
public static LogMonitorAdapter newInstance(LogLevel[] userDefined) {
  if (userDefined == null) {
    return null;
  }
  return newInstance(Arrays.asList(userDefined));
}
 
Example #25
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * <p>Log a message to the Monitor.<p>
 *
 * @param category The category to be used
 * @param level The log level to apply to the message
 * @param message The message
 */
public void log(String category, LogLevel level, String message) {
  log(category, level, message, null, null);
}
 
Example #26
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * <p>Log a message to the Monitor.<p>
 *
 * @param category The category to be used
 * @param level The log level to apply to the message
 * @param message The message
 * @param t The throwable content of the message
 */
public void log(String category, LogLevel level, String message,
    Throwable t) {
  log(category, level, message, t, null);
}
 
Example #27
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * <p>Log a message to the Monitor.<p>
 *
 * @param category The category to be used
 * @param level The log level to apply to the message
 * @param message The message
 * @param NDC
 */
public void log(String category, LogLevel level, String message, String NDC) {
  log(category, level, message, null, NDC);
}
 
Example #28
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * <p>Gets the current Severe LogLevel <p>
 *
 * @return LogLevel
 */
public LogLevel getSevereLevel() {
  return AdapterLogRecord.getSevereLevel();
}
 
Example #29
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * <p>Sets the Severe LogLevel.</p>
 *
 * @param level
 */
public void setSevereLevel(LogLevel level) {
  AdapterLogRecord.setSevereLevel(level);
}
 
Example #30
Source File: LogMonitorAdapter.java    From cacheonix-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * <p>Gets the default LogLevel for the Adapter.<p>
 *
 * @return LogLevel
 */
public LogLevel getDefaultLevel() {
  return _defaultLevel;
}