The version of Apache log4j used by SoundHelix.
Clone
HTTPS:
git clone https://vervis.peers.community/repos/aEp6o
SSH:
git clone USERNAME@vervis.peers.community:aEp6o
Branches
Tags
- 1.3alpha-7
- CHAINSAW_2_SANDBOX_MERGE
- CORE_VERSION
- LEVEL_REPLACES_PRIORITY
- PREALPHA_1_3_AS_OF_2004_05_12
- PRE_CHAINSAW_MODEL_CONVERSION
- PRE_UGLI_MOVE
- TAG_CHAINSAW2_MOVE
- log4j-1.2.17
- log4j-1.2.17-rc1
- v1.3alpha8
- v1.3alpha8-temp
- v1_2_1
- v1_2_10-recalled
- v1_2_11
- v1_2_11_rc1
- v1_2_11rc3
- v1_2_12
- v1_2_12_rc1
- v1_2_12_rc2
- v1_2_12_rc3
- v1_2_12_rc4
- v1_2_12_rc5
- v1_2_12_rc6
- v1_2_13
- v1_2_13_rc1
- v1_2_13_rc2
- v1_2_13_site_update
- v1_2_14
- v1_2_14_maven
- v1_2_14_rc1
- v1_2_14_site_update
- v1_2_15
- v1_2_15_rc1
- v1_2_15_rc2
- v1_2_15_rc3
- v1_2_15_rc4
- v1_2_15_rc5
- v1_2_15_rc6
- v1_2_16
- v1_2_16_rc1
- v1_2_16_rc2
- v1_2_17
- v1_2_17-rc1
- v1_2_17_rc1
- v1_2_17_rc2
- v1_2_17_rc3
- v1_2_2
- v1_2_3
- v1_2_4
- v1_2_6
- v1_2_7
- v1_2_9
- v1_2_alpha0
- v1_2_alpha7
- v1_2beta1
- v1_2final
- v1_3alpha_1
- v1_3alpha_6
- v_1_0
- v_1_0_1
- v_1_0_4
- v_1_1
- v_1_1_1
- v_1_1_2
- v_1_1_3
- v_1_1_b1
- v_1_1b2
- v_1_1b3
- v_1_1b5
- v_1_1b6
- v_1_1b7
- v_1_2beta3
TTCCLayout.java
/*
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "log4j" and "Apache Software Foundation" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache", nor may
* "Apache" appear in their name, without prior written permission of the
* Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/>.
*
*/
// Contributors: Christopher Williams
// Mathias Bogaert
package org.apache.log4j;
import org.apache.log4j.helpers.DateLayout;
import org.apache.log4j.spi.LoggingEvent;
/**
TTCC layout format consists of time, thread, category and nested
diagnostic context information, hence the name.
<p>Each of the four fields can be individually enabled or
disabled. The time format depends on the <code>DateFormat</code>
used.
<p>Here is an example TTCCLayout output with the
{@link org.apache.log4j.helpers.RelativeTimeDateFormat}.
<pre>
176 [main] INFO org.apache.log4j.examples.Sort - Populating an array of 2 elements in reverse order.
225 [main] INFO org.apache.log4j.examples.SortAlgo - Entered the sort method.
262 [main] DEBUG org.apache.log4j.examples.SortAlgo.OUTER i=1 - Outer loop.
276 [main] DEBUG org.apache.log4j.examples.SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
290 [main] DEBUG org.apache.log4j.examples.SortAlgo.OUTER i=0 - Outer loop.
304 [main] INFO org.apache.log4j.examples.SortAlgo.DUMP - Dump of interger array:
317 [main] INFO org.apache.log4j.examples.SortAlgo.DUMP - Element [0] = 0
331 [main] INFO org.apache.log4j.examples.SortAlgo.DUMP - Element [1] = 1
343 [main] INFO org.apache.log4j.examples.Sort - The next log statement should be an error message.
346 [main] ERROR org.apache.log4j.examples.SortAlgo.DUMP - Tried to dump an uninitialized array.
at org.apache.log4j.examples.SortAlgo.dump(SortAlgo.java:58)
at org.apache.log4j.examples.Sort.main(Sort.java:64)
467 [main] INFO org.apache.log4j.examples.Sort - Exiting main method.
</pre>
<p>The first field is the number of milliseconds elapsed since the
start of the program. The second field is the thread outputting the
log statement. The third field is the level, the fourth field is
the category to which the statement belongs.
<p>The fifth field (just before the '-') is the nested diagnostic
context. Note the nested diagnostic context may be empty as in the
first two statements. The text after the '-' is the message of the
statement.
<p><b>WARNING</b> Do not use the same TTCCLayout instance from
within different appenders. The TTCCLayout is not thread safe when
used in his way. However, it is perfectly safe to use a TTCCLayout
instance from just one appender.
<p>{@link PatternLayout} offers a much more flexible alternative.
@author Ceki Gülcü
@author <A HREF="mailto:heinz.richter@ecmwf.int">Heinz Richter</a>
*/
public class TTCCLayout extends DateLayout {
// Internal representation of options
private boolean threadPrinting = true;
private boolean categoryPrefixing = true;
private boolean contextPrinting = true;
protected final StringBuffer buf = new StringBuffer(64);
/**
Instantiate a TTCCLayout object with {@link
org.apache.log4j.helpers.RelativeTimeDateFormat} as the date
formatter in the local time zone.
@since 0.7.5 */
public TTCCLayout() {
this.setDateFormat(RELATIVE_TIME_DATE_FORMAT, null);
}
/**
Instantiate a TTCCLayout object using the local time zone. The
DateFormat used will depend on the <code>dateFormatType</code>.
<p>This constructor just calls the {@link
DateLayout#setDateFormat} method.
*/
public TTCCLayout(String dateFormatType) {
this.setDateFormat(dateFormatType);
}
/**
The <b>ThreadPrinting</b> option specifies whether the name of the
current thread is part of log output or not. This is true by default.
*/
public void setThreadPrinting(boolean threadPrinting) {
this.threadPrinting = threadPrinting;
}
/**
Returns value of the <b>ThreadPrinting</b> option.
*/
public boolean getThreadPrinting() {
return threadPrinting;
}
/**
The <b>CategoryPrefixing</b> option specifies whether {@link Category}
name is part of log output or not. This is true by default.
*/
public void setCategoryPrefixing(boolean categoryPrefixing) {
this.categoryPrefixing = categoryPrefixing;
}
/**
Returns value of the <b>CategoryPrefixing</b> option.
*/
public boolean getCategoryPrefixing() {
return categoryPrefixing;
}
/**
The <b>ContextPrinting</b> option specifies log output will include
the nested context information belonging to the current thread.
This is true by default.
*/
public void setContextPrinting(boolean contextPrinting) {
this.contextPrinting = contextPrinting;
}
/**
Returns value of the <b>ContextPrinting</b> option.
*/
public boolean getContextPrinting() {
return contextPrinting;
}
/**
In addition to the level of the statement and message, the
returned byte array includes time, thread, category and {@link NDC}
information.
<p>Time, thread, category and diagnostic context are printed
depending on options.
*/
public void format(java.io.Writer output, LoggingEvent event) throws java.io.IOException {
buf.setLength(0);
dateFormat(buf, event);
output.write(buf.toString());
if (this.threadPrinting) {
output.write('[');
output.write(event.getThreadName());
output.write("] ");
}
output.write(event.getLevel().toString());
output.write(' ');
if (this.categoryPrefixing) {
output.write(event.getLoggerName());
output.write(' ');
}
if (this.contextPrinting) {
String ndc = event.getNDC();
if (ndc != null) {
output.write(ndc);
output.write(' ');
}
}
output.write("- ");
output.write(event.getRenderedMessage());
output.write(LINE_SEP);
}
/**
The TTCCLayout does not handle the throwable contained within
{@link LoggingEvent LoggingEvents}. Thus, it returns
<code>true</code>.
@since version 0.8.4 */
public boolean ignoresThrowable() {
return true;
}
}