back to all blogsSee all blog posts

Enhancing Log Management in Open Liberty: Extending maxFiles in Access Logging

image of author
Nidhin C P on May 20, 2025
Post available in languages:

Open Liberty is a flexible, lightweight runtime for Java microservices. One of its many strengths lies in its robust logging system, which allows developers and administrators to gain valuable insight into an application’s runtime behavior.

In this blog post, we explore an enhancement to the maxFiles parameter in Open Liberty’s access logging configuration—a change that improves log file cleanup by ensuring that all matching log files in the output directory are considered, not just those generated by the current process.

This blog will cover:

  • What the maxFiles parameter does in access logging

  • The motivation behind extending its behavior

  • How the enhancement improves log cleanup

  • A configuration example with maxFiles enabled

Understanding Access Logging and maxFiles

Access logging in Open Liberty captures all inbound HTTP requests and records them in access log files. Various parameters for access logging can be configured using the server.xml configuration file. One such parameter is maxFiles, which controls how many rotated access log files the server retains.

The Problem with the Original Behavior

Under the default behavior, Open Liberty’s cleanup mechanism only tracked and deleted access log files that were created during the current server runtime. As a result, older log files generated by previous server runs remained in the directory.

The Enhancement: A More Comprehensive Cleanup

To address this, we extended the scope of the maxFiles parameter. The key change is that the server now considers all log files matching the configured filename pattern in the log output directory, regardless of which process created them, and deletes the oldest ones if the total exceeds maxFiles.

Benefits:

  • Improved Cleanup: Ensures the log directory remains tidy and within the expected limits.

  • Cross-process Awareness: Handles logs from previous runs.

  • Consistency: Makes log retention behavior predictable and reliable across deployments.

Example Configuration for Access Logging with maxFiles

Here’s how to enable access logging with the maxFiles parameter:

<httpEndpoint id="defaultHttpEndpoint" httpPort="9080" httpsPort="9443">
    <accessLogging filepath="${server.output.dir}/logs/http_versionEndpoint_access.log"
                   maxFiles="5" rolloverInterval="1m" />
</httpEndpoint>

This setup will:

  • Store access logs in the ${server.output.dir}/logs directory.

  • Retain only the 5 most recent rotated log files.

  • Automatically delete the oldest file when a new one is created, once the count exceeds 5.

Conclusion

This enhancement to the maxFiles cleanup logic in Open Liberty provides a smarter, more reliable approach to access log retention. By extending the scope to all matching log files in the directory, the server ensures better log hygiene. If you’re using Open Liberty and rely on access logs for monitoring or auditing, enabling maxFiles is a simple yet powerful step toward keeping your logs manageable.