Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Provide a configuration option for logs rotation #114

Closed
gituser opened this issue Mar 15, 2021 · 12 comments
Closed

[Feature] Provide a configuration option for logs rotation #114

gituser opened this issue Mar 15, 2021 · 12 comments
Assignees
Labels
enhancement New feature or request

Comments

@gituser
Copy link

gituser commented Mar 15, 2021

System information

Geth version: 1.0.6
OS & Version: Linux
Commit hash : latest release

Expected behaviour

Currently, geth creates every hour a new log file even if you set the MaxBytesSize to relatively large value (e.g. 100MB), e.g.:

[Node.LogConfig]
FileRoot = ""
FilePath = "bsc.log"
MaxBytesSize = 104857600
Level = "info" 

This results in:

-rw-r--r-- 1 bsc bsc 318390 Mar 12 17:00 bsc.log.2021-03-12_16
-rw-r--r-- 1 bsc bsc 317626 Mar 12 17:59 bsc.log.2021-03-12_17
-rw-r--r-- 1 bsc bsc 317914 Mar 12 19:00 bsc.log.2021-03-12_18
-rw-r--r-- 1 bsc bsc 318458 Mar 12 20:00 bsc.log.2021-03-12_19
-rw-r--r-- 1 bsc bsc 318739 Mar 12 20:59 bsc.log.2021-03-12_20
-rw-r--r-- 1 bsc bsc 319184 Mar 12 22:00 bsc.log.2021-03-12_21
-rw-r--r-- 1 bsc bsc 318645 Mar 12 23:00 bsc.log.2021-03-12_22
-rw-r--r-- 1 bsc bsc 318582 Mar 13 00:00 bsc.log.2021-03-12_23
-rw-r--r-- 1 bsc bsc 320143 Mar 13 01:00 bsc.log.2021-03-13_00
-rw-r--r-- 1 bsc bsc 319308 Mar 13 02:00 bsc.log.2021-03-13_01
-rw-r--r-- 1 bsc bsc 319031 Mar 13 03:00 bsc.log.2021-03-13_02
-rw-r--r-- 1 bsc bsc 319838 Mar 13 04:00 bsc.log.2021-03-13_03
-rw-r--r-- 1 bsc bsc 318024 Mar 13 05:00 bsc.log.2021-03-13_04
-rw-r--r-- 1 bsc bsc 317292 Mar 13 06:00 bsc.log.2021-03-13_05
-rw-r--r-- 1 bsc bsc 316828 Mar 13 06:59 bsc.log.2021-03-13_06
-rw-r--r-- 1 bsc bsc 319357 Mar 13 08:00 bsc.log.2021-03-13_07
-rw-r--r-- 1 bsc bsc 317396 Mar 13 08:59 bsc.log.2021-03-13_08
-rw-r--r-- 1 bsc bsc 319110 Mar 13 10:00 bsc.log.2021-03-13_09
-rw-r--r-- 1 bsc bsc 320053 Mar 13 11:00 bsc.log.2021-03-13_10
-rw-r--r-- 1 bsc bsc 319043 Mar 13 12:00 bsc.log.2021-03-13_11
-rw-r--r-- 1 bsc bsc 318061 Mar 13 13:00 bsc.log.2021-03-13_12
-rw-r--r-- 1 bsc bsc 319053 Mar 13 14:00 bsc.log.2021-03-13_13
-rw-r--r-- 1 bsc bsc 319549 Mar 13 14:59 bsc.log.2021-03-13_14
-rw-r--r-- 1 bsc bsc 318054 Mar 13 15:59 bsc.log.2021-03-13_15
-rw-r--r-- 1 bsc bsc 319036 Mar 13 16:59 bsc.log.2021-03-13_16
-rw-r--r-- 1 bsc bsc 319549 Mar 13 18:00 bsc.log.2021-03-13_17
-rw-r--r-- 1 bsc bsc 319482 Mar 13 18:59 bsc.log.2021-03-13_18
-rw-r--r-- 1 bsc bsc 317783 Mar 13 20:00 bsc.log.2021-03-13_19
-rw-r--r-- 1 bsc bsc 318536 Mar 13 21:00 bsc.log.2021-03-13_20
-rw-r--r-- 1 bsc bsc 317801 Mar 13 22:00 bsc.log.2021-03-13_21
-rw-r--r-- 1 bsc bsc 319516 Mar 13 23:00 bsc.log.2021-03-13_22
-rw-r--r-- 1 bsc bsc 320276 Mar 14 00:00 bsc.log.2021-03-13_23
-rw-r--r-- 1 bsc bsc 318261 Mar 14 01:00 bsc.log.2021-03-14_00
-rw-r--r-- 1 bsc bsc 316822 Mar 14 02:00 bsc.log.2021-03-14_01
-rw-r--r-- 1 bsc bsc 317278 Mar 14 03:00 bsc.log.2021-03-14_02
-rw-r--r-- 1 bsc bsc 318844 Mar 14 04:00 bsc.log.2021-03-14_03
-rw-r--r-- 1 bsc bsc 318133 Mar 14 05:00 bsc.log.2021-03-14_04
-rw-r--r-- 1 bsc bsc 319919 Mar 14 06:00 bsc.log.2021-03-14_05

