Oracle Fusion Middleware environments often consist of multiple servers distributed across many physical hosts. To provision new environments we have the power of Rubicon Red MyST Studio to automate the creation and deployment of platforms both large and small, but there still remains a level of manual effort to validate that everything is working as expected. One of the most basic checks is to review the server logs for errors. Given the size and complexity of some environments this task can be time consuming, and it is likely for things to be missed, making it a perfect candidate for automated assistance.
In this blog we will look at how we can automate checking for errors from all of the WebLogic Server Log files using the WebLogic REST APIs. The blog contains the following sections:
- WebLogic 12.2.1. REST APIs
- WebLogic Log Inspector
- Using the REST APIs to interrogate log files
WebLogic 12.2.1 REST APIs
WebLogic 12.2.1 introduced a range of REST APIs for configuring, monitoring, deploying, and administering the WebLogic Server. For example, you can:
- Create, start, and stop servers
- Configure JDBC data sources
- Create and configure JMS resources
- Create users
- Create partitions
- And much more
These REST APIs provide us with the power and flexibility to quickly and easily incorporate the WebLogic Server administration into other processes and applications. It also simplifies the creation of automation scripts and tools to assist with repeatable and reliable management of the WebLogic Server farm.
WebLogic Log Inspector
Using the REST APIs we have created the WebLogic Log Inspector that interrogates the running servers to read the log files, searching for any error messages, and collating them into a central report for review and investigation. The WebLogic Log Inspector is written in python, making it widely portable and easily understood.
Below is an example execution of the WebLogic Log Inspector utility.
In addition to outputting the high level statistics to the command line, the utility also generates an HTML report with the detailed error messages categorised by log. Below is an example example of the
Using the REST APIs to interrogate log files
Before we begin to use the REST APIs, it is worth noting that the APIs are enabled by default, but may be disabled if desired. To check if the APIs are enabled, log into the WebLogic Server Console (e.g.
http://hostname:7001/console) and navigate to
- The Domain node in the "Domain Structure" navigation tree
Click on "Advanced" at the bottom of the "Configuration" -> "General" tab
Scroll down to find "Enable RESTful Management Services"
With the REST services enabled, the first step of the utility is to access the WebLogic Server management API for servers
The response from this request details all of the servers within the domain, along with some basic server information such as the memory usage and server state, as well as a uri for each server to query further. The utility iterates over these uris to query all running servers.
To illustrate the APIs the utility uses, we will follow the API path for the AdminServer all the way to access the ServerLog messages. From the previous response message we are going follow the uri for the AdminServer
Again, we see that the response contains some basic information about the server memory usage, as well as a uri that allows us to find the list of logs the AdminServer writes to.
We then query the log uri
and receive the following response that contains a list of server logs (e.g. ServerLog, HTTPAccessLog, DomainLog, and DataSourceLog), and a uri to access the log contents.
We can then query the server for the ServerLog using the following uri
The response provides a structured representation of the server log, containing all of the log events. The Log Inspector interrogates the log entries and records any with the severity of “Error”, before generating the errorReport.html with the high-level statistics and detailed error messages.
Using this approach our simple utility makes it very quick and easy to scan through all of the server log files and identify any errors or issues that need investigating. I am sure there are many many more scenarios in which the WebLogic Server Administration REST APIs will make it simple to automate and integrate administration tasks.
The Log Inspector utility can be found in github https://github.com/andrew-dorman/wlsLogInspector
For further information on the WebLogic Server Administration REST APIs, please see
Fusion Middleware Administering Oracle WebLogic Server with RESTful Management Services https://docs.oracle.com/middleware/12212/wls/WLRUR/
Fusion Middleware RESTful Management Interface Reference for Oracle WebLogic Server https://docs.oracle.com/middleware/12212/wls/WLRML/
WebLogic Server 12c (12.2.1): Using REST Services to Manage WebLogic Server http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/1221/01-30-001-ManageWLSREST1221/ManageWLSREST1221.html#overview