Example of ASP.NET Core app with container logging.
you can create a new ASP.NET Core app using dotnet CLI:
dotnet new web -o src/ -n aspnetcore-docker-loggingASP.NET Core 3.0 app has three types of default loggers:
Microsoft.Extensions.Logging.Console.ConsoleLoggerMicrosoft.Extensions.Logging.Debug.DebugLoggerMicrosoft.Extensions.Logging.EventSource.EventSourceLogger
Once you start the app inside of the container, you should be able to view its logs by pulling container logs:
docker logs <containerId>build the app using docker build command:
docker build -t aspnetcore-docker-logging .build the app using VS Code task:
- open Command Palette (
Cmd + Shift + P) - choose or type in
Tasks: Run Task - choose or type in the task name -
build
run the app via dotnet CLI command:
dotnet run --project yourProject.csprojrun the app in a container using docker-compose:
docker-compose uprun the app as a Kubernetes deployment (assuming you have local kube instance running):
# deploy app to kubernetes
kubectl create -f deployment.yml
# verify that app runs on exposed NodePort
curl http://localhost:31000- open the app folder in VS Code and switch to
Debugview - choose between
Docker: Launch .NET Core (Preview)or.NET Core Launch (web)option - start the app in debug mode