It seems there is no option to disable logs rotation by hour in the configuration file.

So would be nice to add an option into the config file to:

  • rotate by size
  • rotate by date (daily, hourly, weekly, monthly, etc)
  • disable rotation altogether

Of course, you could completely disable [Node.LogConfig] section and log into stdout and then handle the logs by yourself, but it's not practical, it will involve more tooling.

@gituser gituser changed the title [Feature] Provide a configuration option to logs rotation [Feature] Provide a configuration option for logs rotation Mar 15, 2021
@gituser
Copy link
Author

gituser commented Jun 29, 2021

Hello, any update on this? Any way to disable that log splitting so I'll handle logs myself with logrotate?

@gituser
Copy link
Author

gituser commented Nov 20, 2021

Ping @guagualvcha

@unclezoro unclezoro added the enhancement New feature or request label Nov 29, 2021
@unclezoro
Copy link
Collaborator

hi @gituser this make sense. Noted.

@BinanceG11
Copy link

We have responded to the question and will proceed to close the case as we didn't get any additional question after 3days. 
Please proceed to join our Discord channel for more discussion at https://discord.com/invite/YPDsUqcwR8

@gituser
Copy link
Author

gituser commented Dec 7, 2021

@BinanceG11 Why do you close this? This is a feature request and it has been accepted by @guagualvcha

@BinanceG11 BinanceG11 reopened this Dec 7, 2021
@BinanceG11
Copy link

Noted. @gituser reopen. Apologies

@bnb-tw
Copy link

bnb-tw commented May 16, 2023

@vnermolaev can we add a time.Duration to the logging config to change the interval?

@bnb-tw
Copy link

bnb-tw commented Jul 5, 2023

@gituser we have merged the changes to be able to modify the log rotation duration.

@gituser
Copy link
Author

gituser commented Aug 10, 2023

hey @bnb-tw unfortunately with bsc v1.2.10 it didn't work for me.

I've set in my config.toml this configuration for logging:

[Node.LogConfig]
FileRoot = ""
FilePath = "bsc.log"
MaxBytesSize = 1048576000
Level = "info"
RotateHours = 24

But I still see that there is a new file being created every hour:

-rw-r--r-- 1 bsc bsc  68591 Aug 11 01:16 bsc.log.2023-08-11_01
drwxr-x--x 8 bsc bsc   4096 Aug 11 01:14 ..
-rw-r--r-- 1 bsc bsc  29267 Aug 11 00:59 bsc.log.2023-08-11_00

@gituser
Copy link
Author

gituser commented Aug 23, 2023

Ping @vnermolaev @bnb-tw @alexlucaci

@zzzckck
Copy link
Collaborator

zzzckck commented Dec 14, 2023

will be in next release: v1.3.6

@buddh0
Copy link
Collaborator

buddh0 commented Dec 14, 2023

@gituser with v1.3.6

  1. if you want to disable rotation, just delete the [Node.LogConfig] part in config.toml,then redirect output,such as
    ./geth ...... >bsc.log
  2. when you enable rotation by add config in [Node.LogConfig]
    rotate by size is a must,
    rotate by hours is optional , RotateHours range in [0, 23], and 0 means to disable rotate by hours
    so if you want to only rotate by size, try the following config
[Node.LogConfig]
FileRoot = ""
FilePath = "bsc.log"
MaxBytesSize = 104857600 // change as you desire
Level = "info"
RotateHours = 0 // disable rotate by hours

galaio pushed a commit to galaio/bsc that referenced this issue Jul 31, 2024
Co-authored-by: will@2012 <xibaow2020@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants