Skip to content

Logging DbCommands: All parameters are '?' #8933

Closed as not planned
Closed as not planned

Description

@Wain123

I have an ILogger with the following function:

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter) {
  Console.WriteLine(formatter(state, exception));
}

DbCommands get logged and the CommandText looks correct, but all the parameter values are simply '?'. Here's a sample output from the Logger:

Executed DbCommand (78ms) [Parameters=[p0='?', p1='?' (Size = 1), p2='?', p3='?' (Size = 6), p4='?', p5='?' (Size = 1), p6='?', p7='?', p8='?' (Size = 6)], CommandType='Text', CommandTimeout='0']
INSERT INTO FRM_LAYOUT_FILTER (SEQNR, BEZEICHNUNG, CREATETIME, CREATEUSER, DEFAULT_FILTER, FORM_NAME, MODIFY_NR, MODIFYTIME, MODIFYUSER)
VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8)

Activity

  1. smitpatel commented on Jun 22, 2017

    @smitpatel
    Contributor

    By default EF doesn't put data in logs as the data may contain sensitive information. To get those parameter values, you need to chain EnableSensitiveDataLogging() after your UseSqlServer (or equivalent method)
    e.g.
    builder.UseSqlServer("connectionstring").EnableSensitiveDataLogging()

  2. smitpatel commented on Aug 23, 2017

    @smitpatel
    Contributor

    @divega For doc issue

  3. added this to the 2.1.0 milestone on Aug 24, 2017
  4. modified the milestones: , 2.1.0 on Jan 17, 2018
  5. modified the milestones: , 2.1.0 on Apr 2, 2018
  6. ajcvickers commented on Apr 10, 2018

    @ajcvickers
    Contributor

    @divega Can this be moved out of the 2.1 milestone. (We are trying to make 2.1 only include issues that we must fix for 2.1)

  7. divega commented on Apr 10, 2018

    @divega
    Contributor

    This issue was moved to dotnet/EntityFramework.Docs#673

  8. removed this from the 2.1.0 milestone on Apr 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions