Accessing WebLogic Server Logfiles via RESTFul Management Services

Posted by Dirk Nachbar on Friday, December 16, 2016
The RESTFul Management Services within Oracle WebLogic 12c is one of the greatest features and my personal favorite.

You can achieve a lot of things with the RESTFul Management Services, like creating DataSources, perform deployments, startup and shutdown Managed Servers and so on.

But you also can access the different WebLogic Server Logfiles :-)

Let's say your developers needs access to the Logfiles of your Oracle WebLogic Server, but you don't want to give them access to your Server which is hosting your Oracle WebLogic Server.
Just create a new User in your WebLogic Admin Console and give this new User the Group "Monitor". With the Monitor Group you can access the WebLogic RESTFul Management Services.

Now your developers can retrieve the Logfiles with a simple cURL command from their desktops:

http://<servername>:<adminport>/management/wls/latest/servers/id/<ServerName>/logs/<LogType>

For the LogType you have following options:
  • DataSourceLog
  • DomainLog (only for AdminServer)
  • HTTPAccessLog
  • ServerLog


A possible cURL request to retrieve the DomainLog of your WebLogic Domain could be as follows:

# Replace the Server Name and Port with your values
# Replace the AdminServer Name "PRODAdminServer" with your AdminServer Name
#
curl -s --user RESTAdmin:welcome1 \
        -H X-Requested-By:MyClient \
        -H Accept:application/json \
        -X GET http://wls122:7101/management/wls/latest/servers/id/PRODAdminServer/logs/id/DomainLog > domain.log

or like this:

# Replace the Server Name and Port with your values
# Replace the Managed Server Name "Prod_ManagedServer1" with your Managed Server Name
#
curl -s --user RESTAdmin:welcome1 \
        -H X-Requested-By:MyClient \
        -H Accept:application/json \
        -X GET http://wls122:7101/management/wls/latest/servers/id/Prod_ManagedServer1/logs/id/ServerLog > Prod_ManagedServer1_ServerLog.log

The corresponding Logfile retrieval in JSON format will look as follows:

DomainLog:


Managed Server ServerLog: