GithubHelp home page GithubHelp logo

fantasticfiasco / serilog-sinks-http-sample-dotnet-core Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 4.0 470 KB

Sample application of Serilog.Sinks.Http producing log events in .NET Core.

License: Apache License 2.0

C# 90.12% Dockerfile 9.88%
serilog sinks http sample

serilog-sinks-http-sample-dotnet-core's Introduction

Serilog.Sinks.Http - Sample in .NET Core

CI

This repository contains a sample application of Serilog.Sinks.Http producing log events sent over HTTP to a basic log server.

Sample output

Running the application

  1. Run docker compose up

What you will end up with is two containers, one producing log events while the other consumes the log events.

Remarks

  • The sample application is using a custom implementation of a HTTP client, mainly to show that it is possible to do so. But don't specify a custom implementation if you don't have to.
  • The sink is configured in code, but could as well be configured in appsettings.json using Serilog.Settings.Configuration.

serilog-sinks-http-sample-dotnet-core's People

Contributors

fantasticfiasco avatar github-actions[bot] avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

serilog-sinks-http-sample-dotnet-core's Issues

have any plan to support https?

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(deps): update dependency serilog.sinks.http to v9

Detected dependencies

docker-compose
docker-compose.yml
dockerfile
log-server/Dockerfile
  • mcr.microsoft.com/dotnet/sdk 8.0-alpine
sample/Dockerfile
  • mcr.microsoft.com/dotnet/sdk 8.0-alpine
github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • docker/setup-buildx-action v3
.github/workflows/update-copyright-years-in-license-file.yml
  • actions/checkout v4
  • FantasticFiasco/action-update-license-year v3
nuget
log-server/log-server.csproj
  • Serilog.Sinks.Console 5.0.1
  • Serilog.AspNetCore 8.0.1
sample/sample.csproj
  • Serilog.Sinks.Http 8.0.0
  • Serilog.Sinks.Console 5.0.1
  • Microsoft.Extensions.Configuration 8.0.0
  • Bogus 35.5.0

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Controller write log

In the program, I can write log normally through ilogger, and in the homecontroller_ Logger cannot write to log

` ILogger log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Http(requestUri: "http://localhost:5000/api/log")
.WriteTo.Console()
.ReadFrom.Configuration(configuration)
.CreateLogger();

        log.Information("Logging xxxx");
        log.Error("Logging 999");

`

`
private readonly ILogger _logger;

    public HomeController(ILogger<HomeController> logger)
    {
        _logger = logger;
    }

    public IActionResult Index()
    {
        _logger.LogInformation("9999");
        _logger.LogInformation("开始记录it环境日志", DateTime.Now);

        try
        {
            _logger.LogInformation("这是it环境的业务日志");
            _logger.LogWarning("这是it环境的警告日志");
            throw new Exception();
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "这是it环境的错误日志");
        }

        return View();
    }

`

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.