Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
Is it safe to use a static `Serilog.ILogger`

I am using Serilog. I want to write log entries with a SourceContext of the containing class.

Is it safe (including thread safe) to do this:

using Serilog;

...

class Foo
{
    private static readonly ILogger Log =
     Serilog.Log.ForContext<Foo>();

    /* Invoke Log.Debug(...) etc. in other methods */
}

The documentation (linked) has a small example that adds the context within a method, rather than creating one to share for the type as above. I'd rather not have to put the same boiler plate code into every method where I am logging. Empirically the above seems to work, but can anyone offer definitive guidance?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Yes, ILoggers in Serilog are always safe to use concurrently from multiple threads.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda