For Java Stack 3, we recommend that teams use the the standard Java logging utility (java.util.logging.Logger). It works right out of the box and can be customized very easily. For Java Stack 3 web applications, you can customize your logging configuration using "deploy/src/main/resources/". For the QA test runner, you can customize your logging configuration using "qa/src/main/resources/conf/". If either of these files does not exist you can copy one from a Java Stack Starter project or simply create and configure it yourself.


Various dependencies in your project may log to different logging APIs, but you can use SLF4J to route all logging messages to the standard Java logging utility by adding the following dependencies to your pom:



With those dependencies you will only need to learn the standard Java logging API. In addition, the Java Stack provides a LogUtils class that can be used to further simplify logging.

For example:


// The Java logging class
import java.util.logging.Logger;

// Stack utility to simplify working with Loggers
import static*;

public class YourClass {
    private static final Logger LOG = getLogger(); // obtains a logger named ""

    public void logStuff() {
        severe(LOG, "a critical error message");
        warning(LOG, "a warning message");
        info(LOG, "Something informative");
        fine(LOG, "Fine detail message (for somewhat verbose logging)");
        finer(LOG, "Even finer detail message (for more verbose logging)");
        finest(LOG, "Very fine detail message (for very verbose logging)");
        // Each of the above statements can also take an exception and one or more message arguments
        // See the Logger and LogUtils APIs for details
This page was last modified on 29 April 2014, at 04:04.

Note: Content found in this wiki may not always reflect official Church information. See Terms of Use.