OpenResty Edge Access Logs: Configure Gateway Log Format Without Reload
To configure access logs in OpenResty Edge, define a named log format on the Global Config page, then assign it to an application and point it at a log file. Changes push to every gateway server with no reload or restart. The default main format records the remote IP address, HTTP host, and upstream status.
This tutorial walks through configuring the access log format globally, applying it to an application, and verifying the log output on a gateway server.
Define an access log format in Global Config
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.
Let’s start by configuring the format of the access log.
Go to the Global Config page.
The current configuration belongs to the network partition named “default”.
Let’s jump directly to the section about the log settings.
Here is the default log file directory. If you want to modify it, you must ensure that the modified directory already exists on all gateway servers.
Here is the default access log format named “main”.
This format records a lot of information, such as the remote address IP, HTTP host, request line, response bytes sent, upstream status, etc.
The “As default” means to set it to the default access log format of this network partition. And in the application, if we don’t change to another log format, the default is to use this.
If you want to add a new format, you can click this button.
In this tutorial we use this existing format “tutorial-example”.
It records the request time, remote IP address, HTTP host, and request line.
Assign the access log format to an application
Now let’s configure this access log format for the application
Go to the applications page.
We still use our continuing sample application for the test-edge.com domain.
Enter the application.
Go to the settings page.
The network partition named “default” was previously configured for this application.
And the application uses the global config’s default access log format by default.
We cannot change the access log file when using the default log format.
Let’s change the log format. We select the “tutorial-example” access log format.
Now we can change the log file. We change it to “example.access.log”.
Save it.
As always, we need to make a new release to push out our changes.
Click on this button.
Ship it!
It is fully synchronized.
Now our changes have been pushed to all the gateway clusters and servers.
When you change the access log format, the change syncs to all gateway servers through a binary upgrade — OpenResty’s online hot upgrade, which needs no reload or restart and causes no downtime or dropped connections. So it’s still very efficient and scalable.
Test the access log on the gateway server
We already have an upstream defined in our earlier tutorial.
This my_backend upstream has a backend server defined already.
And we also have a page rule already defined.
This page rule sets up a reverse proxy to the upstream we just saw.
So when we access the application, there will be upstream content returned.
Now let’s see which gateway server our application belongs to.
Go to the gateway clusters page.
Our application belongs to the network partition named “default”.
And there are many gateway clusters belonging to the network partition named “default”.
Let’s select one of them to view the access log messages.
Let’s generate an access log message by accessing the application.
On the terminal, we send a request via curl.
curl -sSI -H 'Host: test-edge.com' http://52.53.251.226/
Access successful!
Then, let’s check the access log messages. We log in to the OpenResty Edge gateway server.
Check the last one access log message in the example.access.log file.
The log file directory is defined in the global config.
And the log file is defined in our application.
Run the command.
We can see the access log message contains the request cost time.
And remote IP address.
HTTP host.
And the request line.
We can see that the access log message matches the access log format “tutorial-example”.
By the way, in addition to configuring access log format for the application in settings page, we can also configure it when we create a new application.
Go back to the applications page.
Click the new application button to see where to set the access log format.
We can set access log format here.
Access logs are one part of observability in OpenResty Edge. To inspect failures, see how to view error logs across applications and gateway servers, and how to trace a request with its Request ID.
Frequently asked questions
How do I configure the access log format in OpenResty Edge?
Go to the Global Config page and define (or pick) a named access log format under the log settings. Then open your application’s settings, select that format, and set the log file name. Make a new release to push the change to all gateway servers.
Where does OpenResty Edge store the access log file?
The log file directory is defined in the Global Config, and the log file name is defined per application. In this tutorial the application writes to example.access.log inside the configured log directory on each gateway server.
Can I change the access log format without restarting the gateway?
Yes, with no restart. After you make a new release, the change is pushed to all gateway clusters and servers. Note that changing the access log format triggers a binary upgrade of the gateway — this is OpenResty’s online hot upgrade, which causes no downtime and drops no existing connections, so the gateway keeps serving traffic and never needs a restart. It stays efficient and scalable.
What fields does the default “main” access log format record?
The default format named “main” records a lot of information, including the remote IP address, HTTP host, request line, response bytes sent, request time, and upstream status.
Can I set a different access log format per application?
Yes. Each application can use the network partition’s default format, or select its own — such as the “tutorial-example” format used here, which records the request time, remote IP address, HTTP host, and request line. You can also set the format when you create a new application.
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.










































































