Setting the logging level for one replica to DEBUG
Set the logging level for one replica to DEBUG
if you want to avoid
restarting the microservice.
About this task
You can use REST API calls to the /management/loggers
endpoint to set the
logging level to DEBUG
in the microservice instances that are running.
Procedure
-
Identify the name of the pod for which you need to change the logging level. Display a list of
all pods by running the following command:
oc get pods -n <cp4na_namespace>
<cp4na_namespace> is the namespace where IBM® Cloud Pak for Network Automation is installed.
The names of the IBM Cloud Pak for Network Automation pods begin with
cp4na-o
. - Get the port for the application container from the details of the pod. Run
the following command to get the pod details:
oc get pods <pod_name> -o=jsonpath="{.spec.containers[*].ports[*].containerPort}"
<pod_name> is the name of the pod that you chose in step 1.
For example, run a command like this to get the port forapollo
:oc get pods cp4na-o-apollo-7567d7f966-h5mc6 -o=jsonpath="{.spec.containers[*].ports[*].containerPort}"
The following output is displayed:
8282
- To access the command line of the pod, run this command:
oc exec -it <pod_name> -- bash
For example, run a command like this to access the command line ofapollo
:oc exec -it cp4na-o-apollo-7567d7f966-h5mc6 -- bash
- To set the logging level for the pods, you can use a curl
command from the command line of the pod.
- To set the logging level for the
nimrod
orishtar
pods, use a curl command with an access token. For more information about how to get an access token, see Authenticating REST API requests.For example, run a command like this:
curl -k -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <access_token>" -d '{"configuredLevel": "DEBUG"}' \ https://localhost:<port>/management/loggers/<logger_name>/
- To set the logging level for other pods, use a curl command without an
access token.
For example, run a command like this:
curl -k -X POST -H "Content-Type: application/json" -d '{"configuredLevel": "DEBUG"}' \ https://localhost:<port>/management/loggers/<logger_name>/
- To set the logging level for the
- To verify the current logging level, run a curl command like
this:
curl -k https://localhost:<port>/management/loggers/<logger_name>/
<port> is the port value that you got in step 2.
<logger_name> is the name of the logger. For example, you might configure
com.accantosystems
as the main logger for debug mode.For example, run a curl command like this to view the current logging level for the loggercom.accantosystems
:curl -k https://localhost:8282/management/loggers/com.accantosystems/
The following output is displayed:{"configuredLevel":"INFO","effectiveLevel":"DEBUG"}