Logging in Java Adapters
This tutorial provides the required code snippets in order to add logging capabilities in a Java adapter.
Import the java logging package:
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
- In an on-prem installation of the MobileFirst Server, the file is available depending on the underlying application server.
- To get to the logs in a cloud deployment in:
Forwarding Logs to the Analytics server
Logs can also be forwarded to the Analytics console.
- In MobileFirst Operations Console select the Settings option from the sidebar navigation.
- Click the Edit button in the Runtime Properties tab.
- 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.