-
Notifications
You must be signed in to change notification settings - Fork 39
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
Read logging config from logging.yml if available #2659
Read logging config from logging.yml if available #2659
Conversation
I was able to log both to Humio and to local files by adding this to my version: 1
loggers:
nav:
level: DEBUG
root:
handlers: [humio, console]
handlers:
humio:
class: humiologging.handlers.HumioJSONHandler
level: DEBUG
humio_host: https://your-humio-ingest-addr-here
ingest_token: SECRET_TOKEN_THINGY
console:
class: logging.StreamHandler
formatter: default
formatters:
default:
format: '%(asctime)s [%(levelname)s] [%(name)s] %(message)s' |
Codecov Report
@@ Coverage Diff @@
## master #2659 +/- ##
==========================================
+ Coverage 54.61% 55.25% +0.63%
==========================================
Files 560 561 +1
Lines 40712 41546 +834
==========================================
+ Hits 22235 22955 +720
- Misses 18477 18591 +114
... and 17 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine but codecov complains about missing coverage, and reports wrong lines even.
Also, docs needed.
9bea213
to
aa3d873
Compare
Added tests and docs, but now this depends on #2660 being merged first. I also see we have still more implicitly covered error handling code in ipdevpoll that keeps falling in and out of coverage due to timing randomness. I've added that to my worklist. |
This adds the ability to override most of NAV's logging config with the more flexible dictConfig format, as read from an optional `logging.yml` file (which can also be overriden by environment variable, just like `logging.conf`)
aa3d873
to
6a9828c
Compare
doc/howto/setting-up-logging.rst
Outdated
NAV has by default installed on it, so if you want NAV to also keep logging to | ||
files in addition to Humio, you need to add an extra handler that logs to a | ||
stream (``stderr`` by default), and you need to specify a format for it. This | ||
example just redefines the log line format NAV uses by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should perhaps actually show here what NAV's default is, without talking about humiologging. Then you can show how to add humiologging afterwards so that that it is easy to see the state before and after.
As requested in review, this begins by documenting how to replicate NAV's default logging config, and proceeds to document Humio only after that.
9bbc066
to
43cabfa
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This adds the ability to override most of NAV's logging config with the more flexible dictConfig format, as read from an optional
logging.yml
file (which can also be overriden by environment variable, just likelogging.conf
)This could be used to customize NAV logging in your deployment to a much larger degree. It should also be possible to have NAV keep logging to its normal log files by configuring a default StreamHandler, as most NAV daemons will redirect stderr to its log file on daemonization.