guideExport to PDF On-Premises logs

The logs from Export to PDF On-Premises are written to stdout and stderr. Most of them are formatted in JSON. They can be used for monitoring or debugging purposes. In production environments, we recommend storing the logs to files or using a distributed logging system (like ELK or CloudWatch).

# Docker

The docker has built-in logging mechanisms that capture logs from the output of the containers. The default logging driver writes the logs to files.

When using this driver, you can use the docker logs command to show logs from a container. You can add the -f flag to view logs in real time. Refer to the official Docker documentation for more information about the logs command.

When a container is running for a long period of time, logs can take up a lot of space. To avoid this problem, you should make sure that the log rotation is enabled. This can be set with the max-size option.

# Distributed logging

If you are running more than one instance of Export to PDF On-Premises, we recommend using a distributed logging system. It allows you to view and analyze logs from all instances in one place.

# AWS CloudWatch and other cloud solutions

If you are running Export to PDF On-Premises in the cloud, the simplest and recommended way is to use a service which is available at the selected provider. Here are some of the available services:

To use CloudWatch with AWS ECS, you have to create a log group before and change the log driver to awslogs. When the log driver is configured properly, logs will be streamed directly to CloudWatch.

The logConfiguration may look similar to this:

"logConfiguration": {
  "logDriver": "awslogs",
  "options": {
    "awslogs-region": "us-west-2",
    "awslogs-group": "cksource",
    "awslogs-stream-prefix": "ck-pdf-converter-logs"

Refer to the Using the awslogs Log Driver article for more information.

# On-premises solutions

If you are using your own infrastructure or for some reason cannot use the service offered by your provider, you can always use some on-premises distributed logging system.

There are a lot of solutions available, including:

  • ELK + Filebeat
    This is a stack built on top of Elasticsearch, Logstash and Kibana. In this configuration, Elasticsearch stores logs, Filebeat reads logs from Docker and sends them to Elasticsearch, and Kibana is used to view them. Logstash is not necessary because logs are already structured.

  • Fluentd
    It uses a dedicated Docker log driver to send the logs. It has a built-in frontend, but can also be integrated with Elasticsearch and Kibana for a better filtering.

  • Graylog
    It uses a dedicated Docker log driver to send the logs. It has a built-in frontend and needs Elasticsearch to store the logs as well as a MongoDB database to store the configuration.

# Example configuration

The example configuration uses Fluentd, Elasticsearch and Kibana to capture logs from Docker.

Before running Export to PDF On-Premises, you have to prepare the logging services. For the purposes of this example, Docker Compose is used. Create the fluentd, elasticsearch and kibana services inside the docker-compose.yml file:

version: '3.7'
    build: ./fluentd
      - ./fluentd/fluent.conf:/fluentd/etc/fluent.conf
      - "24224:24224"
      - "24224:24224/udp"

      - 9200
      - "9200:9200"

      ELASTICSEARCH_HOSTS: "http://elasticsearch:9200"
      - "5601:5601"

To integrate Fluentd with Elasticsearch, you first need to install fluent-plugin-elasticsearch in the Fluentd image. To do this, create a fluentd/Dockerfile with the following content:

FROM fluent/fluentd:v1.10-1

USER root

RUN apk add --no-cache --update build-base ruby-dev \
    && gem install fluent-plugin-elasticsearch \
    && gem sources --clear-all

Next, configure the input server and connection to Elasticsearch in the fluentd/fluent.conf file:

  @type forward
  port 24224
<match *.**>
  @type copy
    @type elasticsearch
    host elasticsearch
    port 9200
    logstash_format true
    logstash_prefix fluentd
    logstash_dateformat %Y%m%d
    include_tag_key true
    type_name access_log
    tag_key @log_name
    flush_interval 1s
    @type stdout

Now you are ready to run the services:

docker-compose up --build

When the services are ready, you can finally start Export to PDF On-Premises.

docker run --init -p 8080:8080 \
--log-driver=fluentd \
--log-opt fluentd-address=[Fluentd address]:24224 \
[Your config here] \[version]

Now open Kibana in your browser. It is available at http://localhost:5601/. In the first run, you may be asked about creating an index. Use the fluentd-* pattern and press the “Create” button. After this step, your logs should appear in the “Discover” tab.