Logging is supported by WildFly Swarm using the typical JBoss-Logging systems. By default, logging occurs to the console. Advanced configuration can adjust the amount of information logged and where the log ends up (files or console or other locations).

Including Logging Capabilities

Several of the higher-order fractions include logging by default. If you need to include it explicitly, though, you may use the following Maven coordinates.



Including the above dependency will automatically configure reasonable INFO-level logging to the console. You can control the logging level with the swarm.logging sysprop: -Dswarm.logging=DEBUG.

If you wish to perform more advanced configuration, please see the JavaDocs for the Logging API.

Logging to a file

In order to log to a file, you’d need to specifiy a file handler and link it to the root logger. A full example for the configuration of a log file handler looks like this:

String logFile = System.getProperty("user.dir") + File.separator + "swarm.log";

Swarm container = new Swarm();
  new LoggingFraction()
    .fileHandler("FILE", f -> {

      Map<String, String> fileProps = new HashMap<>();
      fileProps.put("path", logFile);
      f.formatter("%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n");

    .rootLogger(Level.INFO, "FILE")