Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Logback for Payara server

These packages serve for providing slf4j APIs and logback for Payara as a common components. It will also replace server’s logs past initial startup. Additionally it allows for access logging with logback-access. Also included is logstash-encoder, so that logs can be transferred directly to logstash without need for additional file watching and parsing.

(Semi-)Automatic installation

  1. Have your server running

  2. Download latest version of io.github.goodees:payara-logback-dist. Current version is 1.0.0

  3. Unzip

  4. Have asadmin on your executable path in your shell

  5. Run install.cmd or install.sh

To understand what actually happens, read on.

Manual Installation

payara-logback-libs contains slf4j api, logback, logstash-encoder, and all their dependencies (shaded). It gets installed on the ext classloader — the top of the classloader hierarchy.

asadmin add-library --type ext payara-logback-libs-1.0.jar

payara-logback-delegation makes the contents of payara-logback-libs available to OSGi classloader

asadmin deploy --type osgi payara-logback-delegation-1.0.jar

And finally, payara-logback-access integrates logback-access with payara web container.

asadmin deploy --type osgi payara-logback-access-1.0.jar

Configuring logging with logback

Nothing happens yet, right?

First, have your logback configuration file. Place it in your domain’s config directory as logback.xml.

A simple file to get you started would be:

<configuration debug="true" scan="true">
    <!-- Since we strongly integrate with Payara's java.util.logging, we need to include this -->
    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
    <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->

            <pattern>[%d{ISO8601}] [%t] [%4p] [%logger]: %m%n</pattern>
        <level value="INFO" />
        <appender-ref ref="FILE" />

Consult Logback manual for reference of configuration.

Next, tell the location of your configuration file to logback via system property and redirect java.util.logging to slf4j. Finally, restart the instance(s), and you’re done.

asadmin create-jvm-options "-Dlogback.configurationFile=${com.sun.aas.instanceRoot}/config/logback.xml"
asadmin set-log-attributes "handlers=org.slf4j.bridge.SLF4JBridgeHandler"
asadmin restart-domain

Enabling access logging with logback-access

The steps for access logging are similar. We create a configuration file, like this one taken from Logback access documentation:

  <!-- always a good activate OnConsoleStatusListener -->
  <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />

  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">


  <appender-ref ref="FILE" />

Let’s place the configuration file in the config directory under the name of logback-access.xml.

Next we’ll install the access logging using a valve, that we will activate for a default virtual server.

asadmin create-jvm-options "-DlogbackAccess.configurationFile=${com.sun.aas.instanceRoot}/config/logback-access.xml"
asadmin set server-config.http-service.virtual-server.server.property.valve_1="io.github.goodees.payara.logback.access.Logger"
asadmin restart-domain

And now you’re all set.