{"id":15137856,"url":"https://github.com/satrapu/aspnet-core-logging","last_synced_at":"2026-03-01T12:31:34.769Z","repository":{"id":39498610,"uuid":"151933388","full_name":"satrapu/aspnet-core-logging","owner":"satrapu","description":"This repo shows ASP.NET Core 9 logging in action; it also serves as a learning, experimenting and teaching path for .NET, Azure Pipelines and other technologies \u0026 tools.","archived":false,"fork":false,"pushed_at":"2026-01-25T18:10:54.000Z","size":1883,"stargazers_count":19,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-26T09:50:46.526Z","etag":null,"topics":["aspnetcore","autofac","azure-pipelines","colima","coverlet","database-migrations","docker","docker-compose","ef-core","jaeger","net9","nunit3","open-telemetry","pgadmin","postgresql","reportgenerator","seq","serilog","sonarcloud","verify"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/satrapu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-10-07T11:17:21.000Z","updated_at":"2025-06-12T01:12:23.000Z","dependencies_parsed_at":"2023-11-19T17:25:58.123Z","dependency_job_id":"9d7223d0-5e1d-4186-b27e-088d27e43c3f","html_url":"https://github.com/satrapu/aspnet-core-logging","commit_stats":{"total_commits":829,"total_committers":5,"mean_commits":165.8,"dds":"0.010856453558504175","last_synced_commit":"ed983914d5ed5342e7b75aaa5a6abed08d53e604"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/satrapu/aspnet-core-logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrapu%2Faspnet-core-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrapu%2Faspnet-core-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrapu%2Faspnet-core-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrapu%2Faspnet-core-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/satrapu","download_url":"https://codeload.github.com/satrapu/aspnet-core-logging/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/satrapu%2Faspnet-core-logging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29969243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T11:43:06.159Z","status":"ssl_error","status_checked_at":"2026-03-01T11:43:03.887Z","response_time":124,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspnetcore","autofac","azure-pipelines","colima","coverlet","database-migrations","docker","docker-compose","ef-core","jaeger","net9","nunit3","open-telemetry","pgadmin","postgresql","reportgenerator","seq","serilog","sonarcloud","verify"],"created_at":"2024-09-26T07:02:46.787Z","updated_at":"2026-03-01T12:31:34.745Z","avatar_url":"https://github.com/satrapu.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aspnet-core-logging\n\n## Description\n\nThis repository shows ASP.NET Core 9 logging in action; it also serves as a learning, experimenting and teaching path for .NET, Azure Pipelines and other technologies \u0026 tools.\n\n:exclamation: Currently this web API uses JSON web tokens (JWT) for authentication \u0026 authorization purposes, but momentarily the mechanism used for generating these tokens has been __greatly__ simplified to the point of being actually naive as my focus is set on other topics; on the other hand, I do intend on providing a more realistic implementation in a not so far away future.\n\nThis project has several posts associated with it:\n\n- [Structured logging in ASP.NET Core using Serilog and Seq](https://crossprogramming.com/2021/12/23/structured-logging-in-asp-net-core-using-serilog-and-seq.html)\n- [Use Docker Compose when running integration tests with Azure Pipelines](https://crossprogramming.com/2020/09/03/use-docker-compose-when-running-integration-tests-with-azure-pipelines.html)\n- [Use Docker when running integration tests with Azure Pipelines](https://crossprogramming.com/2019/12/27/use-docker-when-running-integration-tests-with-azure-pipelines.html)\n- [Build an ASP.NET Core application using Azure Pipelines](https://crossprogramming.com/2019/03/17/build-asp-net-core-app-using-azure-pipelines.html)\n- [Logging HTTP context in ASP.NET Core](https://crossprogramming.com/2018/12/27/logging-http-context-in-asp-net-core.html)\n\n## Build\n\n| Build Server                                                                    | Operating System | Status                                                                                                                                                                                                                                             |\n|---------------------------------------------------------------------------------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | Linux            | [![Build Status](https://dev.azure.com/satrapu/aspnet-core-logging/_apis/build/status/ci-pipeline?branchName=master\u0026jobName=Run%20on%20Linux)](https://dev.azure.com/satrapu/aspnet-core-logging/_build/latest?definitionId=2\u0026branchName=master)   |\n| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | macOs            | [![Build Status](https://dev.azure.com/satrapu/aspnet-core-logging/_apis/build/status/ci-pipeline?branchName=master\u0026jobName=Run%20on%20macOS)](https://dev.azure.com/satrapu/aspnet-core-logging/_build/latest?definitionId=2\u0026branchName=master)   |\n| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | Windows          | [![Build Status](https://dev.azure.com/satrapu/aspnet-core-logging/_apis/build/status/ci-pipeline?branchName=master\u0026jobName=Run%20on%20Windows)](https://dev.azure.com/satrapu/aspnet-core-logging/_build/latest?definitionId=2\u0026branchName=master) |\n\n## Code quality\n\n| Provider                                  | Badge                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |\n|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Codacy](https://www.codacy.com/)         | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/001d9d7bbf43459aae186c7d8cd49858)](https://www.codacy.com/gh/satrapu/aspnet-core-logging)                                                                                                                                                                                                                                                                                                                                                                                  |\n| [FOSSA](https://fossa.com/)               | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fsatrapu%2Faspnet-core-logging.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fsatrapu%2Faspnet-core-logging?ref=badge_shield)                                                                                                                                                                                                                                                                                                                 |\n| [SonarCloud](https://sonarcloud.io/about) | [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=aspnet-core-logging\u0026metric=ncloc)](https://sonarcloud.io/dashboard?id=aspnet-core-logging) \u003cbr/\u003e [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=aspnet-core-logging\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=aspnet-core-logging) \u003cbr/\u003e [![SonarCloud Status](https://sonarcloud.io/api/project_badges/measure?project=aspnet-core-logging\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=aspnet-core-logging) |\n\n## Setup local development environment\n\nIn order to run this application locally, you need to setup some things first, like: run PostgreSQL and pgAdmin via Docker Compose, create a PostgreSQL database using EF Core database migrations, etc.\n\n### Setup local persistence services\n\nThis ASP.NET Core web API uses [PostgreSQL](https://www.postgresql.org/) as persistent storage and [pgAdmin](https://www.pgadmin.org/) as database manager, all running locally via [Docker Compose](https://github.com/docker/compose).\n\n#### Create Docker volumes\n\nThese volumes are needed to store data outside the Docker containers running the PostgreSQL databases and their manager.\n\n- Volume used by the local development database\n\n```bash\ndocker volume create --name=aspnet-core-logging-db-for-local-dev_data\n```\n\n- Volume used by the integration tests when run locally\n\n```bash\ndocker volume create --name=aspnet-core-logging-db-for-integration-tests_data\n```\n\n- Volume used by the acceptance tests when run locally\n\n```bash\ndocker volume create --name=aspnet-core-logging-db-for-acceptance-tests_data\n```\n\n- Volume used by pgAdmin tool\n\n```bash\ndocker volume create --name=pgadmin_data\n```\n\n- Volume used by Seq tool\n\n```bash\ndocker volume create --name=seq_data\n```\n\n#### Create .env file\n\nThe [.env](https://docs.docker.com/compose/env-file/) file is used by Docker Compose to avoid storing sensitive data inside `docker-compose.yml` file.\nCreate a new file named `.env` inside the folder where you have checked-out this git repository and add the following lines:\n\n```properties\n# Environment variables used by the local dev DB compose service\nDB_LOCAL_POSTGRES_USER=\u003cDB_LOCAL_USERNAME\u003e\nDB_LOCAL_POSTGRES_PASSWORD=\u003cDB_LOCAL_PASSWORD\u003e\n\n# Environment variables used by the integration tests DB compose service\nDB_INTEGRATION_TESTS_POSTGRES_USER=\u003cDB_INTEGRATION_TESTS_USERNAME\u003e\nDB_INTEGRATION_TESTS_POSTGRES_PASSWORD=\u003cDB_INTEGRATION_TESTS_PASSWORD\u003e\n\n# Environment variables used by the acceptance tests DB compose service\nDB_ACCEPTANCE_TESTS_POSTGRES_USER==\u003cDB_ACCEPTANCE_TESTS_USERNAME\u003e\nDB_ACCEPTANCE_TESTS_POSTGRES_PASSWORD=\u003cDB_ACCEPTANCE_TESTS_PASSWORD\u003e\n\n# Environment variables used by DB client compose service\nPGADMIN_DEFAULT_EMAIL=\u003cPGADMIN_EMAIL\u003e\nPGADMIN_DEFAULT_PASSWORD=\u003cPGADMIN_PASSWORD\u003e\n```\n\nMake sure you replace all of the above `\u003cDB_LOCAL_USERNAME\u003e`, `\u003cDB_LOCAL_PASSWORD\u003e`, ..., `\u003cPGADMIN_PASSWORD\u003e` tokens with the appropriate values.\n\n#### Compose commands\n\nAll of the commands below must be run from the folder where you have checked-out this git repository.\nThis folder contains a `docker-compose.yml` file describing the aforementioned compose services.\n\n##### Run compose services\n\n```bash\n# The -d flag instructs Docker Compose to run services in the background\ndocker compose up -d\n```\n\n##### Stop compose services\n\n```bash\ndocker compose stop\n```\n\n##### Start compose services\n\n```bash\ndocker compose start\n```\n\n##### Display compose service log\n\n```bash\n# The -f flag instructs Docker Compose to display and follow the log entries of the 'pgadmin' service\ndocker compose logs -f pgadmin\n```\n\n##### Destroy compose services\n\nThe command below will **not** delete the Docker volumes!\n\n```bash\ndocker compose down\n```\n\n### Setup pgAdmin\n\nOnce the services have been started using `docker compose up` command, pgAdmin UI is ready to be used.\n\n#### Open pgAdmin UI\n\nOpen your browser and navigate to [http://localhost:8080](http://localhost:8080).\nIn order to start using pgAdmin, you need to authenticate - use the `PGADMIN_DEFAULT_EMAIL` and `PGADMIN_DEFAULT_PASSWORD` properties found in your `.env` file to login.\n\n#### Register your local database server\n\nWhen asked about a PostgreSQL server to register, populate the fields found inside `Connection` tab as below:\n\n- Host name/address = `aspnet-core-logging-dev` - the compose service name and *not* the container name\n(the Docker Compose [networking page](https://docs.docker.com/compose/networking/) is a little bit misleading,\nas it mentions *container name*, that's why the services found inside the `docker-compose.yml` file are named differently than their containers)\n- Port = `5432` - the Docker internal port\n- Username = the value of the `${DB_DEV_POSTGRES_USER}` property from the local `.env` file\n- Password = the value of the `${DB_DEV_POSTGRES_PASSWORD}` property from the local `.env` file\n\n### Setup environment variables\n\nSince storing sensitive data inside configuration file put under source control is not a very good idea,\nthe following environment variables must be defined on your local development machine:\n\n| Name                                                        | Value                                                                                                       | Description                                                                    |\n|-------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| TODO_WEB_API_BY_SATRAPU_CONNECTIONSTRINGS__APPLICATION      | Server=localhost; Port=5432; Database=aspnet-core-logging-dev; Username=satrapu; Password=***;              | The connection string pointing to the local development database               |\n| TODO_WEB_API_BY_SATRAPU_CONNECTIONSTRINGS__INTEGRATIONTESTS | Server=localhost; Port=5433; Database=aspnet-core-logging-integrationtests; Username=satrapu; Password=***; | The connection string pointing to the integration tests database               |\n| TODO_WEB_API_BY_SATRAPU_CONNECTIONSTRINGS__ACCEPTANCETESTS  | Server=localhost; Port=5434; Database=aspnet-core-logging-acceptancetests; Username=satrapu; Password=***;  | The connection string pointing to the acceptance tests database                |\n| TODO_WEB_API_BY_SATRAPU_GENERATEJWT__SECRET                 | \u003cYOUR_JWT_SECRET\u003e                                                                                           | The secret used for generating JSON web tokens for experimenting purposes only |\n\nThe connection strings above use the same username and password pairs find in the local `.env` file.\nThe port from each connection string represent the host port declared inside the local `docker-compose.yml` file -\nsee more about ports [here](https://docs.docker.com/compose/compose-file/#ports).\n\n### Setup local development database\n\nIn order to run the application locally, you need to have an online PostgreSQL database whose schema is up-to-date.\nThe database will be started using the aforementioned Docker Compose commands, while its schema will be updated via one of the options below.\n\n#### Option 1: Manually run database migrations\n\nIn order to create and update the local development database, you need to install EF Core CLI tools; the reference documentation can be found [here](https://learn.microsoft.com/en-us/ef/core/cli/dotnet). I also recommend reading about database migrations [here](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli).\nAll of the commands below should be executed from the folder where you have checked-out this git repository.\n\n- Install dotnet-ef\n\n```bash\ndotnet tool install dotnet-ef --global\n```\n\n:exclamation: Please restart the terminal after running the above command to ensure the following `dotnet ef` commands do not fail.\n\n- Update dotnet-ef to latest version, if requested to do so\n\n```bash\ndotnet tool update dotnet-ef --global\n```\n\n- Add a new database migration\n\n```bash\ndotnet ef migrations add \u003cMIGRATION_NAME\u003e --startup-project ./Sources/Todo.WebApi --project ./Sources/Todo.Persistence\n```\n\n- List existing database migrations\n\n```bash\ndotnet ef migrations list --startup-project ./Sources/Todo.WebApi --project ./Sources/Todo.Persistence\n```\n\n- Update database to the last migration\n\n```bash\ndotnet ef database update --startup-project ./Sources/Todo.WebApi --project ./Sources/Todo.Persistence\n```\n\n- Drop existing database\n\n```bash\ndotnet ef database drop --startup-project ./Sources/Todo.WebApi --project ./Sources/Todo.Persistence\n```\n\n#### Option 2: Run database migrations at application startup\n\nEnsure the `MigrateDatabase` configuration property is set to `true`.\nSee more about applying EF Core migrations at runtime [here](https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli#apply-migrations-at-runtime).\n\n### Inspect log events using Seq\n\nIn order to inspect application log events generated via [Serilog](https://serilog.net/), navigate to [http://localhost:8888](http://localhost:8888), which will open [Seq](https://datalust.co/seq) UI.\n\n### Inspect traces using Jaeger\n\nIn order to inspect application traces, navigate to [http://localhost:16686/search](http://localhost:16686/search), which will open [Jaeger](https://www.jaegertracing.io/) UI.\nTo see Jaeger metrics, navigate to [http://localhost:14269/metrics](http://localhost:14269/metrics).\nTo see Jaeger health status, navigate to [http://localhost:14269/](http://localhost:14269/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatrapu%2Faspnet-core-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsatrapu%2Faspnet-core-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsatrapu%2Faspnet-core-logging/lists"}