Skip to content

Commit

Permalink
Customization: Add Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Samk13 committed Feb 25, 2024
1 parent c565be4 commit e928851
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions docs/customize/Logging.md
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.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ nav:
- Storage: "customize/s3.md"
- Upload Limits: "customize/upload_limits.md"
- Metadata-only records: "customize/metadata_only.md"
- Logging: "customize/Logging.md"
- Develop:
- Overview: "develop/index.md"
- Getting started:
Expand Down

0 comments on commit e928851

Please sign in to comment.