Explore Kong System Log Files

Overview

In the previous section, you Explored KONG Configuration Files.

Log files are essential to troubleshooting issues that arises. In this section, you’ll explore the Kong System log files, specifically the error.log.

Filename(s):

  1. error.log
  2. access.log
  3. admin_access.log

Location: /usr/local/kong/logs

Kong Log Files

Error.log : Kong Error logs

Run the command below to view the file.

$ cat /<usr/local/kong>/logs/error.log

The results should look like this.

2017/07/30 18:58:56 [notice] 64#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:56 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:58 [notice] 64#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:58 [notice] 64#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:58 [notice] 64#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:58 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:58 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 18:58:58 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 19:01:12 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 19:02:25 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 19:03:26 [notice] 65#0: signal 17 (SIGCHLD) received
2017/07/30 19:04:29 [error] 65#0: *1180 lua coroutine: runtime error: don't know how to respond to PATCH
stack traceback:
coroutine 0:
	[C]: ?
coroutine 1:
	[C]: in function 'resume'
	/usr/local/share/lua/5.1/lapis/application.lua:393: in function 'handler'
	/usr/local/share/lua/5.1/lapis/application.lua:130: in function 'resolve'
	/usr/local/share/lua/5.1/kong/api/init.lua:65: in function 'handler'
	/usr/local/share/lua/5.1/lapis/application.lua:130: in function 'handler'
	/usr/local/share/lua/5.1/lapis/application.lua:163: in function </usr/local/share/lua/5.1/lapis/application.lua:159>
	[C]: in function 'xpcall'
	/usr/local/share/lua/5.1/lapis/application.lua:159: in function 'dispatch'
	/usr/local/share/lua/5.1/lapis/nginx.lua:214: in function 'serve'
	content_by_lua(nginx-kong.conf:147):10: in function <content_by_lua(nginx-kong.conf:147):1>, client: 172.17.0.4, server: kong_admin, request: "PATCH /upstreams/mockbin.org/targets HTTP/1.1", host: "localhost:8001"
2017/07/30 19:04:41 [error] 65#0: *1221 lua coroutine: runtime error: don't know how to respond to PATCH
stack traceback:
coroutine 0:

Important Note: The Kong log_level by default is set to “notice”. For more detail logging, you can modify this in the Kong.conf file to a higher severity such as “error”. However, if you use the Rate Limiting plugin, increasing the log details can increase the log size.


Access.log : API access logs

Run the same command for the other log files.

$ cat /<usr/local/kong>/logs/access.log

The results show access to the APIs

127.0.0.1 - - [03/Aug/2017:09:10:19 +0000] "GET / HTTP/1.1" 404 56 "-" "curl/7.29.0"
127.0.0.1 - - [03/Aug/2017:09:10:19 +0000] "GET / HTTP/1.1" 404 56 "-" "curl/7.29.0"

###Admin_access.log* : Admin API access logs Run the same command for the other log files.

$ cat /<usr/local/kong>/logs/admin_access.log

The results should look similar to below:

127.0.0.1 - - [03/Aug/2017:09:38:10 +0000] "GET /status HTTP/1.1" 200 496 "-" "curl/7.29.0"
127.0.0.1 - - [03/Aug/2017:09:38:13 +0000] "GET /status HTTP/1.1" 200 496 "-" "curl/7.29.0"
127.0.0.1 - - [03/Aug/2017:09:38:16 +0000] "GET /status HTTP/1.1" 200 496 "-" "curl/7.29.0"
127.0.0.1 - - [03/Aug/2017:09:38:19 +0000] "GET /status HTTP/1.1" 200 496 "-" "curl/7.29.0"

Optional Lab: Modify Log_Level to Error

The default Kong log_level=notice. You can change these if you want and need more details. To do so do the following:

High Level Tasks:

  1. Modify kong.conf file log_level=error (from notice)
  2. Start the configuration file with kong restart -c /etc/kong/kong.conf –vv
  3. Access the admin api and verify log_level=error setting
  4. View logs

Summary

Log files are essential to troubleshooting issues that arises. You looked at various log level specificy the Error logs.

What Next

Lets explore how to Secure Access to the Kong Environment and your APIs.

Secure Access to an API

Edit this page