by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 09 20:14

    mivano on dev

    Upgrade Elasticsearch.Net to 7.… (compare)

  • Jul 05 23:05

    ckadluba on dev

    Update README.md Added informa… (compare)

  • Jul 02 23:13

    serilog-build on v3.4.0

    (compare)

  • Jul 02 23:03

    serilog-build on v278

    (compare)

  • Jul 02 23:02

    merbla on master

    Compatibility with .net standar… Dispose StringWriter typo and 11 more (compare)

  • Jul 02 00:31

    merbla on dev

    Use sink NuGetKey (compare)

  • Jul 02 00:28

    merbla on dev

    Bump 3.4 Merge pull request #129 from me… (compare)

  • Jul 02 00:21

    merbla on dev

    Update NuGet API Key. Merge pull request #127 from me… (compare)

  • Jul 02 00:15

    merbla on dev

    Compatibility with .net standar… Dispose StringWriter typo and 3 more (compare)

  • Jul 02 00:13

    merbla on dev

    X-Splunk-Request-Channel header… Merge pull request #126 from dr… (compare)

  • Jul 01 10:34

    ckadluba on dev

    Add support for DateTime2 DataT… Add DateTime2 TimeStamp config … Add DateTime2 timestamp json fo… and 2 more (compare)

  • Jul 01 10:29

    ckadluba on dev

    Bumped version number. (compare)

  • Jun 29 01:03

    nblumhardt on dev

    NuGet publishing key (compare)

  • Jun 29 00:58

    nblumhardt on dev

    Use Environment.User* on .NET S… Merge pull request #37 from 0xc… (compare)

  • Jun 25 20:58

    kashifsoofi on dev

    target framework netstandard2.0 add netcoreapp3.1 TargetFramewo… Merge branch 'dev' into standard and 4 more (compare)

  • Jun 22 14:57

    kashifsoofi on revert-72-master

    (compare)

  • Jun 22 14:55

    kashifsoofi on dev

    5.0.0 Release (#49) * Dev vers… Merge branch 'dev' into master Merge branch 'master' into dev (compare)

  • Jun 22 14:53

    kashifsoofi on dev

    Revert "5.0.0 Release (#49) (#7… Merge pull request #73 from ser… (compare)

  • Jun 22 14:52

    kashifsoofi on revert-72-master

    Revert "5.0.0 Release (#49) (#7… (compare)

  • Jun 22 14:51

    kashifsoofi on dev

    5.0.0 Release (#49) (#72) * De… (compare)

Daniel
@ddieppa
Hi All, I am trying to use the Serilog middleware to add more details to the logs but the diagnostic context is not logging it
public static IApplicationBuilder UseCustomSerilogRequestLogging(this IApplicationBuilder application) =>
            application.UseSerilogRequestLogging(
                options =>
                {
                    options.EnrichDiagnosticContext = (diagnosticContext, httpContext) =>
                    {
                        var request = httpContext.Request;
                        var response = httpContext.Response;
                        var endpoint = httpContext.GetEndpoint();

                        diagnosticContext.Set("Host", request.Host);
                        diagnosticContext.Set("Protocol", request.Protocol);
                        diagnosticContext.Set("Scheme", request.Scheme);

                        if (request.QueryString.HasValue)
                        {
                            diagnosticContext.Set("QueryString", request.QueryString.Value);
                        }

                        if (endpoint is object)
                        {
                            diagnosticContext.Set("EndpointName", endpoint.DisplayName);
                        }

                        diagnosticContext.Set("ContentType", response.ContentType);
                    };

                });
I dont see any differences in the logs adding this with the normal logging, so I am assuming is not logging any of the new stuff
maheshenator
@maheshenator
how can i use "shared" attribute in appsettings.json file,( there are examples on how to use in code. .WriteTo.File("log.txt", shared: true)), but for my app need to use from appsetting.json file
Nicholas Blumhardt
@nblumhardt
@ddieppa the diagnostic context is only applied to the single event generated per request by the Serilog middleware; can you spot the properties on there?
@maheshenator thanks for posting the SO link, will take a look :+1:
Daniel
@ddieppa
@nblumhardt sorry for this question, but I am completely new to Serilog, what do you mean by "the single event generated per request by the Serilog middleware"? I don't see any difference on what I am logging using this CustomMiddleware or the default SerilogRequestLogging
Michael W Powell
@mwpowellhtx
Hello, I am getting my feet wet with Serilog first time, coming from a some time log4net background, so configuration, etc, is not entirely foreign to me.
I am trying to start from loosely based on the sample, but I am getting an exception, Inner Exception 1: ArgumentException: Configuration for Action<Serilog.Configuration.LoggerEnrichmentConfiguration> is not implemented.
any ideas why I might get that sort of exception, more or less out of the box/gate?
first thoughts, maybe I am missing an .Enrich.... call. I suppose I could pear back to just .ReadFrom.Configuration(root) and see what that yields.
Michael W Powell
@mwpowellhtx
for giggles I copied pretty much straight out of the sample, exchanging netcoreapp3.1 for the multitarget, and referencing the Serilog.Settings.Configuration package instead of the project, and still got the same error.
Mark Olbert
@markolbert

Quick question: I've written a wrapper around Serilog (to more easily capture source code information and to allow SMS logging). It supports dependency injection. My basic DI configuration (for Autofac) creates a singleton ILogger which is then wrapped by instances of the wrapper (IJ4JLogger).

Is that thread safe? Or should I use instance-based DI for both the wrapped ILogger and the wrapping IJ4JLogger? If I go instance-based is Serilog itself designed so that multiple ILogger's can, say, write to the same file sink? (That's why I went with a singleton ILogger in the first place)

Michael W Powell
@mwpowellhtx
anyone have any thoughts on why the Samples out of the box are broken?
Michael W Powell
@mwpowellhtx
From the github issue, turns out it was, I need to reference the dev package, then it worked.
Michael W Powell
@mwpowellhtx
Okay dokay, it builds using the dev package, it "runs", but I do not get anything written to the log file?
Michael W Powell
@mwpowellhtx
figure it out, getting namespaces and such correct in the filters
ManteshJangond
@ManteshJangond
Hello, I am looking for encrypt the file logging using Serilog, anyone please help me
Keith Barrows
@KeithBarrows
image.png

Running into a weird challenge:

    Public Sub LogClose(kronosId As String) Implements IAccessor.LogClose
        Dim logEntry As New LogEntry With {
            .KronosId = kronosId,
            .FacIdentifier = _appConfig.FacIdentifier,
            .Origin = _appConfig.Origin
        }

        Log.Debug("{Method}: {@LogEntry}", "LogClose", logEntry)

        SetBaseRequest("Scads/Logs/ForceClose/{sessionId}/{gtnra}", Method.POST)
        _request.RequestFormat = DataFormat.Json
        _request.AddBody(logEntry)
        _response = _client.Execute(_request)
    End Sub

produces this in the Seq:
image.png

Thoughts? logEntry is a simple class with simple properties...
Keith Barrows
@KeithBarrows
@ManteshJangond - Pull the file logger sink code from GitHub and add your encryption to it for your use?
Ruben Bartelink
@bartelink
@ManteshJangond IIRC if you search the file sink Issues, this has been asked/answered
Nathan Winder
@nathanwinder
Hello, and thank you in advance. I need to mitigate the risk of CRLF injection attacks in our application logging. (https://owasp.org/www-community/vulnerabilities/CRLF_Injection) . I reviewed the documentation but was unable to find guideance on this topic. We are using the Application Insights Sink (https://github.com/serilog/serilog-sinks-applicationinsights) it appears that a Custom ITelemetryConverter may be what we want but I wanted to confirm there isn't a solution already available or perhaps a better way to implement a solution.
Nicholas Blumhardt
@nblumhardt
@markolbert yes, Serilog loggers are thread-safe and should generally be singletons or singleton-like :+1:
Hi @KeithBarrows - this often happens when the properties are actually fields - not sure how they're declared in VB.NET, but if you post some more details of the LogEntry class I might be able to spot it. HTH!
Nicholas Blumhardt
@nblumhardt
@nathanwinder Hi! Thanks for the link to the CRLF page on OWASP... Seems like a very weak vulnerability category?! (That page could just as well be named "Bug"!) :-D ... I think logs without CLRFs will be very odd indeed; imagine a multiline stack trace with no newlines... The good news is that all the logs sent to AI are JSON-encoded, so any injected CR or LF will be converted into the \r or \n JSON escape sequence. AI will decode these to, for example, so line breaks in stack traces, but this is all main-line AI functionality and doesn't constitute any kind of vulnerability. HTH!
Nathan Winder
@nathanwinder
@nblumhardt I thought that might be the case, thank you.
Nicholas Blumhardt
@nblumhardt
:+1:
Keith Barrows
@KeithBarrows
Public Class LogEntry
    Public Id As Guid?
    Public FacIdentifier As String
    Public OriginId As String
    Public Origin As String
    Public DestinationId As String
    Public Destination As String
    Public KronosId As String
    Public TimeIn As DateTime
    Public TimeOut As DateTime?
End Class
Looks like I may need to convert these to get/sets?
Keith Barrows
@KeithBarrows
testing...
Nicholas Blumhardt
@nblumhardt
Hi @KeithBarrows - yes, these are fields, and not properties; Serilog only captures and serializes public properties
If it's possible to change them to properties that's the most straightforward option; otherwise, there's a plug-in described in https://stackoverflow.com/questions/46152092/serilog-serializing-fields that can do the trick :-)
Hope this helps!
Been a little buried in the 2020.1 release, sorry about the slow reply, will check in here tomorrow and see whether you've had any luck
Arthri
@Arthri
For the File sink, how can I set it to roll over to a new file every time a day passes/clock hits 12am?
Nicholas Blumhardt
@nblumhardt
@Arthri rollingInterval: RollingInterval.Day should do that :+1:
Arthri
@Arthri
@nblumhardt is there a way to change what is appended to the file when I use RollingInterval.Day?
Nicholas Blumhardt
@nblumhardt
@Arthri to the filename? No, it's a fixed pattern
Arthri
@Arthri
oh
thanks :+1:
NeophileJagpal
@NeophileJagpal
Hey all I have integrated serilog with es sink in my application which supports .NET framework 4.5.....i am getting error "failed to put template [serilog-events-template] ... Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:.....using Serilog.Sinks.Elasticsearch" version="7.2.0-alpha0005"
NeophileJagpal
@NeophileJagpal
I can't use Serilog.Sinks.Elasticsearch version than 7.2.0-alpha0005 as that doesn't support .NET4.5
Gerboa
@Gerboa

Is there a way to force parameter names in message templates and/or context variables to PascalCase?
e.g.

Log.ForContext("myValue", myVar).Debug("Object is {@objectValue}.", objVal);

would create parameter names of MyValue and ObjectValue.

Peyman Mehrbani
@paymanx
hi
how I can write different event level to different file?
for example: debug-20200101.log or fatal-20200101.log?
Ruben Bartelink
@bartelink
@paymanx You'll likely get a quicker response on stackoverflow.com
@Gerboa my guess before I look at the code is that you could achieve it by walking the captured properties with an Enricher in your log configuration. I dont believe it exists. Well worth asking this on stackoverflow.com (and posting a link back here for the few here that do not track the serilog tag on SO)
CenturySpine
@CenturySpine
hello everyone ! is there a release date of the sink.file library which includes the timeSpan rolling file parameter ?
Ruben Bartelink
@bartelink
There's what seems a canonical question about adding context to exception logging on SO which I assume must ahve a good answer (involving DiagnosticContext?) - I'd personally like to know the answer! https://stackoverflow.com/questions/62790173/serilog-additional-properties-with-exception-logging?noredirect=1#comment111077843_62790173