4 Replies Latest reply on Jan 16, 2019 3:43 PM by Jeeraud Maloon

    How to Invoke WildFly Rest Endpoint to Obtain Logging File Content

    Jeeraud Maloon Newbie

      To obtain a portion of JBoss/WildFly (v. 14) log file using CLI programmatically, I can execute the following command to obtain the last 10 lines of the server.log file:

       

      /subsystem=logging/:read-log-file(name=server.log,tail=true,lines=10,skip=0)

       

      Or

       

      /subsystem=logging/log-file=server.log:read-log-file(tail=true,lines=10,skip=0)

       

      I cannot use the CLI command as the JBoss CLI Client jar file is not approved, and not included on the server to begin with. Hence the need to make HTTP/Rest calls.

       

      According to the HTTP Management API page, I should get the content following this pattern:

       

      http://server:9990/management/<path_to_resource>?operation=<operation_name>&operation_parameter=<value>

       

      These are the supported operations for a GET :

      • attribute : for a read-attribute operation
      • resource : for a read-resource operation
      • resource-description : for a read-resource-description operation
      • snapshots : for the list-snapshots operation
      • operation-description : for a read-operation-description operation
      • operation-names : for a read-operation-names operation

       

      For simple attributes like server status, I am able to retrieve data from both the browser and programmatically (e.g. http://localhost:9990/management?operation=attribute&name=server-state&json.pretty=1).

       

      However, I have tried many variations to no avail, e.g.

       

      I get a list of operations including "read-log-file" (appears to be similar to executing the following CLI command "/subsystem=logging: [TAB]" which lists everything the following Rest operation provides):

      http:/localhost:9990/management/subsystem/logging/log-file?operation=operation-names

       

      Get list of nodes with the followings (when connected to CLI and execute "/subsystem=logging/ [TAB]" minus several of commands -- not sure if the Rest API is limited):

      http:/localhost:9990/management/subsystem/logging/log-file?operation=resource&name=server.log&tail=true

      http:/localhost:9990/management/subsystem/logging/read-log-file?operation=resource&tail=true

      http:/localhost:9990/management/subsystem/logging/read-log-file?operation=resource&name=server.log&tail=true

       

      Get Management resource not found

      http:/localhost:9990/management/subsystem/logging/log-file/read-log-file?operation=resource&name=server.log&tail=true

       

      Get a blank page

      http:/localhost:9990/management/subsystem/logging/log-file/server.log/read-log-file?operation=resource&tail=true

       

      Can somebody please provide a Rest call for WildFly v. 14 to achieve this objective? Thanks.