How Orchard CMS does the logging?

后端 未结 2 2000
傲寒
傲寒 2021-02-14 20:10

I\'m working with Orchard CMS and it is better CMS for me. I want to understand how it does the logging and whether I can add my own logging or not. I saw that Orchard uses

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-14 20:59

    There is a great article on how Orchard Logging works. (I am not sure if it is ok to copy and paste the entire article). This is the link: Injection Logger in Orchard

    So the trick is this:

    Whenever a class requires a Logger instance, all it needs to do is to declare a ILogger property, that’s it. And later, in your class, you can use this property to Logging at anytime

    And how is this done?

    When Orchard web application startup, the OrchardStarter will be used to do most of the registration work.

    In a few words, it looks all the code in all projects, gets all the classes that use an ILogger property, and implements it for you (if not implemented), using Castle's logger factory.

提交回复
热议问题