Automic Workload Automation

 View Only

  • 1.  Setting AWI log level in AAKE

    Posted 22 days ago
    Edited by Michael A. Lowry 18 days ago

    What's the best way to set the default log level for the AWI in an AAKE system? Note that I'm not referring to Configuring the Log Level in AWI once it’s already running. I'm referring to the default log level used when the AWI first starts.

    In a non-Kubernetes system, one could do this by modifying logback.xml. However, it is not straightforward to modify files in the AWI image in AAKE systems. In at least two places (1, 2), the documentation states:

    In AAKE you have additional options to change the default log level. For more information see Configuring Container-Based Systems.

    However, the linked documentation page Configuring Container-Based Systems does not mention log levels at all.

    Is there a way to set the default AWI log level using only environment variables?

    See also my earlier discussion, Configure AWI via environment variables.



  • 2.  RE: Setting AWI log level in AAKE

    Posted 16 days ago
    Edited by Michael A. Lowry 16 days ago

    Here is the default logback.xml file from an AWI v24.4 pod:

    <configuration>
    	<!-- Logging configuration file. No changes necessary, unless directedy by Automic Support -->
    	<!-- copied from ecc-framework-webapp/src/main/webapp/config/logback.xml by build process -->
    	<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
    		<file>${AWI_LOG_FILE_PATH:-}${HOSTNAME}_${app_name:-AWI}_LOG_00.txt</file>
    		<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
    			<fileNamePattern>${AWI_LOG_FILE_PATH:-}${HOSTNAME}_${app_name:-AWI}_LOG_0%i.txt</fileNamePattern>
    			<minIndex>1</minIndex>
    			<maxIndex>9</maxIndex>
    		</rollingPolicy>
    		<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    			<maxFileSize>800MB</maxFileSize>
    		</triggeringPolicy>
    		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
    			<layout class="ch.qos.logback.classic.PatternLayout">
    				<pattern>%date{ISO8601} %-22(%.22thread) [%-5(%level)] %X{session.ae.system:-NOLOGIN}/%X{session.ae.user:--} %X{session.ui:-NOUI} %X{session.ae.id} %X{perflogger.id} [%.100logger] - %msg%n</pattern>
    			</layout>
    		</encoder>
    	</appender>
    	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    		<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
    			<layout class="ch.qos.logback.classic.PatternLayout">
    				<pattern>%date{ISO8601} %-22(%.22thread) [%-5(%level)] %X{session.ae.system:-NOSESSION}/%X{session.ae.user:--} %X{session.ui:-NOUI} %X{session.ae.id} %X{perflogger.id} [%.40logger] - %msg%n</pattern>
    			</layout>
    		</encoder>
    	</appender>
    	<!-- Configure async appenders with a 2000 entries queue. if the IO blocks or is too slow, and queue is half full, only warn/error will be logged -->
    	<appender name="LOGGER" class="ch.qos.logback.classic.AsyncAppender">
    		<queueSize>2000</queueSize>
    		<discardingThreshold>1000</discardingThreshold>
    		<appender-ref ref="${AWI_LOGBACK_APPENDER:-console}" />
    	</appender>
    	<!-- Log level is set here. Possible values: TRACE, DEBUG, INFO, WARN, ERROR
                 DEBUG is recommended on testing and development instances.
                 INFO is recommended on production instances.
             -->
    	<root level="INFO">
    		<appender-ref ref="LOGGER" />
    	</root>
    	<!-- trace loggers for Automation Engine - Change log level in uc4config.xml -->
    	<logger name="com.uc4.ecc.framework.core.aetracing" level="INFO" additivity="false">
    		<appender-ref ref="LOGGER" />
    	</logger>
    	<logger name="ECC BOOT" level="INFO" additivity="false">
    		<appender-ref ref="LOGGER" />
    	</logger>
    	<!--  performance logger - enable this to trace the performance of ecc -->
    	<logger name="com.uc4.webui.performance" level="OFF" additivity="false">
    		<appender-ref ref="LOGGER" />
    	</logger>
    	<!--  VaadinSessionLockUtil: logs known issues in thread handling. do not show stacktrace by default. -->
    	<logger name="com.uc4.ecc.framework.core.async.VaadinSessionLockUtil" level="INFO" additivity="false">
    		<appender-ref ref="LOGGER" />
    	</logger>
    	<!--  Push handler logs non-errors on error level, turn it off. If you experience any push/connection related problems, enable this temporarily -->
    	<logger name="com.vaadin.server.communication.PushHandler" level="OFF" additivity="false" />
    	<logger name="org.atmosphere.cpr.AtmosphereFramework" level="OFF" additivity="false" />
    	<logger name="org.apache.http.wire" level="OFF" additivity="false" />
    	<!-- activate for trace logging for the ECC servlet
            <logger name="com.uc4.webui.vaadin.framework.servlet" level="TRACE" additivity="false" >
                    <appender-ref ref="LOGGER" />
            </logger>
            -->
    </configuration>

    Here we see two environment variables:

    • AWI_LOGBACK_APPENDER
    • AWI_LOG_FILE_PATH

    AWI_LOGBACK_APPENDER is set to file. This is probable inherited from the pod definition. E.g.,

    awi:
      resources:
        requests:
          memory: "8G"
          cpu: "250m"
        limits:
          memory: "14G"
          cpu: "500m"
     logging:
        log: "file"
        pvc: "aake-pvc-logs"
    . . .

    AWI_LOG_FILE_PATH is set to temp/. This is probably the default. The AWI runs in the directory /usr/awi, so the logs are written to /usr/awi/temp.

    The logging level is not set based on a variable, but is hard-coded in this line:

    <root level="INFO">

    It is unclear how one would set the default logging level without modifying the logback.xml file.



  • 3.  RE: Setting AWI log level in AAKE

    Posted 16 days ago
    Edited by Michael A. Lowry 16 days ago

    The Logback documentation on variable substitution describes how variables work in Logback configuration files, and the syntax for specifying default values:

    Under certain circumstances, it may be desirable for a variable to have a default value if it is not declared or its value is null. As in the Bash shell, default values can be specified using the ":-" operator. For example, assuming the variable named aName is not defined, "${aName:-golden}" will be interpreted as "golden".

    Consider the appender-ref element in the definition of the LOGGER appender:

    <appender name="LOGGER" class="ch.qos.logback.classic.AsyncAppender">
    	<queueSize>2000</queueSize>
    	<discardingThreshold>1000</discardingThreshold>
    	<appender-ref ref="${AWI_LOGBACK_APPENDER:-console}" />
    </appender>

    This means:

    • if the environment variable1 AWI_LOGBACK_APPENDER is set, the LOGGER appender will delegate to the appender specified by AWI_LOGBACK_APPENDER, e.g, file.
    • otherwise, the LOGGER appender will delegate to the appender named console.

    With a small modification to the logback.xml file, a similar approach could be used to enable setting the default AWI log level via a variable.

    <root level="${AWI_LOG_LEVEL:-INFO}">
    	<appender-ref ref="LOGGER" />
    </root>

    Perhaps Broadcom already has something like this in mind. One reading of the inconsistent documentation is that this capability was planned but not delivered.

    Notes

    1. See the Logback documentation on scopes for detailed information on precedence in variable resolution.


  • 4.  RE: Setting AWI log level in AAKE

    Posted 13 days ago
    Edited by Michael A. Lowry 13 days ago

    With a small modification to the logback.xml file, a similar approach could be used to enable setting the default AWI log level via a variable.

    <root level="${AWI_LOG_LEVEL:-INFO}">
    	<appender-ref ref="LOGGER" />
    </root>

    I tested the above approach, and verified that it works. Here is a Dockerfile for a modified AWI image that replaces the default logback.xml file.

    # syntax=docker/dockerfile:1.10
    # AWI image with custom logback.xml file.
    
    # Define build arguments with default values
    ARG REGISTRY="containerregistry.mycompany.com"
    ARG AWI_REPOSITORY="awi"
    ARG VERSION="24.4.1.1"
    
    # Begin with vendor-supplied AWI image.
    FROM ${AWI_REGISTRY}/${AWI_REPOSITORY}:${AWI_VERSION}
    
    # Replace the default Logback configuration file
    COPY logback.xml /usr/awi/config/logback.xml
    
    # Start the AWI. These statements are based on the way Broadcom's own AWI image works.
    CMD ["cd", "/usr/awi"]
    ENTRYPOINT ["/bin/sh", "-c", "./entrypoint.sh"]

    Enjoy!