0 purchases
dio interceptor seq
Dio Seq Logging Interceptor #
An interceptor for the DIO client that sends request, response, and error logs to Seq.
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
dio_seq_logging_interceptor: ^1.0.0
copied to clipboard
Usage #
To start using the SeqLoggingInterceptor, follow the steps below:
Import the package in the file where you are configuring the DIO client:
import 'package:dio_seq_logging_interceptor/dio_seq_logging_interceptor.dart';
copied to clipboard
Create an instance of the interceptor, providing the Seq server URL and, optionally, the API key:
final seqLoggingInterceptor = SeqLoggingInterceptor(
'https://your-seq-server-url',
apiKey: 'your-seq-api-key',
);
copied to clipboard
Add the interceptor to your DIO client instance:
final dio = Dio();
dio.interceptors.add(seqLoggingInterceptor);
copied to clipboard
Now, all requests, responses, and errors processed by the DIO client will be logged in Seq.
Configuration #
You can customize the header name used for the correlation ID when creating an instance of the SeqLoggingInterceptor. By default, the header name is 'X-Request-Seq-Id'.
final seqLoggingInterceptor = SeqLoggingInterceptor(
'https://your-seq-server-url',
apiKey: 'your-seq-api-key',
correlationalHeaderName: 'X-Custom-Correlation-ID',
);
copied to clipboard
Exemplo logs #
Running Seq with Docker #
To run a Seq container using Docker, follow these steps:
Install Docker if you haven't already.
Pull the latest Seq image from Docker Hub:
docker pull datalust/seq
copied to clipboard
Create a new directory to store Seq data:
mkdir seq_data
copied to clipboard
Run a Seq container, mapping the created data directory to the container's /data folder and forwarding the default Seq port (5341):
PH=$(echo '<password>' | docker run --rm -i datalust/seq config hash)
copied to clipboard
mkdir -p <local path to store data>
copied to clipboard
docker run \
--name seq \
-d \
--restart unless-stopped \
-e ACCEPT_EULA=Y \
-e SEQ_FIRSTRUN_ADMINPASSWORDHASH="$PH" \
-v <local path to store data>:/data \
-p 80:80 \
-p 5341:5341 \
datalust/seq
copied to clipboard
This command will run the Seq container in detached mode (-d), with a custom name (--name seq), map the local seq_data directory to the container's /data folder (-v), and forward the host's port 5341 to the container's port 80 (-p).
Open your web browser and navigate to http://localhost:5341. You should see the Seq web interface.
You can now use the Seq instance running in the Docker container to collect and analyze your logs. When configuring your SeqLoggingInterceptor, use the Seq URL http://localhost:5341 to send logs to this instance.
For more information on running Seq with Docker, refer to the official Seq documentation.
Contributions #
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or a pull request.
License #
This project is licensed under the MIT License. See the LICENSE file for details.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.