Apache log4cxx  Version 0.13.0
log4cxx::TTCCLayout Class Reference

TTCC layout format consists of time, thread, logger name and nested diagnostic context information, hence the name. More...

#include <ttcclayout.h>

Inheritance diagram for log4cxx::TTCCLayout:
log4cxx::helpers::DateLayout log4cxx::Layout log4cxx::spi::OptionHandler log4cxx::helpers::Object log4cxx::helpers::Object

Public Member Functions

 TTCCLayout ()
 Instantiate a TTCCLayout object with RelativeTimeDateFormat as the date formatter in the local time zone. More...
 
 TTCCLayout (const LogString &dateFormatType)
 Instantiate a TTCCLayout object using the local time zone. More...
 
void setThreadPrinting (bool threadPrinting1)
 The ThreadPrinting option specifies whether the name of the current thread is part of log output or not. More...
 
bool getThreadPrinting () const
 Returns value of the ThreadPrinting option. More...
 
void setCategoryPrefixing (bool categoryPrefixing1)
 The CategoryPrefixing option specifies whether Logger name is part of log output or not. More...
 
bool getCategoryPrefixing () const
 Returns value of the CategoryPrefixing option. More...
 
void setContextPrinting (bool contextPrinting1)
 The ContextPrinting option specifies log output will include the nested context information belonging to the current thread. More...
 
bool getContextPrinting () const
 Returns value of the ContextPrinting option. More...
 
void setFilePrinting (bool filePrinting1)
 The FilePrinting option specifies log output will include the file and the line where the log statement was written. More...
 
bool getFilePrinting () const
 Returns value of the ContextPrinting option. More...
 
virtual void format (LogString &output, const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool) const
 In addition to the level of the statement and message, this function writes to the ouput stream time, thread, logger and NDC information. More...
 
virtual bool ignoresThrowable () const
 The TTCCLayout does not handle the throwable contained within LoggingEvents. More...
 
- Public Member Functions inherited from log4cxx::helpers::DateLayout
 DateLayout (const LogString &dateLayoutOption)
 
virtual ~DateLayout ()
 
virtual void activateOptions (log4cxx::helpers::Pool &p)
 Activate the options that were previously set with calls to option setters. More...
 
virtual void setOption (const LogString &option, const LogString &value)
 Set option to value. More...
 
void setDateFormat (const LogString &dateFormat1)
 The value of the DateFormat option should be either an argument to the constructor of helpers::DateFormat or one of the strings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601. More...
 
const LogStringgetDateFormat () const
 Returns value of the DateFormat option. More...
 
void setTimeZone (const LogString &timeZone)
 The TimeZoneID option is a time zone ID string in the format expected by the locale C++ standard class. More...
 
const LogStringgetTimeZone () const
 Returns value of the TimeZone option. More...
 
void formatDate (LogString &s, const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p) const
 
- Public Member Functions inherited from log4cxx::Layout
virtual ~Layout ()
 
virtual LogString getContentType () const
 Returns the content type output by this layout. More...
 
virtual void appendHeader (LogString &output, log4cxx::helpers::Pool &p)
 Append the header for the layout format. More...
 
virtual void appendFooter (LogString &output, log4cxx::helpers::Pool &p)
 Append the footer for the layout format. More...
 
- Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 

Additional Inherited Members

- Protected Attributes inherited from log4cxx::helpers::DateLayout
DateFormatPtr dateFormat
 

Detailed Description

TTCC layout format consists of time, thread, logger name and nested diagnostic context information, hence the name.

Each of the four fields can be individually enabled or disabled. The time format depends on the DateFormat used.

Here is an example TTCCLayout output with the RelativeTimeDateFormat.

176 [main] INFO  examples.Sort - Populating an array of 2 elements in reverse order.
225 [main] INFO  examples.SortAlgo - Entered the sort method.
262 [main] DEBUG examples.SortAlgo.OUTER i=1 - Outer loop.
276 [main] DEBUG examples.SortAlgo.SWAP i=1 j=0 - Swapping intArray[0] = 1 and intArray[1] = 0
290 [main] DEBUG examples.SortAlgo.OUTER i=0 - Outer loop.
304 [main] INFO  examples.SortAlgo.DUMP - Dump of interger array:
317 [main] INFO  examples.SortAlgo.DUMP - Element [0] = 0
331 [main] INFO  examples.SortAlgo.DUMP - Element [1] = 1
343 [main] INFO  examples.Sort - The next log statement should be an error message.
346 [main] ERROR examples.SortAlgo.DUMP - Tried to dump an uninitialized array.
467 [main] INFO  examples.Sort - Exiting main method.

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 logger to which the statement belongs.

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.

WARNING 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.

PatternLayout offers a much more flexible alternative.

Constructor & Destructor Documentation

◆ TTCCLayout() [1/2]

log4cxx::TTCCLayout::TTCCLayout ( )

Instantiate a TTCCLayout object with RelativeTimeDateFormat as the date formatter in the local time zone.

◆ TTCCLayout() [2/2]

log4cxx::TTCCLayout::TTCCLayout ( const LogString dateFormatType)

Instantiate a TTCCLayout object using the local time zone.

The DateFormat used will depend on the dateFormatType.

This constructor just calls the DateLayout::setDateFormat method.

Member Function Documentation

◆ format()

virtual void log4cxx::TTCCLayout::format ( LogString output,
const spi::LoggingEventPtr event,
log4cxx::helpers::Pool pool 
) const
virtual

In addition to the level of the statement and message, this function writes to the ouput stream time, thread, logger and NDC information.

Time, thread, logger and diagnostic context are printed depending on options.

Parameters
outputdestination to receive formatted output.
eventevent to format.
poolpool used to allocate memory needed during formatting.

Implements log4cxx::Layout.

◆ getCategoryPrefixing()

bool log4cxx::TTCCLayout::getCategoryPrefixing ( ) const
inline

Returns value of the CategoryPrefixing option.

◆ getContextPrinting()

bool log4cxx::TTCCLayout::getContextPrinting ( ) const
inline

Returns value of the ContextPrinting option.

◆ getFilePrinting()

bool log4cxx::TTCCLayout::getFilePrinting ( ) const
inline

Returns value of the ContextPrinting option.

◆ getThreadPrinting()

bool log4cxx::TTCCLayout::getThreadPrinting ( ) const
inline

Returns value of the ThreadPrinting option.

◆ ignoresThrowable()

virtual bool log4cxx::TTCCLayout::ignoresThrowable ( ) const
inlinevirtual

The TTCCLayout does not handle the throwable contained within LoggingEvents.

Thus, it returns true.

Implements log4cxx::Layout.

◆ setCategoryPrefixing()

void log4cxx::TTCCLayout::setCategoryPrefixing ( bool  categoryPrefixing1)
inline

The CategoryPrefixing option specifies whether Logger name is part of log output or not.

This is true by default.

◆ setContextPrinting()

void log4cxx::TTCCLayout::setContextPrinting ( bool  contextPrinting1)
inline

The ContextPrinting option specifies log output will include the nested context information belonging to the current thread.

This is true by default.

◆ setFilePrinting()

void log4cxx::TTCCLayout::setFilePrinting ( bool  filePrinting1)
inline

The FilePrinting option specifies log output will include the file and the line where the log statement was written.

◆ setThreadPrinting()

void log4cxx::TTCCLayout::setThreadPrinting ( bool  threadPrinting1)
inline

The ThreadPrinting option specifies whether the name of the current thread is part of log output or not.

This is true by default.


The documentation for this class was generated from the following file: