Logging in JavaScript Adapters
improve this page | report issueOverview
This tutorial provides the required code snippets in order to add logging capabilities in a JavaScript adapter.
Logging example
The message below 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.
MFP.Logger.debug("This is a debug message from a JavaScript adapter");
Additional logging levels, from least to most verbose: ERROR, WARN, INFO, LOG and DEBUG.
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:
- IBM Containers or Liberty Build Pack, see the IBM Containers log and trace collection tutorial.
- Mobile Foundation IBM Cloud service, see Accessing server logs section in the Using Mobile Foundation tutorial.
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 MFP.Logger to forward JavaScript Adapter logs to the MobileFirst Server.
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 May 17, 2019