Skip to content

Latest commit

 

History

History

logger

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Zap Structured Logging

Configuration loading is designed for containerization in mind. The container engine and orchestrator can mount volumes (secret or regular) as well as set the environment variables as outlined below.

You may set configurations through both files and environment variables. Please note that environment variables will override the settings in the configuration files. The configuration files are all expected to be in YAML format.


Table of contents


Zap Structured Logging

Structured logging is handled through Zap. Please refer to Zap's documentation on how to set the fields below.

Only the BuiltinConfig and BuiltinEncoder settings can be provided through environment variables that override values from the configuration files.


File Location(s)

The configuration loader will search for the configurations in the following order:

Location Details
/etc/MCQPlatform.conf/ The etc directory is the canonical location for configurations.
$HOME/.MCQPlatform/ Configurations can be located in the user's home directory.
./configs/ The config folder in the root directory where the application is located.
Environment variables Finally, the configurations will be loaded from environment variables and override configuration files

Configuration File

The expected file name is LoggerConfig.yaml. All the configuration items below are required.

If specifying settings for the General Config or Encoder Config, all values must be provided.

Name Environment Variable Key Type Description
BuiltinConfig LOGGER_BUILTINCONFIG string Must be one of Development or Production. Required.
BuiltinEncoderConfig LOGGER_BUILTINENCODERCONFIG string Must be one of Development or Production. Required.
General Config Not applicable. General Configurations. Please refer to Zap user documentation.
↳ development boolean
↳ disableCaller boolean
↳ disableStacktrace boolean
↳ encoding string
↳ outputPaths string array
↳ errorOutputPaths string array
Encoder Config Not applicable. Encoder Configurations. Please refer to Zap user documentation.
↳ messageKey string
↳ levelKey string
↳ timeKey string
↳ nameKey string
↳ callerKey string
↳ functionKey string
↳ stacktraceKey string
↳ skipLineEnding boolean
↳ lineEnding string
↳ consoleSeparator string

Example Configuration File

builtin_config: Development | Production
builtin_encoder_config: Development | Production
general_config:
  development: boolean
  disableCaller: boolean
  disableStacktrace: boolean
  encoding: string
  outputPaths: [string, array]
  errorOutputPaths: [string, array]
encoder_config:
  messageKey: string
  levelKey: string
  timeKey: string
  nameKey: string
  callerKey: string
  functionKey: string
  stacktraceKey: string
  skipLineEnding: boolean
  lineEnding: string
  consoleSeparator: string

Example Environment Variables

export LOGGER_BUILTINCONFIG="Development"
export LOGGER_BUILTINENCODERCONFIG="Production"