How to read WildFly logs using the CLI

In this short tutorial we will learn how to inspect the WildFly log files from the Command Line Interface.

One interesting feature is the ability to display log files using the management instruments. The advantage of this approach is that you can go through the server log files even if you are not remotely connected to the machine.

There are two main approaches to do that:

  • Query the logging subsystem to fetch the server logs
  • Use the HTTP Management API to fetch logs

Let’s see both options in detail.

How to read WildFly logs using the Command Line Interface

Gathering information from server log files is quite intuitive. Firstly, let’s learn how to list the available log files using the list-log-files command on the logging subsystem:

    "outcome" => "success",
    "result" => [
            "file-name" => "server.log",
            "file-size" => 24564L,
            "last-modified-date" => "2022-11-20T09:37:26.931+0100"
            "file-name" => "server.log.2022-11-11",
            "file-size" => 120521L,
            "last-modified-date" => "2022-11-11T19:23:19.631+0100"
. . . . .

Another interesting option for us, is the ability to display the actual log files content filtered by some parameters such as the number of lines to read (lines parameter) and the lines to skip (skip parameter) from the header. For example::

    "outcome" => "success",
    "result" => [
        "2022-11-20 09:37:21,741 INFO  [org.jboss.modules] (main) JBoss Modules version 2.0.3.Final",
        "2022-11-20 09:37:22,174 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.13.Final",
        "2022-11-20 09:37:22,180 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final",
        "2022-11-20 09:37:22,272 INFO  [] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 27.0.0.Final (WildFly Core 19.0.0.Final) 
. . . .

Then, if you want to emulate Linux tail command, you can add the “tail” parameter which accepts a boolean. Here’s for example how to read the last 10 lines of the server.log. For example:

    "outcome" => "success",
    "result" => [
        "2022-11-20 09:37:26,896 INFO  [] (Controller Boot Thread) WFLYCTL0183: Service status report",
        "WFLYCTL0184:    New missing/unsatisfied dependencies:",
        "      service jboss.jdbc-driver.postgres (missing) dependents: [service, service
ource.PostgrePool] ",
        "      service (missing) dependents: [service
.helloworld-mdb.helloworld-mdb.DefaultJMSConnectionFactory] ",

Finally, another useful command is the read-boot-errors which will list all errors from the server start up in the response:


How to download log files with the CLI

Additionally, it is worth mentioning that you can check your log files also through the attachment CLI command, which has options both for displaying files and save them locally.

Here is how to display the content of server.log file using the attachment command:

attachment display --operation=/subsystem=logging/log-file=server.log:read-resource(include-runtime)

Next, here is how to save the logs locally:

attachment save --operation=/subsystem=logging/log-file=server.log:read-resource(include-runtime) --file=./server.log

Reading WildFly logs using HTTP Management API

WildFly allows you to use the HTTP channel to stream server logs from a remote location. This can be useful if you want to perform some filtering/operations on the content of log files remotely. For example, you can test the following through the browser:


Replace the user and password attribute in the previous URL with a management user and password. You should expect your browser to request whether you are going to open the log file or save it locally.

A more programmatic approach consists in using a utility such as curl to request the log file and save it locally. This offers the benefit that you can choose the log format (in our example, JSON). For example:

curl --digest -L -D - \
--header "Content-Type: application/json" -u admin:mYpassword1! \
-d '{"operation":"read-attribute","address":[{"subsystem":"logging"},{"log-file":"server.log"}],"name":"stream"}'