Bootstrap FreeKB - Konga - Konga logs on Docker
Konga - Konga logs on Docker

Updated:   |  Konga articles

Let's say Konga has been deployed to a Docker container. The KONGA_LOG_LEVEL environment variable can be used to tell Konga to log at one of the following log levels.

  • silly
  • debug (default for non-prod)
  • info
  • warn (default for prod)
  • error

Let's say you are deploying Konga via Docker Compose. In this example, you could define the KONGA_LOG_LEVEL in the docker-compose.yml file.

services:
  konga:
    image: docker.example.com/konga/konga:0.14.7
    networks:
      - kong
    deploy:
      replicas: 1
      placement: 
        constraints: 
           - node.labels.gateway == true
      restart_policy:
        condition: on-failure
        delay: 1m
        window: 2m
        max_attempts: 10
    logging:
      driver: gelf
      options:
        gelf-address: "udp://server001:12201"
        tag: "{{.DaemonName}}/{{.Name}}"
    environment:
      DB_ADAPTER: postgres
      DB_HOST: kong_database
      DB_USER: kong
      DB_DATABASE: konga_db
      NODE_ENV: production
      KONGA_LOG_LEVEL: silly
    ports:
      - "1337:1337"

 

The docker ps command can be used to determine if the Konga container is running.

docker ps

CONTAINER ID     IMAGE              COMMAND                 CREATED         STATUS     PORTS     NAMES
d937372c09ab9    b939aa938add9913   "/docker-entrypoin..."  6 minutes ago   Created              konga001                                                                  

 

Assuming the Kong container is running, the docker exec command can be used to access the Konga container.

docker exec -it konga001 bash

 

Let's say the Konga application has been deployed to the /app directory. In this scenario, the /app/config/log.js file will contain contain the log level and log location.

module.exports = {
  log: {
    level: 'info',
    filePath: 'logs/application.log'
  }
};

 

winston.Logger is often used to append events to a log file, meaning that log.js would be updated to have the following to append Konga events to a log file named konga.log.

var winston = require('winston');
var customLogger = new winston.Logger();

customLogger.add(winston.transports.File, {
  level: 'info',
  filename: 'konga.log',
  json: false
});

module.exports.log = {
  level: 'info',
  custom: customLogger,
  inspect: false
};

 

Likewise, the /app/config/env/development.js or production.js file will contain the log level.

'use strict';

var fs = require('fs');

module.exports = {
  log: {
    level: process.env.KONGA_LOG_LEVEL || "debug"
  }
};

 

Then issue the npm start command to start Konga.

npm start

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 40afda in the box below so that we can be sure you are a human.