Git Product home page Git Product logo

serilog-docker's Introduction

Serilog with Docker

A docker image for testing Serilog on Docker platforms. It also includes a number of sample apps.

PreReqs

  • Docker

Building the Serilog Library

  • Clone this repo.
  • Run docker-compose build to:
    • pull the images
    • build a docker image
  • Run docker-compose up to:
  • To enter the container with out using compose, use docker run -it --entrypoint=/bin/bash serilog

Run the Samples

This repo also contains the following samples:

  • Console App
  • Web App
  • FSharp Web App

To run these, run docker-compose -f samples.yml up --build

This will

  • Build & run the sample docker images.

  • The console app periodically does a HTTP GET to the

    • C# Kestrel Sample
    • F# Kestrel Sample
  • The console app also logs to the Console, Seq and Splunk sinks.

  • The web apps are also configured to use Serilog via Microsoft.Extensions.Logging & Serilog.Extensions.Logging.

  • Seq Host - http://localhost:80

  • Splunk Host - http://localhost:8000

Windows Containers samples

PreReqs

Quick setup

# Add the containers feature and restart
Install-WindowsFeature containers
Restart-Computer -Force

# Download, install Docker Engine, Docker Compose
Invoke-WebRequest "https://download.docker.com/components/engine/windows-server/cs-1.12/docker.zip" -OutFile "$env:TEMP\docker.zip" -UseBasicParsing
Expand-Archive -Path "$env:TEMP\docker.zip" -DestinationPath $env:ProgramFiles

Invoke-WebRequest -Uri https://dl.bintray.com/docker-compose/master/docker-compose-Windows-x86_64.exe -OutFile $env:ProgramFiles\Docker\docker-compose.exe -UseBasicParsing

# set PATH
$env:Path += ";c:\program files\docker"
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Docker", [EnvironmentVariableTarget]::Machine)

# Configure Docker daemon to listen on both pipe and TCP
dockerd.exe -H npipe:////./pipe/docker_engine -H 0.0.0.0:2375 --register-service

# Start Docker daemon
Start-Service docker

Run the Samples

This repo contains the following windows samples

To run these, run docker-compose -f samples-windows.yml up

Containers use nat network. To inspect what IPs they got run docker network inspect nat in the separate cmd shell and find your containers:

"Containers": {
    "5f66928248090245cc4313d8ff114a27e2a98ffaaf25f77518e6b7b8eb042c3a": {
        "Name": "serilogdocker_web-sample_1",
        "EndpointID": "1b18aae7a2bb05e3b82e7bd35a63595a7aef828041e77c4da61c6ca36537ed5e",
        "IPv4Address": "172.23.144.124/16",
        "IPv6Address": ""
    },
    "83313f0f78ca0447801ef29d1953e65be3d73e1d168c627e5593a255eedd1672": {
        "Name": "serilogdocker_seq_1",
        "EndpointID": "6649b52db115b5f7288e4a99fa298b7fe4f1991892abdbed9305cb175143e775",
        "IPv4Address": "172.23.155.24/16",
        "IPv6Address": ""
    }
}

Navigate to the Web App and Seq Web UI (http://172.23.144.124:5000 and http://172.23.155.24:5341/ accordingly for the example above)

serilog-docker's People

Contributors

adamchester avatar merbla avatar merbs-splunk avatar nblumhardt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

serilog-docker's Issues

Console logs with colour

Should we switch the samples.yml to use tty: true so that we can see colourful console logs? Is there any reason this might cause issues for any use case I haven't considered?

I will send a PR if we agree it's useful.

image

.net core (3.1) web api problem

can't add .UseSerilog() in 3.1 v

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{

                webBuilder.UseStartup<Startup>().**UseSerilog**();
            });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.