Tracing & logging, show column insert values

5 posts, 0 answers
  1. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 12 Jul 2014 Link to this post

    Hi,

    I have seen it before, but can't find it anywhere now. I've used this article:
    http://docs.telerik.com/data-access/developers-guide/tracing-and-logging/data-access-tasks-tracing-and-logging-create-custom-trace-listener

    But the SQL statements are shown with ? for the values. It should be possible to see the values, but how? Been looking for it this morning and yesterday...

    Could you point me to the right direction?

    Erik

    Example:
    I now get:
    insert [App.Com].[ItemGroups] ([AutoNrFomat], [AutoNrNext], [Code], [Description], [IconId], [InternalTag], [ItemGroupDefinitionId], [ItemGroupStateId], [Name], [Number], [ParentItemGroupId], [SysAccountId], [SysAdminId], [SysDeleted], [SysTemplateId], [SysUniqueId]) 
    output inserted.[ItemGroupId] into @generated_ids 
     VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 


  2. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 16 Jul 2014 Link to this post

    Hello Erik,

    If you want only to trace the SQL Statements generated by the context, I would recommend you to use another approach - to initialize the OpenAccessContext.Log property, instead of creating a CustomTraceListener. The Log property is of type TextWriter so you can initialize it with Console.Out with direct output to the console or with a StringWriter. Then the only additional step you should do is to set the Log Level to Verbose or All, then you would be able to see all of the parameters values.

    I hope that helps.

    Regards,
    Boris Georgiev
    Telerik
     
    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
     
  3. DevCraft banner
  4. Jose
    Jose avatar
    4 posts
    Member since:
    Dec 2011

    Posted 10 Aug 2015 in reply to Boris Georgiev Link to this post

    Hi Boris, 

    I have the same problem, no real values on variables, just host variables.

    I have tried verbose ans all, with no change.

    DataAcces version 2014.3.1209.1 

    The code

    Telerik.OpenAccess.BackendConfiguration telback =
                      new Telerik.OpenAccess.BackendConfiguration();
                    telback.Logging.LogEvents = Telerik.OpenAccess.LoggingLevel.All;
                    // em is my dbcontext
                    em.Log = new StringWriter();
                    StringWriter outsql = new StringWriter();
                    em.Log = outsql;

         after save I have outsql as "... WHERE "id" = :p1 ..."

    Thanks

    Paulo

  5. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 13 Aug 2015 Link to this post

    Hello Erik,

    There are some things which I cannot understand: 
    1) What type of model/mapping you are using? Fluent or Domain Model?
    2) When you create BackendConfiguration object what you are doing with it? Do you change the context BackendConfiguration with the new one and how you change it?

    The easiest way to change the log level, if you are using Fluent Model is to only add this line:
    backend.Logging.LogEvents = LoggingLevel.All;
    in FluentModel class, in method: public static BackendConfiguration GetBackendConfiguration()
     
    If you are using Domain Model you could follow the steps described in this documentation article.

    Also in this article you can find information how to change the Logging Configuration for any scenario.

    I hope that helps. If you are trying to achieve something else, do not hesitate to contact us again.

    Regards,
    Boris Georgiev
    Telerik
     
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  6. Jose
    Jose avatar
    4 posts
    Member since:
    Dec 2011

    Posted 25 Aug 2015 in reply to Boris Georgiev Link to this post

    Ok. Model. Fixed and running.

    Thanks

Back to Top
DevCraft banner