The scope of the log.file.max-backups parameter

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: log.file.max-backups 参数的作用范围

| username: Raymond

Today I encountered an interesting phenomenon. I always thought that the historical files of the slowlog would not have an automatic cleanup mechanism, but today I found that the historical files of the slowlog were all cleaned up. Then, I noticed that the log files under tidb-deploy/tidb-4000/log added up to 10, and I happened to set log.file.max-backups to 10. So, I am guessing whether the log.file.max-backups parameter is also effective for the slowlog. In other words, when this log.file.max-backups parameter takes effect, it will also delete the historical logs of the slowlog to meet the set value of the log.file.max-backups parameter. I wonder if anyone else has encountered this issue.

| username: TiDBer_wTKU9jv6 | Original post link

| username: 西伯利亚狼 | Original post link

If you want to keep it, increase the threshold.

| username: Raymond | Original post link

The information provided by the expert is very useful, but based on my observations, max-backups is effective for the historical slow log cleanup mechanism, while max-days does not seem to be very effective for historical slow log cleanup. When in the code will the max-backups and max-days parameters take effect?

| username: Raymond | Original post link

Thank you for your reply.

| username: TiDBer_wTKU9jv6 | Original post link

In conjunction with the max-size parameter, old slow logs are generated, and when the last modification time of the old slow logs reaches max-days, the old slow logs will be cleaned up. max-days and max-backups are set to retain logs from two different dimensions.

| username: xiaohetao | Original post link

Is the automatic log cleanup time determined by simultaneously meeting the values of max-days and max-backups?

| username: TiDBer_wTKU9jv6 | Original post link

Meet one of them

| username: xiaohetao | Original post link

Thanks :+1:

| username: Raymond | Original post link

Do the max-days and max-backups parameters apply to error logs, such as tidb_stderr.log, in this way?

| username: Hi70KG | Original post link

By default, each node server outputs standard errors in the logs. If the --log-file parameter is specified during startup, the logs will be output to the specified file and rotated daily.

It seems like this parameter also applies to error logs according to the documentation! :grinning:

| username: Raymond | Original post link

Is there a corresponding documentation link?

| username: cs58_dba | Original post link

In general production, you should at least retain the data from the past week, right?

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.