Giter VIP home page Giter VIP logo

giraffe.serilogextensions's People

Contributors

akoslukacs avatar amine-mejaouel avatar l3m avatar ratsclub avatar zaid-ajaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

giraffe.serilogextensions's Issues

Fable.Remoting.Json broken in Giraffe v5

Description

Hey Zaid,
I am getting following error at runtime after configuring Giraffe.SerilogExtensions into Giraffe application.
Giraffe version in application is: 5.0.0-rc-6

Error details:
FileNotFoundException: Could not load file or assembly 'TaskBuilder.fs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
<StartupCode$Giraffe-SerilogExtensions>.$[email protected](FSharpFunc<HttpContext, Task<FSharpOption>> next, HttpContext context)

This is similar to "Zaid-Ajaj/Fable.Remoting#201".
And as mentioned in that issue because Giraffe switched away from TaskBuilder.fs to Ply, that might be cause of issue as Fable.Remoting.Json might still dependent on TaskBuilder.fs.

By default authorization headers are logged

Description

Not sure if intentional or not, but I did notice once I started using your library that authorization headers (all headers really) end up on the console. This is fine while local, but when shipping to a log storage it can become problematic.

Is it left in intentionally?

Is Ply a dependency of Giraffe.SerilogExtensions?

Description

I added Giraffe.SerilogExtensions and followed the read me to enable it in my SAFE app. Then I get an error message when I try to call a api exposed by Fable.Remoting

Error messages, screenshots

"Could not load file or assembly 'Ply, Version=0.3.1.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified."

Expected behavior

Installing Giraffe.SerilogExtensions should also install all required dependencies

Other information

  • Operating System:
    • windows 10
  • Platform
    • dotnet core

Aditional formatter

Description

I would like to add a formatter but I'm not sure if it would interfere with the current logger.

Also if I would like to add a new property to the current SerilogAdapter.Enable how could it be done?

ReponseLogEnricher throws error when adding ContentLength into log event

Description

I found it when I was playing with the sample. It's funny that issue would not show up when we just do "dotnet run".
But if we attach a debugger on it, and hit any endpoint of the api, the debugger will capture an exception which indicates there is something odd with type casting kind of thing.

I then located the source, the exception was raised when it try to add ContentLength into log event.

Error messages, screenshots

2019-01-25T06:40:58.0709064Z Exception System.Exception: Could not convert '13L' into a log event property value
at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThenFail@1645.Invoke(String message)
at Giraffe.SerilogExtensions.Enrichers.eventProperty(String name, Object value) in C:\projects\giraffe-serilog\src\Giraffe.SerilogExtensions\Enrichers.fs:line 18
at Giraffe.SerilogExtensions.ResponseLogEnricher.Serilog-Core-ILogEventEnricher-Enrich(LogEvent logEvent, ILogEventPropertyFactory _arg1) in C:\projects\giraffe-serilog\src\Giraffe.SerilogExtensions\ResponseLogEnricher.fs:line 13
at Serilog.Core.Logger.Dispatch(LogEvent logEvent) in C:\projects\serilog\src\Serilog\Core\Logger.cs:line 408 caught while enriching Serilog.Events.LogEvent with Giraffe.SerilogExtensions.ResponseLogEnricher.

Known workarounds

Manually add "Response.ContentLength" to IgnoredRequestFields,,,

Using with saturn

Description

Trying to get it working with Saturn, but I think it's conflicting with Saturn's requestId plug

Error messages, screenshots

Add this package to a Saturn app, and all requests fail. For example:

[17:15:01 INF] GET Request at /
[17:15:01 ERR] Error at / took 74 ms
System.ArgumentException: An item with the same key has already been added. Key: RequestId
   at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at <StartupCode$Giraffe-SerilogExtensions>[email protected](Unit unitVar) in C:\projects\giraffe-serilog\src\Giraffe.SerilogExtensions\SerilogAdapter.fs:line 41
   at FSharp.Control.Tasks.TaskBuilder.tryWith[a](FSharpFunc`2 step, FSharpFunc`2 catch) in C:\Users\humbo\source\repos\TaskBuilder.fs\TaskBuilder.fs:line 165

Failing test, failing github repo, or reproduction steps

Repo here
Commit 0 is dotnet new saturn
Commit b000m adds this package to the app, and request now fail. Or might be wrong with setup at line 15 and 21 Or just the naming is soo different...
In commit working just commented out the requestId plug from Saturn.

The suspect line in this repo, and the line in Saturn

Expected Behavior

Not blowing up :)

Known workarounds

Remove Saturn's requestId plug

Other information

  • Operating System:

    • windows [10]
  • Platform

    • dotnet core - 2.1.300
    • dotnet full - 4.7.2 (yep, it's working otherwise)

Remove Ply dependency

Description

Newer version of Giraffe doesn't use Ply but Giraffe.SerilogExtensions still depend on it. Without installing ply we get a runtime error so better remove Ply dependency and/or upgrade Girafe.SerilogExtensions to target newer version of Giraffe.

  • Platform
    • dotnet core
    • [ x] dotnet full
    • mono
  • Branch or release version:
    2.0.0

How can I made the log write into file,like in c#

            var _logTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] =>[{SourceContext}]=> {Message:lj}{NewLine}{Exception}";
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Debug()
                .MinimumLevel.Override("Microsoft", Serilog.Events.LogEventLevel.Information)
                .Enrich.FromLogContext()
                .WriteTo.File("logs/log-.txt", rollingInterval:RollingInterval.Day,
                 outputTemplate: _logTemplate)
                .WriteTo.Console(outputTemplate: _logTemplate)
                .CreateLogger();

Add body from Post requests

Is there a way of adding this in as an additional property on the request/response events? Ideally without creating an additional log event.

RequestLogEnricher.FullPath issues

Description

Found two issues with FullPath:

Query string and path are in reverse order:

I get Request FullPath: ?foo=bar/index. The JSON log contains "FullPath":"?foo=bar/index" as well

FullPath is empty if there is no query string:

I get Request FullPath: . The JSON log contains "Path":"/index","FullPath":"".

Expected Behavior

I would expect it to contain path even if there is no query string present :)

I think it's easy to fix, if I that is the intended behaviour...

Other information

  • Operating System:
    Windows 10
  • Platform
    dotnet core 2.2.401

FSharp integration

Description

This might not be the right place to ask this but:

Is there a more "native" Serilog interface for F#?

Error messages, screenshots

For example:

  1. Log.Error(err, template) could be Log.Error template Error
  2. Log.ForContext(Class) does not accept F# funcs, only type = class (when types are classes)

Expected Behavior

Log.ForContext should accept F# functions

Known workarounds

  1. Just use the normal F# Interface and its fine.
  2. Add Source Context manually: Log.ForContext("SourceContext", "path+name func")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.