Read WildFly 8 log files using the CLI

User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

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

WildFly 8 has been just released. One of the add-ons compared with the earlier release is the ability to display log files using the management instruments. Although log files are typically read and filtered using your operating system shell commands (such as tail or grep), the final release of WildFly enabled listing and reading the log files via the CLI as well. Gathering information from server log files is quite intuitive, for example in order to get the list of the server log files, simply execute the list-log-files command on the logging subsystem: 

/subsystem=logging/:list-log-files
{
"outcome" => "success", 
"result" => [
{
"file-name" => "server.log",
"file-size" => 9695L,
"last-modified-date" => "2014-02-13T15:46:04.365+0100"
},
{
"file-name" => "server.log.2014-02-12",
"file-size" => 9695L,
"last-modified-date" => "2014-02-12T21:32:49.759+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. Here’s how to read the full server.log file:

/subsystem=logging/:read-log-file(name=server.log,lines=-1,skip=0)
{
"outcome" => "success",
"result" => [
. . . . . .
"2014-02-16 21:53:19,520 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management",
"2014-02-16 21:53:19,523 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990",
"2014-02-16 21:53:19,525 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final \"WildFly\" started in 38820ms - Started 305 of 361 services (93 services are lazy, passive or on-demand)"
. . . .
]
}


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

/subsystem=logging/:read-log-file(name=server.log,tail=true,lines=10,skip=0)
{
"outcome" => "success",
"result" => [
"",
"2014-02-17 15:01:25,100 INFO [org.jboss.weld.deployer] (MSC service thread 1-8) JBAS016005: Starting Services for CDI deployment: rest-javaee7.war",
"2014-02-17 15:01:25,292 INFO [org.jboss.weld.Version] (MSC service thread 1-8) WELD-000900: 2.1.2 (Final)",
"2014-02-17 15:01:25,523 INFO [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016008: Starting weld service for deployment rest-javaee7.war",
"2014-02-17 15:01:29,366 INFO [org.jboss.resteasy.spi.ResteasyDeployment] (MSC service thread 1-7) Deploying javax.ws.rs.core.Application: class com.sample.JaxRsActivator",
"2014-02-17 15:01:29,541 INFO [org.wildfly.extension.undertow] (MSC service thread 1-7) JBAS017534: Registered web context: /rest-javaee7",
"2014-02-17 15:01:29,583 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed \"rest-javaee7.war\" (runtime-name : \"rest-javaee7.war\")",
"2014-02-17 15:01:29,726 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management",
"2014-02-17 15:01:29,729 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990",
"2014-02-17 15:01:29,730 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.Final \"WildFly\" started in 45032ms - Started 305 of 3
61 services (93 services are lazy, passive or on-demand)"
]
}

 

Follow us on Twitter