A_kat
A_kat

Reputation: 1527

How to read logs from console or docker container

I am creating an API using ASP.NET Core. Now I produce logs in console for speed.

I want to create a Go application that reads those logs produced by ASP.NET Core (they will be run in the same host in different containers).

My question how do you go about reading the console output of the ASP.NET Core logging with Go. I use the default logging:

.ConfigureLogging(logging =>
{
        logging.ClearProviders();
        logging.AddConsole();
})

Also I read that you can output logs in a docker container, so would that be a best option?. What is generally the best option for my problem.

Upvotes: 0

Views: 3005

Answers (2)

C Han
C Han

Reputation: 140

There are two go docker clients, i know.

  1. https://github.com/fsouza/go-dockerclient
  2. https://github.com/docker/go-docker

Both of them have log methods to retrieve logs from containers.

Upvotes: 1

rolf82
rolf82

Reputation: 1571

If your application is logging to stdout in docker, then you can read the logs with docker logs.

For example use docker logs -f container_name to follow in realtime the logs of your container (replace with your container's name).

Upvotes: 2

Related Questions