- Main Page
- Modules
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# TTCCLayout Class Reference

Inherits DateLayout.

List of all members.

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

## Public Member Functions

| TTCCLayout ()
| Instantiate a TTCCLayout object with RelativeTimeDateFormat as the date formatter in the local time zone.
| TTCCLayout (const LogString &dateFormatType)
| Instantiate a TTCCLayout object using the local time zone.
void | setThreadPrinting (bool threadPrinting1)
| The ThreadPrinting option specifies whether the name of the current thread is part of log output or not.
bool | getThreadPrinting () const
| Returns value of the ThreadPrinting option.
void | setCategoryPrefixing (bool categoryPrefixing1)
| The CategoryPrefixing option specifies whether Logger name is part of log output or not.
bool | getCategoryPrefixing () const
| Returns value of the CategoryPrefixing option.
void | setContextPrinting (bool contextPrinting1)
| The ContextPrinting option specifies log output will include the nested context information belonging to the current thread.
bool | getContextPrinting () const
| Returns value of the ContextPrinting option.
void | setFilePrinting (bool filePrinting1)
| The FilePrinting option specifies log output will include the file and the line where the log statement was written.
bool | getFilePrinting () const
| Returns value of the ContextPrinting option.
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.
virtual bool | ignoresThrowable () const
| The TTCCLayout does not handle the throwable contained within LoggingEvents.

## Constructor & Destructor Documentation

TTCCLayout | ( |  | ) |

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

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

virtual void 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:

  | output | destination to receive formatted output.
  | event | event to format.
  | pool | pool used to allocate memory needed during formatting.

Implements Layout.

bool getCategoryPrefixing | ( |  | ) | const`[inline]`

| Returns value of the CategoryPrefixing option.

bool getContextPrinting | ( |  | ) | const`[inline]`

| Returns value of the ContextPrinting option.

bool getFilePrinting | ( |  | ) | const`[inline]`

| Returns value of the ContextPrinting option.

bool getThreadPrinting | ( |  | ) | const`[inline]`

| Returns value of the ThreadPrinting option.

virtual bool ignoresThrowable | ( |  | ) | const`[inline, virtual]`

| The TTCCLayout does not handle the throwable contained within LoggingEvents. Thus, it returns `true`. Implements Layout.

void setCategoryPrefixing | ( | bool | categoryPrefixing1 | ) | `[inline]`

| The CategoryPrefixing option specifies whether Logger name is part of log output or not. This is true by default.

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

void setFilePrinting | ( | bool | filePrinting1 | ) | `[inline]`

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

void 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:

- ttcclayout.h