Logging in Java Adapters

improve this page | report issue


This tutorial provides the required code snippets in order to add logging capabilities in a Java adapter.

Logging example

Import the java logging package:

import java.util.logging.Logger;

Define a logger:

static Logger logger = Logger.getLogger(JavaLoggerTestResource.class.getName());

Now inside a method include logging:

logger.warning("Logging warning message...");

This message outputs to the trace.log file of the application server. If the server administrator is forwarding logs from the MobileFirst Server to the MobileFirst Analytics Server the logger message will also appear in the Infrastructure → Server Log Search view in the MobileFirst Analytics Console.

Accessing the log files

Forwarding Logs to the Analytics server

Logs can also be forwarded to the Analytics console.

  1. In MobileFirst Operations Console select the Settings option from the sidebar navigation.
  2. Click the Edit button in the Runtime Properties tab.
  3. In the Analytics → Additional packages section, specify the class name of the Java adapter, for example com.sample.JavaLoggerTestResource, to forward logs to the MobileFirst Server.

Log filtering from the console

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on December 12, 2017