GithubHelp home page GithubHelp logo

serilog-enrichers-process's Introduction

Serilog.Enrichers.Process

The process enricher for Serilog.

Build status NuGet Version

To use the enricher, first install the NuGet package:

Install-Package Serilog.Enrichers.Process

Then add Enrich.WithProcessId() and/or .WithProcessName() to the LoggerConfiguration():

Log.Logger = new LoggerConfiguration()
    .WriteTo.Console()
    .Enrich.WithProcessId()
    .Enrich.WithProcessName()
    .CreateLogger();

Copyright © 2016 Serilog Contributors - Provided under the Apache License, Version 2.0.

serilog-enrichers-process's People

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serilog-enrichers-process's Issues

Process (& Thread) Enrichers not working with self-contained/publishSingleFile apps

I noticed that the ProcessId and ThreadId properties are blank in the following configuration:

  • net6.0-windows
  • PublishSingleFile=true
  • Using Serilog.Settings.Configuration and appsettings.json to reference enrichers (not setup in code) via "Enrich": [ "WithProcessId", "WithThreadId" ],

The logging works correct (properties are there) if I copy these enricher assemblies into the executable directory (I verified that they are also part of the packaged executable via the sfextract utility, so they weren't "trimmed" out in publishing)

As a workaround, I'm deploying these two again into the installation directory.

Is this a known/expected limitation?

Use Assembly name in .Net Core

In .Net core apps, they are typically run via "dotnet MyProgram.dll". This means the program name will always use "dotnet" as the program name. It would be really handy if this could be detected and the name of the actual .net core console app could be used.

I hacked up some local mods to effect these changes. Effectively, if the process name is "dotnet" I retrieve the entity dotnet is executing via

System.Reflection.Assembly.GetEntryAssembly().GetName().Name;

As it turns out, .Net standard 1.3 doesn't have the GetEntryAssembly() method, so I modified the project to add a .Net Standard 2.0 to the frameworks and conditionally compile the code above on .NetStandard 2.0.

My visual studio 2017 did some migration on the project so I'll include the csproj file that resulted from that since that is where I had to set up the .Net Standard 2.0 build.
dotnetcore-process-name.patch.txt

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.