Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 26 22:29

    serilog-build on v5.0.1

    (compare)

  • Oct 26 22:28

    nblumhardt on dev

    Dev version bump [skip ci] (compare)

  • Oct 26 22:27

    serilog-build on v76

    (compare)

  • Oct 26 22:27

    nblumhardt on master

    Dev version bump [skip ci] Implement RaygunIdentifierMessa… Documentation and 48 more (compare)

  • Oct 26 22:25

    nblumhardt on version-5

    (compare)

  • Oct 26 22:24

    nblumhardt on dev

    Fix versioning (compare)

  • Oct 26 22:18

    nblumhardt on dev

    Version 5 Merge pull request #33 from ser… (compare)

  • Oct 26 21:56

    QuantumNightmare on version-5

    Version 5 (compare)

  • Oct 26 19:57

    QuantumNightmare on response-details

    (compare)

  • Oct 26 19:56

    QuantumNightmare on dev

    WIP experimenting with using th… move all property-driven featur… Pass the desired OccurredOn dat… and 10 more (compare)

  • Oct 26 07:30

    nblumhardt on dev

    Docs: Added pushing properties … (compare)

  • Oct 26 07:28

    nblumhardt on dev

    Add a netstandard2.0 target to … Merge pull request #16 from Num… (compare)

  • Oct 23 01:56

    QuantumNightmare on response-details

    Some further details about the … (compare)

  • Oct 23 01:37

    QuantumNightmare on response-details

    minor edits (compare)

  • Oct 22 23:52

    QuantumNightmare on response-details

    Added raw data and local storag… sorting out some inconsistencie… (compare)

  • Oct 22 04:03

    QuantumNightmare on response-details

    Don't use the default wrapper e… More detail about the various s… (compare)

  • Oct 21 22:19

    nblumhardt on dev

    Update NuGet.org publishing key (compare)

  • Oct 21 04:00

    QuantumNightmare on response-details

    Adding some documentation to th… (compare)

  • Oct 21 03:22

    Jaben on dev

    One more tweak to get the versi… (compare)

  • Oct 21 03:18

    Jaben on dev

    Fix for build version and corre… (compare)

matrixbot
@matrixbot

@iinuwa:matrix.org Does this achieve what you want? I create a the static Logger in the Main method, and then using Serilog.Extensions.Logging call ConfigureLogging with the AddSerilog(ILogger) method:

```csharp
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration().CreateLogger();

public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
  .ConfigureWebHostDefaults(webBuilder =>
  {
    webBuilder.ConfigureKestrel(opts => opts.AddServerHeader = false);
    webBuilder.ConfigureAppConfiguration((_, config) => config.AddMsappEnvironment());
    webBuilder.UseStartup<Startup>();
  })
  .ConfigureLogging(logging =>
  {
      logging.ClearProviders();
      logging.AddSerilog(Log.Logger);
  });

}
}

@iinuwa:matrix.org * Does this achieve what you want? I create a the static Logger in the Main method, and then using Serilog.Extensions.Logging call ConfigureLogging with the AddSerilog(ILogger) method:
public class Program
{
  public static void Main(string[] args)
  {
    Log.Logger = new LoggerConfiguration().CreateLogger();

    public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
      .ConfigureWebHostDefaults(webBuilder =>
      {
        webBuilder.UseStartup<Startup>();
      })
      .ConfigureLogging(logging =>
      {
          logging.ClearProviders();
          logging.AddSerilog(Log.Logger);
      });
  }
}
Tal McMahon
@TalMcMahon
Ahh, so you are creating it immediately, then pushing it into the dependency?
is that what ConfigureLogging does? meaning I still use contructor injection (ILogger<type> logger)
matrixbot
@matrixbot
@iinuwa:matrix.org No, no dependency injection Log.Logger is the actual static instance being passed into the host logging configuration
@iinuwa:matrix.org This is just an example from my tests; I don't like how much the WebHost logs, so I actually just run ClearProviders and don't add Serilog. That way only my application logs get logged. (Quick and dirty method while I figure out how to filter stuff properly.)
Tal McMahon
@TalMcMahon
kk
matrixbot
@matrixbot
@iinuwa:matrix.org Someone else may have a better method, I and I think that Nicholas (the author) recently opened a PR that would allow bootstrapping the static logger and the host config in one method.
iinuwa
@iinuwa

Working on some Serilog/.NET Core host integration to both allow start-up exceptions to be logged, and support consuming services and configuration from the host once it's bootstrapped; PR is at serilog/serilog-extensions-hosting#28 if you have a chance to check it out/send feedback :-)

Here's the PR I was talking about

Tal McMahon
@TalMcMahon
cool, I will check it out
Tal McMahon
@TalMcMahon
There's another overload of UseSerilog() that accepts an ILogger .... I am going to try that one
dirtmaster1
@dirtmaster1
running serilog to log to fixed filename, log file gets archived peridoically and then gets re-created with same name at same location but serilog stops logging after that point. Is there a way to have serilog continue logging to that file when that type of event happens?
sapnaavya
@sapnaavya
Hello, I am using serilog JSON formatter "formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog" and below is the output I am getting:
{"Timestamp":"2020-10-19T17:05:24.5176744-07:00","Level":"Information","MessageTemplate":" producer disposed","Properties":{"SourceContext":"TestClass","ThreadId":92}}
I was wondering if there is a way to remove the last few digits in timestamp. I would like to remove 5176744 from the timestamp.
Nicholas Blumhardt
@nblumhardt
@sapnaavya not with JsonFormatter, but https://github.com/serilog/serilog-expressions#formatting should be able to do it via {Timestamp: Substring(@t, 0, 19), ...
sapnaavya
@sapnaavya
Thanks @nblumhardt . Since JSONFormatter does not allow timestamp format to change.. may be..we can achieve this by implementing custom formatter and import that cutom formatter in logging.config file.
Nicholas Blumhardt
@nblumhardt
@sapnaavya yep, that would also work :+1:
Weston
@ronnyek
So I'm using console loggign sink... is there a way to tell serilog to highlight a specific area of a string to be logged out?
is that a matter of just using string formats syntax for logging out messages?
Tal McMahon
@TalMcMahon
Thats What I do..... a few "~~~" or simialr
Weston
@ronnyek
wait, what?
~~
Tal McMahon
@TalMcMahon
I just add to the string itself. I add tilda or spaces something so that the log is a bit easier to scan/search on
Weston
@ronnyek
like you just look for the tildes or it actuially translates that into a highlight
Tal McMahon
@TalMcMahon
like Log.LogInformation("=====>Service Started")
Weston
@ronnyek
because console logger has literateconsole functionality
where if you use string format, it'll actually color the substitued values or whatever
Tal McMahon
@TalMcMahon
Oh, sorry. I meant in the file sink
my bad
Weston
@ronnyek
hmm... actually the syntax highlighting doesnt do the trick
with a string format
I dont see it documented anywhere
Tal McMahon
@TalMcMahon
yeah thats why I ended up here.
worked for both
I mean with the string format answer
Weston
@ronnyek
I know literate console does do that, for some things
like I had a string I was formattign
{someNumber: {{0:0.00}}}
and it was highlighting that, but leaving the {{}} in the highlighted code
I'd just like to say logger.LogInformation("count: {0}",20) and have 20 automatically highlighted in something thats not the regular logging color
Weston
@ronnyek
I bet when I was seeing it highlight stuff, I bet it just thought that was json
erikljung
@erikljung
Hi, probably a stupid question, but maybe someone has a creative solution to my unconventional issue. I would like to create a logger with MinimumLevel = Warning for all sinks, but i also want to collect all logs in a special sink regardless of the MinimumLevel . I know restrictedToMinimumLevel can be set per sink, but that is not flexible enough for me.
Ruben Bartelink
@bartelink
@erikljung Id say this is worth asking on SO. Main problem I see is that each logger chain has a min level (defaulting to Information, which filters them before they get to the sinks). Adding the sink to grab all warnings into the config is the easy bit.
Nathan Skerl
@nskerl
@erikljung have you looked into subloggers? You could send the conditional stream to an entire new logger which has your special sink
erikljung
@erikljung
@bartelink @nskerl Thanks for your answers. I've already solved the problem by setting restrictedToMinimumLevelfor all other sinks and keeping the LoggerConfiguration unlimited. It would probably not be the optimal solution regulary, but I had a very unimportant usecase. I will however check out the sublogger thing.
MyFleetCenter
@MyFleetCenter
Hello, is there a way to use the Elasticsearch sink to write to Enterprise search on Elastic Cloud? I can upload using Postman without issue, but trying to upload it using my C# api application shows me this in Fiddler: {"errors":"Routing Error. The path you have requested is invalid."}. I found this on SO regarding Nest and Enterprise search but not sure if it also applies to the Elasticsearch sink : https://stackoverflow.com/questions/64137515/search-issue-with-elasticsearch-nest-routing-error-the-path-you-have-requeste
zcarson
@zcarson
Hello, I'm using the Http sink to forward my log messages to another service. I need to have the message shaped into a specific PoCo that should contain values based on the appsettings.json. I've tried injecting the IOptions into a custom ITextFormatter, but it is complaining that there is no default constructor. Is there an easy way to get config values into the textFormatter, or another way to get those values in? Once that problem is solved, I have a similar issue with getting an Authkey into the request headers that the Http sink is sending, but I havent started tackling that yet so it may be easier.
Thibaud Desodt
@tsimbalar
maybe https://stackoverflow.com/questions/50387469/net-core-and-serilog-email-sink-json-config/50580020#50580020 can help ?
Otherwise I'd suggest posting a question on stackoverflow with the serilogtag
zcarson
@zcarson
Coworker suggested adding it to a WithProperty Enricher; seems to have done the trick