Skip to content

Commit

Permalink
Add log file rotation (#297)
Browse files Browse the repository at this point in the history
* Add log file rotation

* Update CHANGELOG

* Change bob_tools to bob_apps

* Update logger.yml

* Update logger.yaml
  • Loading branch information
alexprof authored Aug 24, 2021
1 parent 5a55f26 commit 57ff8cb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bob versions changelog

## [Unreleased]
#### Added
- Add log file rotation to logger.yaml in examples ([#297](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: 20 mb
roller:
kind: fixed_window
pattern: "./log/archive/info.{}.log"
count: 10
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: 20 mb
roller:
kind: fixed_window
pattern: "./log/archive/error.{}.log"
count: 10
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

0 comments on commit 57ff8cb

Please sign in to comment.