none
Log custom messages in EF Core RRS feed

  • Question

  • Is there a way to log any custom messages in EF Core, as we can do it EF6

    using (var context = new BookStore())
    {
        context.Database.Log = Console.Write;
        context.Database.Log("Custom message");
    }
    


    MW

    • Moved by CoolDadTx Tuesday, May 14, 2019 2:08 PM EF related
    Tuesday, May 14, 2019 6:48 AM

All replies

  • Hi waqasm78,

    Thank you for posting here.

    For your question, you want to log custom messages in EF Core.

    Based on my research, EF Core does not have the function so far. If you want to know more about it, you could refer to the following link.

    https://docs.microsoft.com/en-us/ef/efcore-and-ef6/index​​​​​​​

    Read: Feature comparison=>other-features=>Simple Logging (Database.Log)

    Best Regards,

    Jack



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 14, 2019 8:04 AM
  • I have never used the functionality, but yes, you can do logging with EF Core.

    https://docs.microsoft.com/en-us/ef/core/miscellaneous/logging

    EF issues can be discussed at the EF forum.

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework

     
    Tuesday, May 14, 2019 8:06 AM
  • Is there a way to log any custom messages in EF Core, as we can do it EF6

    using (var context = new BookStore()) { context.Database.Log = Console.Write; context.Database.Log("Custom message"); }

    How can I log my custom messages in EF Core?




    Tuesday, May 14, 2019 9:37 AM
  • Yes, I know logging Database operations in EF Core, but I want to log some custom messages as well, like we can do in EF6.

    But in EF Core how can I log custom messages?

    MW

    Tuesday, May 14, 2019 9:43 AM
  • Yes, I know logging Database operations in EF Core, but I want to log some custom messages as well, like we can do in EF6.

    But in EF Core how can I log custom messages?

    MW

    You could look into Serilog for custom messages using a MS SQL Server sink.

    https://serilog.net/

    https://www.codeproject.com/Tips/1159173/Integrate-Serilog-Logging-Framework-with-ASP-NET-C


    Tuesday, May 14, 2019 10:20 AM