Skip to content

Logging

It is possible for a plugin algorithm to write information into the job logs, and consequently, Delphix Masking Engine logs. This is accomplished by using calling the getLogService method of the ServiceProvider interface provided at the algorithm setup. The resulting LogService object may be used to make logging entries at various levels of severity. The available log levels are ERROR, WARNING, INFO, and DEBUG.

The log interface is provided to allow for debugging output during algorithm development, and for reporting of statistical or similar values detailing the overall operation of the algorithm, typically in the tearDown method.

Logging Security Warning

An algorithm must never log unmasked values (the input argument to the mask method) to the log files. The job and Masking Engine log files may be retrieved by engine users and are included support bundles.

Logging Verbosity

Algorithms also should not log progress messages or other verbose details, especially from the mask method, as this will fill the log files with messages and may impact job performance. There is a rate-limiting mechanism that limits the volume of messages each algorithm can write over time, but any amount of routine logging is likely to diminish the overall usefulness of the logs by obscuring more important messages.

Example Code

This example is take from the StringRedaction sample algorithm provided with the SDK:

public class StringRedaction implements MaskingAlgorithm<String> {
    ...
    private LogService logger;
    ....

    @Override
    public String mask(@Nullable String input) throws MaskingException {
        if (input == null) {
            return null;
        }

        if (random.nextDouble() < 0.1) {
            logger.info("{0}: Masked {1} values", getName(), count);
        }

        StringBuilder returnVal = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            returnVal.append(redactionCharacter);
        }
        count++;
        return returnVal.toString();
    }

    @Override
    public void validate() throws ComponentConfigurationException {
        if (redactionCharacter == null || redactionCharacter.length() != 1) {
            throw new ComponentConfigurationException(
                    "redactionCharacter must be a single character");
        }
    }

    @Override
    public void setup(@Nonnull ComponentService serviceProvider) {
        logger = serviceProvider.getLogService();
    }

    @Override
    public void tearDown() {
        logger.info("{0}: Masked a total of {1} values", getName(), count);
        count = 0;
    }

Some methods and fields elided for the sake of brevity

The relevant details here:

  • The setup method uses the provided ComponentService object to get a LogService instance, saving it as logger.
  • The mask method calls the logger's info method to write informational messages at random during execution. This kind of "progress" logging may be useful during development but should be removed for algorithms before production deployment.
  • The tearDown method calls the info method of the logger again to record the total number of values masked.