Event Logging
Requirements
- Completed the Server Setup Guide
- An enterprise organization
Azure Queue (Cloud)
The cloud instance of Bitwarden uses Azure Queue and Table Storage to handle events. Here's how this works:
- A user carries out an action which needs to be logged
- If the event is client-side (e.g. viewing a password), the client sends details of the event to
the Events server project, which then calls
EventService
. If the event is server-side, the relevant project callsEventService
itself. - The event is temporarily stored in Azure Queue Storage (which is designed for handling large numbers of messages)
- The EventsProcessor server project runs a regular batch job to retrieve events from Queue Storage and save them to Table Storage
- Events are retrieved from Table Storage for viewing
To emulate this locally:
-
Make sure you've installed and setup Azurite, as described in the Server Setup Guide
-
Make sure that the
globalSettings:events:connectionString
user secret is not set, or has the default value ofUseDevelopmentStorage=true
-
Start the Events and EventsProcessor projects using
dotnet run
or your IDE. (Also ensure you have Api, Identity and your web vault running.)
You should now observe that your enterprise organization is logging events (e.g. when creating an item or inviting a user). These should appear in the Event Logs section of the organization vault.
Azure Storage Explorer lets you inspect the contents of your local Queue and Table Storage and is extremely useful for debugging.
Database storage (Self-hosted)
Self-hosted instances of Bitwarden use an alternative EventService
implementation to write event
logs directly to the Event
table in their database.
To use database storage for events:
- Run your local development server in a self-hosted configuration (Api, Identity and web vault)
- Start the Events project using
dotnet run
or your IDE (note: EventsProcessor is not required for self-hosted)