Appendix: Logging Options String

This section describes the logging options when running qrunc and qcmgr.

Logging Options String, -l

The logging options string, -l, allows QNX Container components to specify options for logging the output from the component using common command line arguments.

The logging options string has the following specifications:
  • The options are specified as a single string in the form
    <option1>=<value1>,<option2>=<value2>,<option3>=<value3>,...
  • Each option must be specified in the form <option>=<value> with no spaces after the equals sign.
  • Options are separated by a comma , with no spaces allowed before or after the comma. Thus, commas aren't allowed in any of the option's values.

Options

The following table shows the supported logging options and the allowed values along with any defaults:
Option Valid Values Default Values
locations (Mandatory) Log output location. Can be any combination of stdout, stderr, file and slog2 separated by a | character. N/A
verbosity (Mandatory) The maximum verbosity to show for logs. Can be one of the following: shutdown, critical, error, warning, notice, info, debug1, and debug2. N/A
prefix An optional string prepended to all log messages. This prefix is ignored if location=slog2 is selected. NULL
file Absolute path to the file to write logs to. Must only be specified if location=file is selected. NULL
bufsize The maximum buffer size (in bytes) for each log message. Must be at least the length of (prefix string + 9) and less than 2048. 256
slogpages Number of 4K pages to use with system logger. Must be specified if location=slog2 is selected. N/A
slogcode The code value to use when location=slog2 is selected. 0

Sample Configurations

Below are some sample logging options string configurations to illustrate usage.

  • Configure logging to direct output to stdout, with a prefix string specified and verbosity set to debug2:
    "locations=stdout,prefix=qcmgr:,verbosity=debug2"
  • Configure logging to use the system logger and verbosity to set to info:
    "locations=slog2,slogpages=8,verbosity=info"
  • Configure logging to direct output to stdout, system logger and a file - with a maximum buffer size and a slogcode set:
    "locations=slog2|stdout|file,bufsize=512,prefix=sampl:e,verbosity=warning,slogpages=8,slogcode=32,file=/tmp/sample_log.txt"

Writing Beyond the Configured Log Buffer Size

When initializing the logging library using qcl_init(), the buffer size must be large enough to hold the entire formatted log message.

This includes not only the message itself but also:
  • Log type (e.g., [SHD])
  • Prefix
  • An underscore (_)
  • A newline character (\n)
  • A null terminator (\0)

To ensure consistent validation across all output locations, this buffer size requirement still applies when only slog2 is selected, which doesn't require a prefix and log type.

Example configuration:
  • prefix = None
  • bufsize = 15
  • npages = 8
  • slogcode = 1

When using qcl_error() to log a message (e.g., "This is larger than 9 bytes\n"), the output gets truncated due to the limited buffer size and last character gets replaced with an underscore (_) to signal truncation.

Resulting output:
  • For STDOUT, STDERR, and file locations: [SHD] This i_
  • For SLOG2: This i_
Page updated: