Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Source Code for Apache Log4j 1.2.17
Apache Log4j provides the interface that applications should code to and provides the adapter components required for implementers to create a logging implementation.
Bytecode (Java 1.4) for Apache Log4j is provided in a JAR file like log4j-1.2.17.jar.
Source Code files for Apache Log4j are provided in both binary packge like log4j-1.2.17.zip and source package like log4j-1.2.17-sources.zip. You can download them at Apache Log4j Website.
You can also browse Source Code files for Apache Log4j 1.2.17 below.
✍: FYIcenter.com
⏎ org/apache/log4j/lf5/viewer/LogTable.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.log4j.lf5.viewer; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.util.Enumeration; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import org.apache.log4j.lf5.util.DateFormatManager; /** * LogTable. * * @author Michael J. Sikorsky * @author Robert Shaw * @author Brad Marlborough * @author Brent Sprecher */ // Contributed by ThoughtWorks Inc. public class LogTable extends JTable { private static final long serialVersionUID = 4867085140195148458L; //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Protected Variables: //-------------------------------------------------------------------------- protected int _rowHeight = 30; protected JTextArea _detailTextArea; // For the columns: protected int _numCols = 9; protected TableColumn[] _tableColumns = new TableColumn[_numCols]; protected int[] _colWidths = {40, 40, 40, 70, 70, 360, 440, 200, 60}; protected LogTableColumn[] _colNames = LogTableColumn.getLogTableColumnArray(); protected int _colDate = 0; protected int _colThread = 1; protected int _colMessageNum = 2; protected int _colLevel = 3; protected int _colNDC = 4; protected int _colCategory = 5; protected int _colMessage = 6; protected int _colLocation = 7; protected int _colThrown = 8; protected DateFormatManager _dateFormatManager = null; //-------------------------------------------------------------------------- // Private Variables: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Constructors: //-------------------------------------------------------------------------- public LogTable(JTextArea detailTextArea) { super(); init(); _detailTextArea = detailTextArea; setModel(new FilteredLogTableModel()); Enumeration columns = getColumnModel().getColumns(); int i = 0; while (columns.hasMoreElements()) { TableColumn col = (TableColumn) columns.nextElement(); col.setCellRenderer(new LogTableRowRenderer()); col.setPreferredWidth(_colWidths[i]); _tableColumns[i] = col; i++; } ListSelectionModel rowSM = getSelectionModel(); rowSM.addListSelectionListener(new LogTableListSelectionListener(this)); //setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); } //-------------------------------------------------------------------------- // Public Methods: //-------------------------------------------------------------------------- /** * Get the DateFormatManager for formatting dates. */ public DateFormatManager getDateFormatManager() { return _dateFormatManager; } /** * Set the date format manager for formatting dates. */ public void setDateFormatManager(DateFormatManager dfm) { _dateFormatManager = dfm; } public synchronized void clearLogRecords() { //For JDK1.3 //((DefaultTableModel)getModel()).setRowCount(0); // For JDK1.2.x getFilteredLogTableModel().clear(); } public FilteredLogTableModel getFilteredLogTableModel() { return (FilteredLogTableModel) getModel(); } // default view if a view is not set and saved public void setDetailedView() { //TODO: Defineable Views. TableColumnModel model = getColumnModel(); // Remove all the columns: for (int f = 0; f < _numCols; f++) { model.removeColumn(_tableColumns[f]); } // Add them back in the correct order: for (int i = 0; i < _numCols; i++) { model.addColumn(_tableColumns[i]); } //SWING BUG: sizeColumnsToFit(-1); } public void setView(List columns) { TableColumnModel model = getColumnModel(); // Remove all the columns: for (int f = 0; f < _numCols; f++) { model.removeColumn(_tableColumns[f]); } Iterator selectedColumns = columns.iterator(); Vector columnNameAndNumber = getColumnNameAndNumber(); while (selectedColumns.hasNext()) { // add the column to the view model.addColumn(_tableColumns[columnNameAndNumber.indexOf(selectedColumns.next())]); } //SWING BUG: sizeColumnsToFit(-1); } public void setFont(Font font) { super.setFont(font); Graphics g = this.getGraphics(); if (g != null) { FontMetrics fm = g.getFontMetrics(font); int height = fm.getHeight(); _rowHeight = height + height / 3; setRowHeight(_rowHeight); } } //-------------------------------------------------------------------------- // Protected Methods: //-------------------------------------------------------------------------- protected void init() { setRowHeight(_rowHeight); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } // assign a column number to a column name protected Vector getColumnNameAndNumber() { Vector columnNameAndNumber = new Vector(); for (int i = 0; i < _colNames.length; i++) { columnNameAndNumber.add(i, _colNames[i]); } return columnNameAndNumber; } //-------------------------------------------------------------------------- // Private Methods: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Nested Top-Level Classes or Interfaces: //-------------------------------------------------------------------------- class LogTableListSelectionListener implements ListSelectionListener { protected JTable _table; public LogTableListSelectionListener(JTable table) { _table = table; } public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) { return; } ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { //no rows are selected } else { StringBuffer buf = new StringBuffer(); int selectedRow = lsm.getMinSelectionIndex(); for (int i = 0; i < _numCols - 1; i++) { String value = ""; Object obj = _table.getModel().getValueAt(selectedRow, i); if (obj != null) { value = obj.toString(); } buf.append(_colNames[i] + ":"); buf.append("\t"); if (i == _colThread || i == _colMessage || i == _colLevel) { buf.append("\t"); // pad out the date. } if (i == _colDate || i == _colNDC) { buf.append("\t\t"); // pad out the date. } // if( i == _colSequence) // { // buf.append("\t\t\t"); // pad out the Sequnce. // } buf.append(value); buf.append("\n"); } buf.append(_colNames[_numCols - 1] + ":\n"); Object obj = _table.getModel().getValueAt(selectedRow, _numCols - 1); if (obj != null) { buf.append(obj.toString()); } _detailTextArea.setText(buf.toString()); } } } }
⏎ org/apache/log4j/lf5/viewer/LogTable.java
Or download all of them as a single archive file:
File name: log4j-1.2.17-sources.jar File size: 481200 bytes Release date: 2012-05-06 Download
⇒ Download and Install apache-log4j-1.2.15.zip
⇐ Download and Install log4j-1.2.17.zip
2015-12-14, 62627👍, 0💬
Popular Posts:
XML Serializer, Release 2.7.1, allows you to write out XML, HTML etc. as a stream of characters from...
JDK 11 java.rmi.jmod is the JMOD file for JDK 11 RMI (Remote Method Invocation) module. JDK 11 RMI m...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
JAX-WS is an API for building web services and clients. It is the next generation Web Services API r...