Apache log4cxx (Incubating)  Version 0.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
TTCCLayout Class Reference

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

Inheritance diagram for TTCCLayout:
DateLayout Layout OptionHandler ObjectImpl Object 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 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 Layout
virtual ~Layout ()
 
void addRef () const
 
void releaseRef () const
 
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 OptionHandler
virtual ~OptionHandler ()
 
- Public Member Functions inherited from Object
virtual const helpers::ClassgetClass () const
 
virtual ~Object ()
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 
- Public Member Functions inherited from ObjectImpl
 ObjectImpl ()
 
virtual ~ObjectImpl ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static const helpers::ClassgetStaticClass ()
 
static const
log4cxx::helpers::ClassRegistration
registerClass ()
 
- Protected Attributes inherited from DateLayout
DateFormatPtr dateFormat
 
- Protected Attributes inherited from ObjectImpl
unsigned int volatile ref
 

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

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
outputdestination to receive formatted output.
eventevent to format.
poolpool 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
inlinevirtual

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: