Examples

From Log4cpp

Jump to: navigation, search

Some links to examples about how to use log4cpp

examples provided by users of the log4cpp library

How to use the ini file

The following example was provided from https://sourceforge.net/users/pmdw/.

When using the Simple Configuration options in the log4cpp.init file this may help users configuring the log file

Command syntax as follows:

Each command is on entire line and is case sensitive <command> <category name> <layout type> <appender commands> <layout patterns>


<command>

valid commands are

  • appender
  • priority
  • category


<category name>

valid category name are

  • root
  • <user defined category in application>


<layout type>

valid layout types are

  • basic
  • simple
  • pattern


<appender commands>

valid appender commands are

  • file <followed by a log file name>
  • rolling <followed by a log file name> <the max size of the file> <and the max number of files to keep>
  • console
  • stdout
  • stderr
  • nteventlog <category name>
  • syslog <category name>
  • remotesyslog <category name>


<layout patterns>

The simple layout follows this pattern

%p - %m%n

The basic layout follows this pattern

%R %p %c %x: %m%n

Valid commands for pattern layout.

all commands for pattern are prefixed with %

all commands for pattern are case sensative

- %n = create new line ( this is usually at the end to make a new line break

- %m = Place the message here

- %c = Place the category name here

- %d = Place the date time stamp here

- %p = Place the message priority here

- %t = Place the thread name here

- %u = Place the processing time component here.

- %x = Place the Nested Diagnostic Context (NDC) here.

NDC is an instrument to distinguish interleaved log output from different sources.

Personal tools