-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Implementing Logging | ||
|
||
InvenioRDM enhances its logging capabilities with the [`invenio-logging`](https://github.com/inveniosoftware/invenio-logging) module, improving the observability and reliability of your repository. This ensures a smoother operational experience for administrators and end-users alike. | ||
|
||
## Overview | ||
|
||
[invenio-logging](https://github.com/inveniosoftware/invenio-logging) is a key component of Invenio configures the Flask app logger, offering a standard Python logging interface for log creation and handler installation. | ||
|
||
The following logger extensions exists: | ||
|
||
**InvenioLoggingConsole**: Logs output to the console, useful for development environments. | ||
|
||
**InvenioLoggingFS**: Logs are written to a file, ideal for production environments where log preservation is necessary. | ||
|
||
**InvenioLoggingSentry**: Provides real-time error tracking and monitoring, allowing for immediate notification of issues. | ||
|
||
## Sentry Configuration | ||
|
||
[Sentry](https://docs.sentry.io/) is a popular error tracking and monitoring tool that provides real-time error tracking and monitoring. InvenioRDM integrates with Sentry through the `invenio-logging` module, here is how to configure it: | ||
|
||
include invenio-logging: in your `Pipefile` under packages, add the invenio-logging package with the sentry_sdk extra: | ||
|
||
```bash | ||
invenio-logging = {extras = ["sentry_sdk"], version = "~=2.0"} | ||
``` | ||
|
||
Configure Logging Backends: Add to your `invenio.cfg` the desired logging backends: | ||
|
||
```python | ||
# Invenio-logging Sentry | ||
# ---------------------- | ||
|
||
SENTRY_DSN = None | ||
LOGGING_SENTRY_INIT_KWARGS = { | ||
# Add Sentry SDK configuration options here e.g.: | ||
# Instruct Sentry to send user data attached to the event | ||
"send_default_pii": True, | ||
} | ||
``` | ||
|
||
Full configuration options can be found in [config.py](https://github.com/inveniosoftware/invenio-logging/blob/master/invenio_logging/config.py) | ||
|
||
in your `.env` file override the `SENTRY_DSN` variable with your Sentry DSN to avoid CI errors. | ||
|
||
```python | ||
INVENIO_SENTRY_DSN = "https://<SENTRY_PROJECT_ID>@sentry.io/<SENTRY_PROJECT_ID>" | ||
``` | ||
|
||
## Best Practices | ||
|
||
**Environment-Specific Configuration** | ||
Utilize different logging levels and backends for development, testing, and production environments to optimize performance and monitoring by switching the configurations above. | ||
|
||
**Sensitive Information** | ||
Ensure that logging does not capture sensitive information, adhering to privacy and security best practices. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters