Why does log4net 1.2.10 require System.Web?

后端 未结 2 1801
别跟我提以往
别跟我提以往 2020-12-19 06:32

I\'m writing this code in a Console Application targeting the .NET Framework 4 Client Profile.

this.container.AddFacility(
  f => f         


        
相关标签:
2条回答
  • 2020-12-19 07:14

    Some of the appenders depend on System.Web such as the AspNetTraceAppender. The only other option available to the developers would have been to split out components that don't depend on the System core into separate assemblies but that would have broken the beauty of log4net in that it is so simple to use. Additionally at the time of writing log4net I don't believe their was such a thing as a Client Profile.

    Since log4net is open source there is nothing stopping you from downloading the source and removing the offending classes and creating your own Client Profile centric log4net assembly.

    http://www.thecodeking.co.uk/2010/08/making-log4net-work-with-net-client.html

    1. Download the log4net source
    2. Open & upgrade the solution using Visual Studio 2010
    3. Remove the System.Web project reference
    4. Exclude Appender\AspNetTraceAppender.cs class from the project
    5. Add a reference to System.Configuration
    6. Navigate to Project -> log4net properties, and select the application tab
    7. Change the target framework to .NET Framework 3.5 Client Profile
    8. Select the Build tab, and change the configuration to Debug
    9. Under Conditional compilation symbols change this to NET;NET_1_0;NET_2_0;
    10. Change the configuration to Release
    11. Under Conditional compilation symbols change this to STRONG;NET;NET_1_0;NET_2_0;
    12. Edit the AssemblyInfo.cs class and update the AssemblyKeyFile attribute with a valid strong key
    13. Compile the project in Release mode and distribute the new assembly
    0 讨论(0)
  • 2020-12-19 07:29

    Here are my thoughts: Log4Net uses System.Web because the developers decided this was the best option.

    If you don't want this weight, consider a logging project that does not require System.Web. There are other options.

    0 讨论(0)
提交回复
热议问题