How to store the log files generated by br log in a specified directory?

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

Original topic: br log 生成的日志文件如何存放在指定目录?

| username: Daniel-W

[Test Environment for TiDB] Testing
[TiDB Version] 6.5.2
After running the br log, the log file is by default placed in /tmp. The --log-file parameter can only specify the file to write to, and it seems there is no parameter to specify the directory, so that the generated log file like br.log.2023-06-27T13.06.59+0800 is placed in a specified directory. Could anyone please let me know if there is a way to specify the storage directory?

| username: Soysauce520 | Original post link

Can I use ln -s?

| username: Daniel-W | Original post link

It is possible through external methods. I would like to know if BR has similar parameters to control this.
Or does BR have any related log cleaning strategies?

| username: zhanggame1 | Original post link

Refer to what I have done before, you can specify the location, I have placed it in the NFS share.

Enable log backup:

Add the shared directory /share/br-log/ to the KV node.

Execute

tiup br log start --task-name=pitr --pd "10.0.0.26:2379" --storage "local:///share/br-log"
| username: 我是咖啡哥 | Original post link

I happened to test this log backup these past two days. I also specified the directory and encountered an error :grinning:
There are two parameters involved here, which can be confusing:

  • -s, --storage: The path to store the TiDB log backup, change log. Here, a directory is specified.
  • –log-file: The log generated by running br log. This can only specify a file name. This is just the log generated when you run the command, and it will not be continuously updated. So it does not need to be a directory.

For example, every time you check the status, a log will be generated. If not specified, it will be placed in /tmp by default.

| username: Daniel-W | Original post link

This is the backup data, my data is stored in COS.

| username: Daniel-W | Original post link

Yes, this situation is the same as mine. If not specified, it defaults to being placed under tmp. If specified, you can only specify a file, and this file can only get larger and larger without a cleanup strategy.

| username: Daniel-W | Original post link

I am currently planning to use --log-file to specify the log file, and then use logrotate to manage the log files.

| username: 我是咖啡哥 | Original post link

How did you operate it? Why is this log file getting bigger and bigger? I see that it stops updating once the command is executed.

| username: Daniel-W | Original post link

“I understand, this can only specify the file name, and this is just the log generated when you run the command, it won’t keep updating.”
Got it, I wrote a script here, and each time I manage a task, I write the recorded log into the same file. I’ll just change the log strategy in the script.
Thanks a lot!

| username: system | Original post link

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