This is a very simple sample showing how to log an ASP.Net Core on Graylog
Tool | Desc | Download |
---|---|---|
Docker | Specially to run the Compose to run up all the solution dependencies like Mongo, Graylog and Elastic Search | https://store.docker.com/ |
DotNet Core SDK | To run the sample application. You can optionally run the sample application on a container but you will need to deal with networking stuff | https://www.microsoft.com/net/download |
Run dependencies means run all stack required for Graylog (MongoDb, ElasticSearch and Graylog itself). By default, Graylog locks some host ports:
Ports | Desc |
---|---|
9000 | Graylog web interface and REST API |
514 | Syslog TCP |
514/udp | Syslog UDP |
12201 | GELF TCP |
12201/udp | GELF UDP |
To run the solution dependencies, run the following command on project root:
docker-compose up -d
The
-d
option is opitional and tells the command to run on background freeing up the terminal.
To run the sample application, just run the command
dotnet run -p ./SampleMVC
By default, the sample application locks the 5000 port on host.
The sample applications uses the Gelf.Extensions.Logging library, that relyes on Microsoft.Extensions.Logging, enabling a very seamless integration to the application pipeline and enabling a very simple loggin implementation. To log informations to Graylog just use the common pattern as described in the ASP.Net Core Documentation.
The view logged information on Graylog, just access the web interface.
By default, it should be running on http://localhost:9000
.