back to all blogsSee all blog posts

Maximise log history on Open Liberty in production

image of author
Kevin Grigorenko on Nov 9, 2018
Post available in languages:

At startup, Open Liberty starts with a new log file. The latest development builds of Open Liberty introduce a new option to configure Liberty to append to any existing messages.log or trace.log files instead of starting a new log file. This enables you to maximise the log history stored in production.

In development, the default behaviour of starting a new log file each time Open Liberty restarts can be really useful because it makes it really easy to find the log data for the new server run. In production, however, this can make logs more difficult to manage. Liberty rolls (overwrites old log files) when the files reach a certain total size or reach a total a certain number of files. For example, if you have five files of log history that can contain a maximum of 20Mb each, you would expect to have 100Mb of log data but, if you restart the server after 5Mb of data has been logged in each file, the five files would contain a total of only 25Mb of log history before the oldest file is overwritten on the next restart. This could mean losing vital production debug information.

You can disable this default behaviour in production by adding the new option com.ibm.ws.logging.newLogsOnStart=false on a separate line in a bootstrap.properties file (for information on how to create and use the bootstrap.properties file, see the Liberty Knowledge Center).

If you would like to completely disable roll-over (overwriting of old log files after a certain file size), you can pair the above option with the following option in server.xml which configures an unlimited maximum log file size:

<logging maxFileSize=0 />

As I said, in development, the default behaviour of rolling the logs after a certain file size is fine. If you’ve moved to production on Open Liberty, take a look at whether this new option to maximise log history is useful to you.