Skip to content

Logs

Where are the adapter logs stored locally?

Logs generated by mp-test or mp-build are stored in the logs subdirectory of the project.


Where are the adapter logs stored in VCF Operations?

Logs are generated and stored on the cloud proxy where the adapter is running at $ALIVE_BASE/user/log/adapters/<ADAPTERKEY>/<ADAPTER_INTERNAL_INSTANCE_ID>.

ADAPTERKEY should match the adapter key used in the manifest.txt, and the ADAPTER_INTERNAL_INSTANCE_ID should match the Internal ID found in VCF Operations at Environment → Inventory → Adapter Instances → <ADAPTER_DISPLAY_NAME> → <ADAPTER_INSTANCE> in the rightmost column. The Internal ID column is not displayed by default. To display the Internal ID, enable the Internal ID column by clicking the lower left 'column' icon and then checking the Internal ID box.

highlight of the checkbox where internal id can be enabled

highlight of the internal id


What are the different log files used for?

There are five types of log files: adapter, server, build, test, and validation logs. Each log file is prepended with the type of log file followed by a number that represents rollover.

  • server.log: Contains all logs related to the HTTP server inside the container. Server logs can't be modified since the server code comes packaged inside the base-adapter Python image.

  • adapter.log Contains all logs related to the adapter. Adapter logs are all the logs generated by adapter code (e.g., the test() method or the collect() methods inside app/adapter.py).

  • test.log Contains all logs related to mp-test.

  • build.log Contains all logs related to mp-build.

  • validation.log Contains a log of the validations performed by mp-test on the collection results. Validation logs are only generated locally.


How do I add logs to my adapter?

The template adapter defines a logger variable in the adapter.py file that configures all adapter logging using adapter_logging from the Python SDK. The logger only needs to be configured once; to generate logs in other files, simply import the Python logging module. Eg.

import logging

logger = logging.getLogger(__name__)

def my_method():
  logger.info("info log")
  logger.warning("warning log")
  logger.error("error log")
  logger.debug("debug log")
   ...

Adapter logging is setup via the Setup Logging method available through the AdapterLogger class of the Java Integrations SDK. The logger only need to be set up once. To retrieve the logger, you can call the Get Logger static method:

import org.apache.logging.log4j.Logger;
import com.vmware.aria.operations.AdapterLogger;

public Class Adapter {
  public void myMethod() {
    Logger logger = AdapterLogger.getLogger();
    logger.info("info log");
    logger.warning("warning log");
    logger.error("error log");
    logger.debug("debug log");
  }

  public void myOtherMethod() {
    Logger logger = AdapterLogger.getLogger();
    logger.info("other info log");
    logger.warning("other warning log");
    logger.error("other error log");
    logger.debug("other debug log");
  }

  public static void main(String[] args){
    AdapterLogger.setupLogging("Adapter");
    Adapter instance = new Adapter();
    instance.myMethod();
    instance.myOtherMethhod();
  }
}

How can I change the amount of logs that are retained, or the log rotation frequency?

The setup logging function has a number of options that can be configured to make logging work for your needs. By default, the templates are set up so that there is no limit on the size of a log file, but the log file will rotate every time an adapter method is called (generally every 5 minutes). This makes it easy to tell what happened in any given collection, but it may not retain enough history for some purposes. To adjust how this works, the setup logging call can be made with two optional parameters: The file count, and the max size (in bytes) for a log file.

The file count controls how many log files are retained. The default value is 5, which would result in a maximum of 5 log files before the oldest will be overwritten for the newest.

The max size controls how large a single log file can be before it is automatically rolled over. By default, this value is 0, which means that it is unlimited, but importantly the templates all perform a manual rollover each time the adapter is called to prevent the log files from continuously growing.

For example, one way to allow up to 50 MB of logs would be to allow up to 10 logs of 5 MB each (be sure to comment out or remote the 'rotate()' function).

Allow up to 10 logs of 5 MB each

logging.setup_logging("adapter.log", 10, 5_242_880)

Ensure there are no calls to 'logging.rotate()'

// Allow up to 10 logs of 5 MB each AdapterLogger.setupLogging("Adapter", 10, 5242880); Logger logger = AdapterLogger.getLogger(); // Ensure there are no calls to 'AdapterLogger.rotate();'


How do I change the server and/or adapter log level?

You can set the log levels for the server and adapter inside the loglevels.cfg file, which is located in logs/loglevels.cfg locally and on the cloud proxy at $ALIVE_BASE/user/log/adapters/<ADAPTERKEY>/<ADAPTER_INTERNAL_INSTANCE_ID>/loglevels.cfg. If the file does not exist, the system generates it after a collection/test.

ADAPTERKEY should match the name of the adapter used in the manifest.txt, and the ADAPTER_INTERNAL_INSTANCE_ID should match the Internal ID found in VCF Operations at Environment → Inventory → Adapter Instances → <ADAPTER_DISPLAY_NAME> → <ADAPTER_INSTANCE> in the rightmost column. The Internal ID column is not displayed by default. To display the Internal ID, enable the Internal ID column by clicking the lower left 'column' icon and then checking the Internal ID box.

highlight of the checkbox where internal id can be enabled

highlight of the internal id


How do I change the log level of mp-init, mp-test, or mp-build?

All SDK tools read the LOG_LEVEL environment variable to set the log level of their console output. For example, to set the log level of any of the CLI tools, we can set the LOG_LEVEL variable to the desired log level:

LOG_LEVEL=debug mp-build
LOG_LEVEL=debug mp-build
set LOG_LEVEL=debug
mp-build

Information

Set the log level back to info after debugging.

The SDK CLI tools support debug, warn, info, and error levels.