Configuring logging levels in running containers

In your official docker images, I see that there are ways to configure volumes, license, and credentials when starting containers. But is there a way to configure the level of transparency? Something like logging levels. The only logs we see are during startup about loaded fonts, license info, environment, content root, and finally which address it’s listening on.

When exceptions are raised during runtime, we see very minimal information and overall nothing helpful.

Is it possible to set a log level that lets us see more context about the running instances? Something like info, debug, and verbose levels are often seen in our industry as a way to tweak the amount of information available to sift through. Often, the errors we see now on the client side (i.e. content of response bodies) are also not helpful and we’re left wondering what the next steps should be other than opening more support tickets or a new topic in this forum.

@james-ontra

Could you please specify which Aspose product you are using and the environment in which you are running the containers? Additionally, are you looking for a specific logging framework or method to implement this logging level configuration?

Could you please specify which Aspose product you are using and the environment in which you are running the containers?

If you click through the link in my original message, you’ll see that the Aspose product we’re using is Aspose.Words. My topic also does not pertain to a specific environment. I’m inquiring about increasing the level of transparency in any environment.

Additionally, are you looking for a specific logging framework or method to implement this logging level configuration?

This has nothing to do with integrating logging frameworks. I understand this is an automated bot asking canned questions but I’ll clarify anyway:

The question is if there are options to configure logging levels on containers based on your official Aspose.Words images. Perhaps with more environment variables, something like:

docker run -e "LogLevel=DEBUG" # and so on ...

If so, please refer me to any documentation that I may have overlooked. If not, perhaps this is something your team will consider adding in later releases.

Let me check the documentation and current implementation, and I will return with more information.

Here’s the custom entrypoint and Dockerfile we use for our setup that allows configuring the log level. Hope it helps.

Dockerfile

FROM aspose/words-cloud:25.4
ENV S3_BUCKET_NAME=""
ENV S3_ENABLED=true
ENV DATA_DIR="/data"
ENV LOG_LEVEL="Information"

## Install required packages and AWS S3 filesystem
RUN apt-get update -y \
 && apt-get install -y curl \
 && curl --silent --location --max-time 30 \
         --output mount-s3.deb https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.deb \
 && apt-get install -y ./mount-s3.deb \
 && rm -rf ./mount-s3.deb /var/lib/apt/lists/* \
 && mkdir -p /data \
 && sed -i 's/^#\?user_allow_other/user_allow_other/' /etc/fuse.conf

COPY common.sh entrypoint.sh /app/
ENTRYPOINT ["/app/entrypoint.sh"]

common.sh

#!/usr/bin/env bash

# Common utility functions

# Usage: log [level] [message]
# If no level is provided, it defaults to "info"
log() {
    if [[ $# -eq 1 ]]; then
        local level="info"
        local message="${1}"
    else
        local level="${1}"
        local message="${2}"
    fi

    if [[ "$level" == "error" || "$level" == "warn" ]]; then
        echo "${level}: ${message}" >&2
    else
        echo "${level}: ${message}"
    fi
}

# Log an error and exit with a given code (default 1)
die() {
    log "error" "$1"
    exit "${2:-1}"
}

entrypoint.sh

#!/usr/bin/env bash

# Entrypoint for the Aspose.Words.Cloud.WebApp container
# It updates the configuration file with the environment
# variables and mounts the S3 bucket if enabled
#
# Environment variables:
# - S3_ENABLED: Whether to enable S3 mounting
# - S3_BUCKET_NAME: The name of the S3 bucket to mount
# - DATA_DIR: The directory to mount the S3 bucket to
# - LOG_LEVEL: The log level to use
set -euo pipefail

# Source common utility functions
# shellcheck disable=SC1091
source "$(dirname "$0")/common.sh"

CONFIG_FILE="${1:-/app/configuration/words-api.json}"
# Update the DataFolder in the configuration file
if [[ -f "$CONFIG_FILE" ]]; then
    log "Updating DataFolder in configuration file to $DATA_DIR"
    log "Updating LogLevel in configuration file to $LOG_LEVEL"
    sed -i \
        -e 's#"DataFolder": "[^"]*"#"DataFolder": "'"$DATA_DIR"'"#' \
        -e 's#"Default": "[^"]*"#"Default": "'"$LOG_LEVEL"'"#' \
        -e 's#"System": "[^"]*"#"System": "'"$LOG_LEVEL"'"#' \
        -e 's#"Microsoft": "[^"]*"#"Microsoft": "'"$LOG_LEVEL"'"#' \
        "$CONFIG_FILE"
fi

if [[ "$S3_ENABLED" = "true" ]]; then
  [[ -z "$S3_BUCKET_NAME" ]] && die "S3_BUCKET_NAME is not set."

  # Mount the S3 bucket
  mount-s3 --debug --allow-delete --allow-overwrite --incremental-upload "$S3_BUCKET_NAME" "$DATA_DIR"
  if [[ $? -ne 0 ]]; then
    die "Failed to mount S3 bucket $S3_BUCKET_NAME"
  fi
else
  log "S3 mounting is disabled. Proceeding without S3 mount."
fi

exec dotnet Aspose.Words.Cloud.WebApp.dll