Get Started with SAP Application Logging Service in the Neo Environment
Configure logs and view them in the SAP BTP cockpit.
Overview
You will learn
- How to configure log messages and loggers
Prerequisites
Prerequisites
- You have a productive global account and a subaccount. For more information, see Getting Started with a Customer Account in the Neo Environment.
- Your user is assigned to the proper Administrator role to work with the SAP BTP cockpit. You need this role in order to deploy an application and to configure loggers. For more information, see Enable Application Providers to Access Your Subaccount.
Steps
See Install the SAP BTP SDK for Neo Environment.
For example, for Java Web Tomcat 8, download neo-java-web-sdk-<version>.zip.
Open the src\com\sap\cloud\sample\helloworld\HelloWorldServlet.java file in the hello-world sample and update the file with the following code:
package com.sap.cloud.sample.helloworld;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Servlet implementing simplest possible hello world application for SAP BTP Neo Environment.
*/
public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(HelloWorldServlet.class);
/** {@inheritDoc} */
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
LOGGER.info("Hello World!");
response.getWriter().println("<p>Hello World!</p>");
}
}Now you can view information about configured loggers when requesting the helloworld application. This information is also logged in the default trace logs with the text Hello World! when you set a log with level INFO.
See Install SAP JVM.
Specify the JAVA HOME variable to the jre folder of the installed SAP JVM and the Path variable to the bin folder of the installed Apache Maven.
Go to the <installed SDK>/samples/hello-world folder in the command prompt and run the command mvn clean install to compile, test, and package the hello-world project.
You can now find your packaged WAR file in the target folder.
In the text area below, enter the command you used to compile, test, and package the hello-world project.
On the Java Applications page, deploy the WAR file and start the helloworld application. See Deploy on the Cloud with the Cockpit.

Choose the helloworld application link to open the application’s Overview page and request the application by opening the application URL.
The application now displays the Hello World! message.
This operation guarantees that the logger is available.
Go to the Logging page.
Set the log level.
Set the INFO log level of the
com.sap.cloud.sample.helloworld.HelloWorldServletlogger that you added toHelloWorldServlet.java. See the Configure Loggers section in Using Logs in the Cockpit for Java Applications. Furthermore, you can find information about the various log levels at Implementing Logging for Java Applications.
Set INFO log level
In the text area below, enter the logger that you set the log level for.
Go to the Overview page and choose the application URL.
The application now displays the Hello World! message.
Go back to the Logging page, display the HTTP access log in a log viewer and search for the path
hello-worldto see thehelloworldapplication logs. For more information, see Log Viewers for Java Applications.
HTTP access logs From the Logging page, display the default trace in a log viewer and search for text
Hello World!to find the logs from the request operation.
Default trace logs
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.