by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Nicholas Blumhardt
    @nblumhardt
    The normal .NET integration is to use Exception.ToString() to fill it
    There are sometimes clues in the ingestion log, Settings > Diagnostics > Ingestion Log, though I'm not sure what info will be shown in this case
    Nicholas Blumhardt
    @nblumhardt
    Just improved the docs :-)
    Sander Struijk
    @furier
    Hi
    Contains(RequestHeaders.User-Agent, 'Mozilla')
    Does not return anything, how can one filter on nested properties with - chars in it?
    Nicholas Blumhardt
    @nblumhardt
    Hi @furier - sorry we missed your message earlier!
    RequestHeaders['User-Agent'] like '%Mozilla%'
    is how I'd write that one
    Dotted property access syntax is just a shorthand for the longer form ['x'] indexer syntax
    HTH!
    bitbonk
    @bitbonk

    @nblumhardt How can I tell Seq to destructure all objects? When I do something like

    this.logger.LogTrace( "Received {Message} on named pipe {PipeName}",  message, this.receivingPipeName);

    The message DTO is not destructured, i.e. I can not exapand and collapse any properties of it in the log, it just a single string.

    bitbonk
    @bitbonk
    Do I really have to put an @ before each and every Property?
    Nicholas Blumhardt
    @nblumhardt
    @bitbonk Hi! Yes, that's how Serilog/MEL work :+1:
    Serialization is always opt-in, because in .NET a lot of types inadvertently cause chaos when JSON-serialized (Type, Exception-subclasses, and any entity mapped lazily by EF come to mind as frequent causes of bugs)
    It's not usually good for Seq to serialize in large objects, which may not be an issue for you depending on how big the graph associated with message is, but, if it's more than a kilobyte or two, performance can start to degrade pretty heavily. HTH!
    Hi all - just a quick heads-up in case you haven't spotted it via any other channels, 2020.1 is out! https://blog.datalust.co/seq-2020-1-release-notes/ - feedback and questions appreciated as always. Cheers!
    bitbonk
    @bitbonk
    @nblumhardt Thanks, but what if I want it to be destructurured only when logged to Seq but not when logged to a file (destructuring often is not so helpful in simple text files).
    Nicholas Blumhardt
    @nblumhardt
    In Serilog's design (and implicit in message templates, I guess), is that "capturing" happens first to create the event, and sinks only render it, without having any influence on the capturing phase. It wouldn't be impossible to change this, but there are a lot of trade-offs to consider, so it's not likely this will be possible with Serilog as it stands today. Interesting scenario, though!
    The usual workaround using the Serilog API is something like: Log.ForContext("MessageBody", message, destructureObjects: true).Verbose("Received {Message} on named pipe {PipeName}", message, this.receivingPipeName)
    This attaches two separate properties - Message is stringy, and included in the rendered message text, while MessageBody is attached separately with the full serialized object (and not by default rendered in text-based sinks)
    Might be possible to do something similar using ILogger<T>.BeginScope() in MEL, would be worth exploring. Using an @ property name in a BeginScope() call will trigger destructuring for Seq. HTH!
    Keith Barrows
    @KeithBarrows
    Working in a 4.5.2 VB winforms + web api project. The projects do not have any DI containers nor will any be added. So using the static Log object for logging. However, it appears any properties I try to push into Context are not showing up.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        _appConfig = New ConfigInfo()
        Log.Logger = SerilogSetup.Setup(Me, _appConfig.ReleaseType).ForContext(Of Form1)
    
        _correlationId = Guid.NewGuid
        Try
            Using LogContext.PushProperty("CorrelationId", _correlationId)
                Log.Information("Initialize application")
    
                lblInfo.ForeColor = Color.Black
    ...
    image.png
    May need to click into the image to see what is logged out. I grabbed a random, but confirmed, logging point that should have had the additional contexts...
    Keith Barrows
    @KeithBarrows
    image.png
    Captured the entry that matches my code example...
    TIA
    Keith Barrows
    @KeithBarrows
    Adding the startup code that I have off in a library (so the other devs do it the same way each time)
            public static Serilog.ILogger Setup(object startingObject, string releaseType)
            {
                if (_config == null)
                {
                    var jsonConfig = ConfigurationManager.AppSettings["Serilog"];
                    _config = JsonConvert.DeserializeObject<SerilogConfig>(jsonConfig);
                }
    
                string file = startingObject.GetType().Assembly.Location; 
                _appName = System.IO.Path.GetFileNameWithoutExtension(file);
                _machineName = Environment.MachineName;
                _environment = releaseType ?? "Production";
    
                var propertyList = new Dictionary<string, string>();
                propertyList.Add("AppName", _appName);
                propertyList.Add("MachineName", _machineName);
                propertyList.Add("ReleaseType", _environment);
    #if DEBUG
                propertyList.Add("CompiledFor", "Debug");
    #else
                propertyList.Add("CompiledFor", "Release");
    #endif
    
                LoggerConfiguration = propertyList.Aggregate(LoggerConfiguration, (current, kvp) => current.Enrich.WithProperty(kvp.Key, kvp.Value));
                LoggerConfiguration
                    .Enrich.FromLogContext()
                    .Enrich.WithHttpRequestId()
                    .Enrich.WithHttpRequestClientHostIP()
                    .Enrich.WithHttpRequestClientHostName()
                    .Enrich.WithHttpRequestType()
                    .Enrich.WithUserName("anonymous", System.Environment.UserName);
    
                return InstantiateLogger();
            }
    Nicholas Blumhardt
    @nblumhardt
    @KeithBarrows interesting! I see the Enrich.FromLogContext() there, so it should work.......
    I wonder if an exception might be being thrown somewhere in the logging pipeline, causing some of the info to be suppressed? Turning on SelfLog would show this up, if so.
    The screenshot shows property names with different casing from the code sample - appName vs AppName, for example - could be a stale copy of the library being deployed?
    Keith Barrows
    @KeithBarrows
    Oh - yea. I had just recased those right before the screenshot.
    I stopped self logging as the IIS Express kept throwing a permission not allowed on the Rolling File sink.
    2020-06-24T21:25:23.2656900Z Caught exception while emitting to sink Serilog.Sinks.RollingFile.RollingFileSink: System.UnauthorizedAccessException: Access to the path 'C:\Program Files (x86)\IIS Express\Logs\wsGT4__20200624.log' is denied.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
       at Serilog.Sinks.File.FileSink..ctor(String path, ITextFormatter textFormatter, Nullable`1 fileSizeLimitBytes, Encoding encoding, Boolean buffered, FileLifecycleHooks hooks)
       at Serilog.Sinks.RollingFile.RollingFileSink.OpenFile(DateTime now)
       at Serilog.Sinks.RollingFile.RollingFileSink.AlignCurrentFileTo(DateTime now)
       at Serilog.Sinks.RollingFile.RollingFileSink.Emit(LogEvent logEvent)
       at Serilog.Core.Sinks.SafeAggregateSink.Emit(LogEvent logEvent)
    Keith Barrows
    @KeithBarrows
    I think I have the file write error handled. Off on another fire fight. :|
    Keith Barrows
    @KeithBarrows
    I have not had time to dig further into this - which would require getting the source code for the Classic nuget package. The other thing I am struggling with is passing some sort of CorrelationId. I even force it into the HTTP headers from my origination app:
        Private Sub SetBaseRequest(ByVal correlationId As Guid, targetUrl As String, httpVerb As RestSharp.Method)
            _log.Debug("{Method}: Execute a {Verb} on {Url} with CorrelationId = {CorrelationId}", "SetBaseRequest", httpVerb, targetUrl, correlationId)
    
            _request = New RestRequest(targetUrl, httpVerb)
            _request.AddHeader("X-Request-ID", correlationId.ToString)
            _request.AddHeader("X-Correlation-ID", correlationId.ToString)
    
            _request.AddUrlSegment("sessionId", _appConfig.SessionId)
            _request.AddUrlSegment("gtnra", _appConfig.Gtnra)
            If targetUrl.Contains("{facilityId}") Then
                _request.AddUrlSegment("facilityId", _appConfig.FacIdentifier)
            End If
        End Sub
    Get to the other side of the call and the classic add ons do not pick up either of those headers...
    Rastislav Marko
    @rastignacc
    @nblumhardt Is it possible to rollback to 5.1.xxx from 2020.1? I believe we won't need that...just in case... we'll be backing up Seq storage as well assuming that is needed for rollback since 2020.1 uses different "format"...
    Nicholas Blumhardt
    @nblumhardt
    @KeithBarrows "Classic" package is https://github.com/serilog-web/classic - HTH!
    @rastignacc Hi! It's possible but mildly tricky because of the format and metadata changes; stopping the service and backing up all of the Seq storage root (everything in the folder containing Seq.json and subfolders) would be the easiest way to go - restoring would then just be uninstall/reinstall of the MSI, and restore of the filesystem
    Rastislav Marko
    @rastignacc
    @nblumhardt thanks !
    Rastislav Marko
    @rastignacc

    I have one more question. I've stumbled upon the fact that limit keyword doesn't function the way I'd expect. It's apparent in dashboard charts where I'd like to limit number of items resulting from group by. It works on table charts as expected but not on line charts (time series). I took the query and tried to run it in events screen and it was clear that limit is actually including time(xx) into account. To illustrate this:

    select count(*) as count
    from stream 
    group by @Message, time(1h)
    limit 25

    would return unknown numbers of items based on the time slices.

    select count(*) as count
    from stream 
    group by @Message
    limit 25

    would return 25 distinct @Message items.
    Any plans on changing this?

    Nicholas Blumhardt
    @nblumhardt
    Hi @rastignacc - I don't think we can change this directly, but it seems like a scenario the query language could support somehow; needs a lot of thought, however
    Rastislav Marko
    @rastignacc
    @nblumhardt thanks a lot, the reason why I asked is that we have one dashboard containing 11 charts (see screenshot below). Experience is snappy when this dashboard page loads unless charts are fully loaded. When charts start to get rendered everything slows down to very unusable level. I was hoping limiting number of items per chart would make it better but it's not that easy as described above. I noticed that removing point markers and suppressing chart legends make it much better though but you lose some functionality. I can send logs if that helps.
    image.png
    I've tried 24 hours by hour as well but seems it's point markers/suppressed legends which helps here
    Nicholas Blumhardt
    @nblumhardt
    Thanks for the follow-up, @rastignacc - seems like it could be a browser-specific issue, perhaps; which browser/version are you running?
    Rastislav Marko
    @rastignacc
    Mostly Chrome (83.x.x, it's almost the latest one, tried with disabled extensions as well). I've just tried in Firefox or Edge, same issue.
    Nicholas Blumhardt
    @nblumhardt
    Hmmmm - thanks for the info - sounds more likely to be a problem in our JavaScript, then. Would it be possible to raise as a but in https://github.com/datalust/seq-tickets?
    Rastislav Marko
    @rastignacc
    @nblumhardt done! datalust/seq-tickets#1009