Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Conversion Character

Effect

c

Category LogSystem
Used to output the logger of the logging event. The logger conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets.

If a precision specifier is given, then only the corresponding number of right most components of the logger name will be printed. By default the logger name is printed in full.

For example, for the logger name "a.b.c" the pattern c{2} will output "b.c".

d

Used to output the date of the logging event in UTC.

The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %d{%H:%M:%s} or %d{%d %b %Y %H:%M:%s}. If no date format specifier is given then %d{%d %m %Y %H:%M:%s} is assumed.

The Following format options are possible:

%a – Abbreviated weekday name

%A – Full weekday name

%b – Abbreviated month name

%B – Full month name

%c – Standard date and time string

%d – Day of month as a decimal(1-31)

%H – Hour(0-23)

%I – Hour(1-12)

%j – Day of year as a decimal(1-366)

%m – Month as decimal(1-12)

%M – Minute as decimal(0-59)

%p – Locale's equivalent of AM or PM

%q – milliseconds as decimal(0-999) – Log4CPLUS specific

%Q – fractional milliseconds as decimal(0-999.999) – Log4CPLUS specific

%S – Second as decimal(0-59)

%U – Week of year, Sunday being first day(0-53)

%w – Weekday as a decimal(0-6, Sunday being 0)

%W – Week of year, Monday being first day(0-53)

%x – Standard date string

%X – Standard time string

%y – Year in decimal without century(0-99)

%Y – Year including century as decimal

%Z – Time zone name

%% – The percent sign

Please refer to the documentation for the strftime() function in the <ctime> header for more information - http://man7.org/linux/man-pages/man3/strftime.3.html.

Example for ISO 8601 :
%d{%FT%T.%q}Z              -    2018-04-03T09:03:44.806Z
%d{%FT%T.%q}+00:00     -    2018-04-03T09:03:44.806+00:00

D

Used to output the date of the logging event in local time.

All of the above information applies.

Example for ISO 8601 :
%D{%FT%T.%q%z}                               -    2018-04-03T09:03:44.806-0400
%D{%FT%T.%q}%.-3D{%z}:%.2D{%z}  -    2018-04-03T09:03:44.806-04:00

E

Used to output the value of a given environment variable. The name of is supplied as an argument in brackets. If the variable does exist then empty string will be used.

For example, the pattern E{HOME} will output the contents of the HOME environment variable.

F

Used to output the file name where the logging request was issued.

NOTE: Unlike log4j, there is no performance penalty for calling this method.

h

Used to output the hostname of this system (as returned by gethostname(2)).

NOTE: The hostname is only retrieved once at initialization.

H

Used to output the fully-qualified domain name of this system (as returned by gethostbyname(2) for the hostname returned by gethostname(2)).

NOTE: The hostname is only retrieved once at initialization.

l

Equivalent to using "%F:%L"

NOTE: Unlike log4j, there is no performance penalty for calling this method.

m

Used to output the application supplied message associated with the logging event.

n

Outputs the platform dependent line separator character or characters.

p

Used to output the LogLevel of the logging event.

r

Used to output miliseconds since program start of the logging event.

t

Used to output the thread ID of the thread that generated the logging event. (This is either pthread_t value returned by pthread_self() on POSIX platforms or thread ID returned by GetCurrentThreadId() on Windows.)

T

Used to output alternative name of the thread that generated the logging event.

i

Used to output the process ID of the process that generated the logging event.

"%%"

The sequence "%%" outputs a single percent sign.

Troubleshooting

Using SocketTCPAppender. Standard error output has errors on timeout sending

...

Code Block
titleError log:
log4cplus:ERROR log4cplus::SocketTCPAppender127.0.0.1:1514) : Timeout sending ( 100000 us ). Starting reconnection to server. Next events will be skipped.

Description: Splunk server is a slow consumer. Appender disconnects connection after a timeout to avoid blocking threads of FIXEdge.

Solution: Set a larger value for property sendTimeout or use value '0' to switch off sending timeout.

Warning

Disabling timeout or large values for it means that logging has more priority than handling FIX traffic.