How to use StreamBase logging from inside a custom Java function

How to use StreamBase logging from inside a custom Java function

book

Article ID: KB0074087

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7

Description

It's unclear how to get a Logger object from a custom Java function.  If I'm writing an embedded adapter, I call com.streambase.sb.operator.Operator.getLogger().  How do I get a reference to the current logger in a function?

Resolution

Here is an example function class and method demonstrating how to get the current logger.

The LogIt class and method is generated by the Java Function Wizard and its use in a Map Operator expression:
package com.sb.support;

import org.slf4j.*;

public class LogIt {

  public static boolean logWarn(String arg0) {
    final Logger logger = LoggerFactory.getLogger(LogIt.class);
    logger.warn(arg0);
    return true;
  }

}

This can be used in a Map operator expression as:
calljava("com.sb.support.LogIt","logWarn","Hello Test")

Issue/Introduction

Example to use StreamBase logging from inside a custom Java function