Using log4net in a dll which is called via CLR function

  • Hello

    I am refactoring older code which is part of an SQL Server CLR Function call. The code has a horrible local logger implemented, I would like to use a standard logger such as log4net.

    What are the pros and cons of such an approach? Is it feasible? Has anyone done something similar before?

    Best regards, Martin

  • Not quite sure what you're doing here. Perhaps you can explain a bit more about the problems you're having and what you want to achieve. Haven't used log4net, but I have used general logging frameworks. Adding these to SQL Server, especially in a synchronous fashion, can be problematic because you introduce overhead and delays in transactions.

  • Hi Steve

    I am working on a CLR function which itself calls a webservice.

    This is legacy code which I need to extend and clean. The code is using proprietary logging, I would like to introduce a 3rd party logging dll which does the job way better. Transactions or synchronicity is not a concern.

    I am wondering: can I use 3rd party dlls in CLR functions without issues or are there any pitfalls / don'ts?

    Regards, Martin

  • In asking a few people, they say that using 3rd parties doesn't involve any more issues than you might have with your own code. If you are 2017+, you might need whitelisting. CLR security changed with 2017.

  • You also might read through this series: https://www.sqlservercentral.com/stairways/stairway-to-sqlclr

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply