Community
    • Login

    Need help defining UDL for log files

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 357 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • aswinfrancis91A
      aswinfrancis91
      last edited by

      My log file format is as seen below. First one is general and the second for error. I have separate log files for each log levels.

      "{Level} | {Timestamp:HHmmss-fffff} | {ThreadId} | {TransactionId} | {RequestPath}| {Message:lj}|{NewLine}";
      
      "{Level} | {Timestamp:HHmmss-fffff} | {ThreadId} | {TransactionId} | {RequestPath}| {Message:lj}| {Properties:j} |{NewLine}";
      

      I am trying to get each of them represented by different colours but that is becoming a challenege especially in error log files where properties have exception properties and stack trace which has CRLF in them comparde to info or debug logs where CRLF is only at end of a log line.

      Error | 014413-78963 | 6 | ["80001f82-0000-f100-b63f-84710c7967bb"] | /HomePage/SomeController/Login| { ErrorMessage = The system cannot find the file specified., Source = System.Security.Cryptography.Algorithms, StackTrce =    at System.Security.Cryptography.CngKeyLite.SomethingSomething(String blobType, ReadOnlySpan`1 keyBlob, Boolean encrypted, ReadOnlySpan`1)
         at System.Security.Cryptography.CngPkcs8.ImportPkcs8(ReadOnlySpan`1 keyBlob)
         at System.Security.Cryptography.CngPkcs8.ImportPkcs8PrivateKey(ReadOnlySpan`1 source, Int32& bytesRead)
      blah blah
      --- End of stack trace from previous location ---
      Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)","TargetSite":"Microsoft.Win32.SafeHandles.SafeNCryptKeyHandle ImportKeyBlob(System.String, System.ReadOnlySpan`1[System.Byte], Boolean, System.ReadOnlySpan`1[System.Char])","Type":"Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException"}} |
      

      Once I get each delimited fields color coded, I would like to have json language style applied to properties section too

      Thanks!

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @aswinfrancis91
        last edited by PeterJones

        @aswinfrancis91 ,

        UDL is primarily for keyword-based languages. Logfiles are much more “positional”-based (or, at least, pattern-based).

        The plugin CSVLint adds a lexer plugin (so it behaves more like a builtin lexer than a UDL). I think it might be able to specify alternate characters instead of comma , for the separator (but I don’t have the plugin installed right now, so cannot check for you).

        Alternately, there’s the AnalysePlugin, which allows you to set up multiple regex to highlight various patterns; it’s primary use is to apply multiple highlights to log files, so it’s probably pretty close to what you want.

        I would like to have json language style applied to properties section too

        Yeah, UDL cannot inherit from a builtin lexer, so wouldn’t be able to do that. And the CSVLint probably couldn’t even approximate that. OTOH, the AnalysePlugin, with its regex, would probably be able to get something reasonable.

        1 Reply Last reply Reply Quote 1
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors