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/LF5Appender.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; import java.awt.Toolkit; import org.apache.log4j.AppenderSkeleton; import org.apache.log4j.lf5.viewer.LogBrokerMonitor; import org.apache.log4j.spi.LocationInfo; import org.apache.log4j.spi.LoggingEvent; /** * <code>LF5Appender</code> logs events to a swing based logging * console. The swing console supports turning categories on and off, * multiple detail level views, as well as full text searching and many * other capabilties. * * @author Brent Sprecher */ // Contributed by ThoughtWorks Inc. public class LF5Appender extends AppenderSkeleton { //-------------------------------------------------------------------------- // Constants: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Protected Variables: //-------------------------------------------------------------------------- protected LogBrokerMonitor _logMonitor; protected static LogBrokerMonitor _defaultLogMonitor; protected static AppenderFinalizer _finalizer; //-------------------------------------------------------------------------- // Private Variables: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Constructors: //-------------------------------------------------------------------------- /** * Constructs a <code>LF5Appender</code> using the default instance of * the <code>LogBrokerMonitor</code>. This constructor should <bold>always * </bold> be preferred over the * <code>LF5Appender(LogBrokerMonitor monitor)</code> * constructor, unless you need to spawn additional log monitoring * windows. */ public LF5Appender() { this(getDefaultInstance()); } /** * Constructs a <code>LF5Appender<code> using an instance of * a <code>LogBrokerMonitor<code> supplied by the user. This * constructor should only be used when you need to spawn * additional log monitoring windows. * * @param monitor An instance of a <code>LogBrokerMonitor<code> * created by the user. */ public LF5Appender(LogBrokerMonitor monitor) { if (monitor != null) { _logMonitor = monitor; } } //-------------------------------------------------------------------------- // Public Methods: //-------------------------------------------------------------------------- /** * Appends a <code>LoggingEvent</code> record to the * <code>LF5Appender</code>. * @param event The <code>LoggingEvent</code> * to be appended. */ public void append(LoggingEvent event) { // Retrieve the information from the log4j LoggingEvent. String category = event.getLoggerName(); String logMessage = event.getRenderedMessage(); String nestedDiagnosticContext = event.getNDC(); String threadDescription = event.getThreadName(); String level = event.getLevel().toString(); long time = event.timeStamp; LocationInfo locationInfo = event.getLocationInformation(); // Add the logging event information to a LogRecord Log4JLogRecord record = new Log4JLogRecord(); record.setCategory(category); record.setMessage(logMessage); record.setLocation(locationInfo.fullInfo); record.setMillis(time); record.setThreadDescription(threadDescription); if (nestedDiagnosticContext != null) { record.setNDC(nestedDiagnosticContext); } else { record.setNDC(""); } if (event.getThrowableInformation() != null) { record.setThrownStackTrace(event.getThrowableInformation()); } try { record.setLevel(LogLevel.valueOf(level)); } catch (LogLevelFormatException e) { // If the priority level doesn't match one of the predefined // log levels, then set the level to warning. record.setLevel(LogLevel.WARN); } if (_logMonitor != null) { _logMonitor.addMessage(record); } } /** * This method is an empty implementation of the close() method inherited * from the <code>org.apache.log4j.Appender</code> interface. */ public void close() { } /** * Returns a value that indicates whether this appender requires a * <code>Layout</code>. This method always returns false. * No layout is required for the <code>LF5Appender</code>. */ public boolean requiresLayout() { return false; } /** * This method is used to set the property that controls whether * the <code>LogBrokerMonitor</code> is hidden or closed when a user * exits * the monitor. By default, the <code>LogBrokerMonitor</code> will hide * itself when the log window is exited, and the swing thread will * continue to run in the background. If this property is * set to true, the <code>LogBrokerMonitor</code> will call System.exit(0) * and will shut down swing thread and the virtual machine. * * @param callSystemExitOnClose A boolean value indicating whether * to call System.exit(0) when closing the log window. */ public void setCallSystemExitOnClose(boolean callSystemExitOnClose) { _logMonitor.setCallSystemExitOnClose(callSystemExitOnClose); } /** * The equals method compares two LF5Appenders and determines whether * they are equal. Two <code>Appenders</code> will be considered equal * if, and only if, they both contain references to the same <code> * LogBrokerMonitor</code>. * * @param compareTo A boolean value indicating whether * the two LF5Appenders are equal. */ public boolean equals(LF5Appender compareTo) { // If both reference the same LogBrokerMonitor, they are equal. return _logMonitor == compareTo.getLogBrokerMonitor(); } public LogBrokerMonitor getLogBrokerMonitor() { return _logMonitor; } public static void main(String[] args) { new LF5Appender(); } public void setMaxNumberOfRecords(int maxNumberOfRecords) { _defaultLogMonitor.setMaxNumberOfLogRecords(maxNumberOfRecords); } //-------------------------------------------------------------------------- // Protected Methods: //-------------------------------------------------------------------------- /** * @return The default instance of the <code>LogBrokerMonitor</code>. */ protected static synchronized LogBrokerMonitor getDefaultInstance() { if (_defaultLogMonitor == null) { try { _defaultLogMonitor = new LogBrokerMonitor(LogLevel.getLog4JLevels()); _finalizer = new AppenderFinalizer(_defaultLogMonitor); _defaultLogMonitor.setFrameSize(getDefaultMonitorWidth(), getDefaultMonitorHeight()); _defaultLogMonitor.setFontSize(12); _defaultLogMonitor.show(); } catch (SecurityException e) { _defaultLogMonitor = null; } } return _defaultLogMonitor; } /** * @return the screen width from Toolkit.getScreenSize() * if possible, otherwise returns 800 * @see java.awt.Toolkit */ protected static int getScreenWidth() { try { return Toolkit.getDefaultToolkit().getScreenSize().width; } catch (Throwable t) { return 800; } } /** * @return the screen height from Toolkit.getScreenSize() * if possible, otherwise returns 600 * @see java.awt.Toolkit */ protected static int getScreenHeight() { try { return Toolkit.getDefaultToolkit().getScreenSize().height; } catch (Throwable t) { return 600; } } protected static int getDefaultMonitorWidth() { return (3 * getScreenWidth()) / 4; } protected static int getDefaultMonitorHeight() { return (3 * getScreenHeight()) / 4; } //-------------------------------------------------------------------------- // Private Methods: //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- // Nested Top-Level Classes or Interfaces: //-------------------------------------------------------------------------- }
⏎ org/apache/log4j/lf5/LF5Appender.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, 51103👍, 0💬
Popular Posts:
What Is HttpComponents commons-httpclient-3.1.j ar?HttpComponents commons-httpclient-3.1.j aris the ...
How to run "jarsigner" command from JDK tools.jar file? "jarsigner" command allows you to digitally ...
Old version of xml-apis.jar. JAR File Size and Download Location: File name: xmlParserAPIs.jar File ...
Where to find answers to frequently asked questions on Download and Installing of Older Versions? He...
Old version of xml-apis.jar. JAR File Size and Download Location: File name: xmlParserAPIs.jar File ...