#37 Documentation here - How to use the init file.

open
nobody
None
5
2013-06-06
2007-03-30
pmdw
No

I can't create a user on the wiki to add this.
I am sure it will be of some use to someone if it could be added to the wiki or in the doc some where

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.

Discussion

  • Craig McQueen
    Craig McQueen
    2013-06-06

    I found it necessary to look in the source code (e.g. here from a code fork) to figure out its usage.

    For example, I had to look there to figure out that to log to syslog, I needed to specify appender LocalSyslogAppender. And I had to look there to find out that there's no way to make it log to console STDERR (there's only ConsoleAppender which logs to STDOUT).