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

Add log file rotation #297

Merged
merged 6 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bob versions changelog
- Prometheus metrics exporter ([#240](https://github.com/qoollo/bob/pull/251))
- Rate metrics ([#242](https://github.com/qoollo/bob/pull/251))
- Global exporter is used, different exporters may be load conditionally ([No issue](https://github.com/qoollo/bob/pull/251))
- Add log file rotation to logger.yaml in examples ([#289](https://github.com/qoollo/bob/pull/297))

#### Changed

Expand Down
42 changes: 39 additions & 3 deletions config-examples/logger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,41 @@ appenders:

# An appender named "requests" that writes to a file with a custom pattern encoder
requests:
kind: file
kind: rolling_file
# [path] to the log file
path: "./log/logs.log"
path: "./log/info.log"
encoder:
pattern: "{d(%Y-%m-%d %H:%M:%S):<20} {M:>20.30}:{L:>3} {l} {m}{n}"
policy:
kind: compound
trigger:
kind: size
limit: 10 mb
ikopylov marked this conversation as resolved.
Show resolved Hide resolved
roller:
kind: fixed_window
pattern: "./log/archive/info.{}.log"
count: 5
ikopylov marked this conversation as resolved.
Show resolved Hide resolved
filters:
- kind: threshold
level: info

requests_error:
kind: rolling_file
path: "./log/error.log"
encoder:
pattern: "{d(%Y-%m-%d %H:%M:%S):<20} {M:>20.30}:{L:>3} {l} {m}{n}"
policy:
kind: compound
trigger:
kind: size
limit: 10 mb
roller:
kind: fixed_window
pattern: "./log/archive/error.{}.log"
count: 5
ikopylov marked this conversation as resolved.
Show resolved Hide resolved
filters:
- kind: threshold
level: error

# root logger sets the default global logging level attach appenders to the root
# Other loggers use this parameters as default
Expand All @@ -44,6 +74,7 @@ loggers:
level: info
appenders:
- requests
- requests_error
- stdout
# [bool] if true, logger won't delete existing configs on start
additive: false
Expand All @@ -52,27 +83,31 @@ loggers:
level: info
appenders:
- requests
- requests_error
- stdout
additive: false
bob_common:
# level applies only to bob-common
level: info
appenders:
- requests
- requests_error
- stdout
additive: false
bob_tools:
bob_apps:
# level applies only to bob-tools
level: info
appenders:
- requests
- requests_error
- stdout
additive: false
bob_grpc:
# level applies only to bob-grpc
level: info
appenders:
- requests
- requests_error
- stdout
additive: false
# pearl - low level IO lib
Expand All @@ -81,6 +116,7 @@ loggers:
level: error
appenders:
- requests
- requests_error
- stdout
additive: false
h2:
Expand Down