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

flags: add log flags to enable log rotation #1869

Merged
merged 3 commits into from Jul 17, 2023

Conversation

yoomee1313
Copy link
Contributor

@yoomee1313 yoomee1313 commented Jun 22, 2023

Proposed changes

  • Next flags are added. They are from go-ethereum flags but --log.format is slightly different from Ethereum.
    • --log.file: If the log file name is passed through the --log.file flag, klaytn code will write the logs at that file.
    • --log.format: It sets the log format (json|logfmt|terminal). Default format is terminal.
    • --log.rotate: If rotate flag is set, klaytn code will write the logs at the log file and supports log rotation.
    • --log.maxsize, --log.maxbackups, --log.maxage, --log.compress: specific log rotation configs. Those flags is used with --log.rotate flag.
  • For better usage, log roration related options are added at conf files and those options are supported at klaytn node daemon files.
    e.g. kend.conf
  # log rotation related options
  LOG_ROTATE=0 # setting 1 to enable the log rotation related options
  LOG_MAXSIZE=100 # the unit is MB
  LOG_MAXBACKUPS=10
  LOG_MAXAGE=30 # maximum number of days to retain a log file
  LOG_COMPRESS=1 # setting 1 to compress the backup logs in gz format
  • We are using daemon files(e.g. kend) to startup the klaytn process and we were redirecting the all standard outputs to the log files with the logs. We kept the redirection of standard outputs for the consistency.

Types of changes

Please put an x in the boxes related to your change.

  • Bugfix
  • New feature or enhancement
  • Others

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING GUIDELINES doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes ($ make test)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Related issues

  • Please leave the issue numbers or links related to this PR here.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@yoomee1313 yoomee1313 self-assigned this Jun 25, 2023
@yoomee1313 yoomee1313 marked this pull request as ready for review June 30, 2023 10:12
api/debug/flags.go Outdated Show resolved Hide resolved
hyunsooda
hyunsooda previously approved these changes Jul 4, 2023
@hyunsooda
Copy link
Contributor

How about to add this new feature to doc?

@yoomee1313
Copy link
Contributor Author

How about to add this new feature to doc?

Correct, I'll update the new flags at here: https://docs.klaytn.foundation/content/operation-guide/log-management

@yoomee1313
Copy link
Contributor Author

@kjeom @nohkwak Could you approve this PR?

@yoomee1313 yoomee1313 merged commit e74bc06 into klaytn:dev Jul 17, 2023
11 checks passed
@yoomee1313 yoomee1313 deleted the log-rotation branch July 17, 2023 01:58
@JayChoi1736 JayChoi1736 mentioned this pull request Jul 24, 2023
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants