2016-06-21

Logging with Flexible Environment and Jetty

Logging with Flexible Environment and Jetty

Problem

Logging was not available for Google Flexible Environment with Java 8 and Jetty 9. But after reading Jetty documentation all needed was added SLF4J as dependency and use it's Logger.

Solution

Add SL4FJ as dependencies in pom:

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.21</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.21</version>
    </dependency>

Use org.slf4j.LoggerFactory and org.slf4j.Logger to log:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static Logger logger = LoggerFactory.getLogger(JavaServlet.class);
logger.info("Info logging!");

Deployed

When deployed, the logging is shown in STDERR

Inga kommentarer:

Skicka en kommentar