Today I’d show you how to check application error logs and global error logs in OpenResty Edge.

Embeded image

Error logs of the sample application

As always, let’s go to the OpenResty Edge’s Admin web console. This is our sample deployment of the console. Every user has their local deployment.

Screenshot

We can still use our continuing sample application, test-edge.com.

Screenshot

Let’s enter this application.

Screenshot

Click here to view the error logs of this application.

Screenshot

We can see that there are already some error logs recorded here. This page displays some important information about the error log.

Screenshot

Such as Request ID, Error log message, Host name, Request body, Client IP addresses, etc.

Let’s make some changes for test-edge.com and visit the domain to generate a new error log message.

We already have a page rule defined.

Screenshot

This page rule sets up a reverse proxy to a pre-defined upstream.

Screenshot

Let’s go to the upstream page.

Screenshot

Let’s edit the upstream server.

Screenshot

We disable this upstream server. After disabling upstream, we will get a bad gateway error when accessing the application.

Screenshot

Save this change.

Screenshot

As always, we need to make a new release to push out our edited page rule.

Screenshot

Click on this button.

Screenshot

Ship it!

Screenshot

Our new release is now synchronized to all our gateway servers.

Screenshot

Now the new page rule has been pushed to all the gateway clusters and servers.

Embeded video

Embeded video

Embeded video

Our configuration changes do NOT require server reload, restart, or binary upgrade. So it’s very efficient and scalable.

Embeded image

Now let’s try to send a request.

On the terminal, we send a request by curl.

curl -sSI http://test-edge.com

Screenshot

We can see the bad gateway error, which will be recorded in our application’s error log.

Screenshot

And we can see that the server-side response has a request ID. We can copy it and use it to find the corresponding log message.

Screenshot

Let’s go back to the application’s error logs page. Check the error log message we generated.

Screenshot

As we expected, an error log was generated. Our newly generated error log will appear at the top of the list.

Screenshot

Error logs of openresty.com

The error logs for this domain are few. Let’s look at the error logs for the other domains we already have online.

Go to the Application list page.

Screenshot

Let’s see the error logs of the OpenResty website.

Screenshot

Go to the page.

Screenshot

Go to the error logs page. There are more error logs recorded here.

Screenshot

This filtering query condition is conducive to locating the problem.

Screenshot

We can filter the messages by request ID.

Screenshot

Gateway.

Screenshot

Server.

Screenshot

Error log level.

Screenshot

And time interval.

Screenshot

Let’s try filtering messages by a gateway.

Screenshot

We select the aws-us-west gateway.

Screenshot

We can see that there is no error log under the aws-us-west gateway.

Global error logs

After understanding the application’s error logs, let’s see the global error logs. The global error logs are displayed on the dashboard page.

Embeded image

Screenshot

Let’s go to the dashboard page to see the global error logs.

Screenshot

There are three types of global error logs.

Screenshot

Global Error Logs.

Screenshot

Admin Site Error Logs.

Screenshot

Log Server Error Logs.

Screenshot

Let’s first look at global error logs.

Screenshot

Global error logs are collected from gateway servers and do not belong to any applications.

Screenshot

We can filter the error logs.

Screenshot

Let’s continue to see the Admin Site Error logs.

Screenshot

These error logs are collected from the Admin console.

Screenshot

We also support conditional filtering of logs.

Screenshot

Let’s select the Log Level “Error”.

Screenshot

We have highlighted logs with “error” levels and repeat times greater than 1.

Screenshot

And last, let’s see the Log Server Error logs.

Screenshot

Error logs collected are from the OpenResty Edge Log Server.

Screenshot

And we can also filter the logs.

Screenshot

As we can see, there are log levels for both global and application logs, but not every log level we have reported.

Screenshot

The log level to be reported can be set on the global config page.

Screenshot

Here we set it to “warn”, meaning only warnings and log messages of higher levels are reported.

Screenshot

The error log level here contains “warn”, “error”, “crit”, “alert”, etc.

Screenshot

And on your local deployment, you can set the log level you want.

Check error logs on servers

Let’s log into the OpenResty Edge gateway server and take a look at our error.log file.

Screenshot

Check the last error log message.

Screenshot

The error log messages of our gateway servers are written here.

Screenshot

Run the command.

Screenshot

We can see the gateway server error log message.

Screenshot

Quit the server.

Screenshot

Then, we log into the OpenResty Edge Admin server and check the error.log file.

Screenshot

Let’s look at the last error log messages again.

Screenshot

The error log messages of the OpenResty Edge Admin are written here.

Screenshot

Run the command.

Screenshot

We can see the OpenResty Edge Admin error log message.

Screenshot

What is OpenResty Edge

OpenResty Edge is our all-in-one gateway software for microservices and distributed traffic architectures. It combines traffic management, private CDN construction, API gateway, security, and more to help you easily build, manage, and protect modern applications. OpenResty Edge delivers industry-leading performance and scalability to meet the demanding needs of high concurrency, high load scenarios. It supports scheduling containerized application traffic such as K8s and manages massive domains, making it easy to meet the needs of large websites and complex applications.

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.