kubernetesguacamole

How to set logging level to DEBUG in Guacamole


I'm just trying to set the log level of Guacamole to DEBUG.. I've successfully set the logging level for guacd and tried multiple environment variables for the guacamole container but it's still not working.. I've found a logging.properties file in the Guacamole container at path: /home/guacamole/tomcat/conf/logging.properties. Is it possible to configure the logging file path so I can add a custom logging.properties file?

The current state of the deployment.yml file looks like this:

# apiVersion: v1
# kind: ConfigMap
# metadata:
#   name: logback
#   namespace: $NAMESPACE
# data:
#   logback.xml: |
#     <configuration>
#
#     <!-- Appender for debugging -->
#     <appender name="GUAC-DEBUG" class="ch.qos.logback.core.ConsoleAppender">
#         <encoder>
#             <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
#         </encoder>
#     </appender>
#
#     <appender name="GUAC-DEBUG-2" class="org.apache.juli.ClassLoaderLogManager">
#         <encoder>
#             <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
#         </encoder>
#     </appender>
#
#     <!-- Log at DEBUG level -->
#     <root level="debug">
#         <appender-ref ref="GUAC-DEBUG"/>
#     </root>
#
#     <root level="debug">
#         <appender-ref ref="GUAC-DEBUG-2"/>
#     </root>
#
#     </configuration>

apiVersion: v1
kind: ConfigMap
metadata:
  name: logging
  namespace: $NAMESPACE
data:
  logging.properties: |
    handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

    .handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

    ############################################################
    # Handler specific properties.
    # Describes specific configuration info for Handlers.
    ############################################################

    1catalina.org.apache.juli.AsyncFileHandler.level = FINE
    1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
    1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
    1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8

    2localhost.org.apache.juli.AsyncFileHandler.level = FINE
    2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
    2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
    2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8

    3manager.org.apache.juli.AsyncFileHandler.level = FINE
    3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
    3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
    3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

    4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
    4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
    4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
    4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

    java.util.logging.ConsoleHandler.level = FINE
    java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
    java.util.logging.ConsoleHandler.encoding = UTF-8


    ############################################################
    # Facility specific properties.
    # Provides extra control for each logger.
    ############################################################

    org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = FINE
    org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

    org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = FINE
    org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

    org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = FINE
    org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

    # For example, set the org.apache.catalina.util.LifecycleBase logger to log
    # each component that extends LifecycleBase changing state:
    #org.apache.catalina.util.LifecycleBase.level = FINE

    # To see debug messages in TldLocationsCache, uncomment the following line:
    #org.apache.jasper.compiler.TldLocationsCache.level = FINE

    # To see debug messages for HTTP/2 handling, uncomment the following line:
    #org.apache.coyote.http2.level = FINE

    # To see debug messages for WebSocket handling, uncomment the following line:
    #org.apache.tomcat.websocket.level = FINE
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: guacamole
  namespace: $NAMESPACE
  labels:
    app: guacamole
spec:
  replicas: 1
  selector:
    matchLabels:
      app: guacamole
  template:
    metadata:
      labels:
        app: guacamole
    spec:
      containers:
      - name: guacd
        image: docker.io/guacamole/guacd:$GUACAMOLE_GUACD_VERSION
        env:
        - name: GUACD_LOG_LEVEL
          value: "debug"
        ports:
        - containerPort: 4822
        securityContext:
          runAsUser: 1000
          runAsGroup: 1000
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
      - name: guacamole
        image: docker.io/guacamole/guacamole:$GUACAMOLE_GUACAMOLE_VERSION
        env:
        - name: GUACD_HOSTNAME
          value: "localhost"
        - name: GUACD_PORT
          value: "4822"
        - name: POSTGRES_HOSTNAME
          value: "database-url.nl"
        - name: POSTGRES_PORT
          value: "5432"
        - name: POSTGRES_DATABASE
          value: "guacamole"
        - name: POSTGRES_USER
          value: "guacamole_admin"
        - name: POSTGRES_PASSWORD
          value: "guacamoleadmin"
        - name: HOME
          value: "/home/guacamole"
        - name: GUACAMOLE_LOG_LEVEL
          value: "debug"
        - name: JAVA_TOOL_OPTIONS
          value: "-Djava.util.logging.config.file=/home/guacamole/logging.properties"
        ports:
        - name: http
          containerPort: 8080
        - name: https
          containerPort: 8443
        volumeMounts:
          # - name: logback
          #   mountPath: /home/guacamole/logback.xml
          #   subPath: logback.xml
          - name: logging
            mountPath: /home/guacamole/logging.properties
            subPath: logging.properties
        securityContext:
          runAsUser: 1001
          runAsGroup: 1001
          allowPrivilegeEscalation: false
          runAsNonRoot: true
      volumes:
        # - name: logback
        #   configMap:
        #     name: logback
        - name: logging
          configMap:
            name: logging

UPDATE 1: According to this page it's possible to add custom logging configuration by adding the logback.xml file in the GUACAMOLE HOME folder, but this didn't fixed it. I've added this logback.xml file via a ConfigMap

UPDATE 2: I can see in the logging of the Guacamole container it adds the following Java Option: -Djava.util.logging.config.file=/home/guacamole/tomcat/conf/logging.properties. So I added the following environment variable to edit this config path and added my own logging.properties file via a ConfigMap:

- name: JAVA_TOOL_OPTIONS
  value: "-Djava.util.logging.config.file=/home/guacamole/logging.properties"

I've updated the deployment.yml file so you can see the current state of the file.. According to the logging it updates the argument correctly, but one line later it overwrites the same argument with the old path..

Anybody ideas? :')


Solution

  • I got in contact with Guacamole support.

    For the people they're experiencing the same issue because the people from Guacamole didn't documented this yet, you can use the environment variable LOGBACK_LEVEL.