且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用[assembly:]进行log4net配置

更新时间:2023-10-31 23:12:46

这样做的好处是,代码是在主代码之前和静态初始化之前进行初始化的.

The advantages of doing this are that the code is initialised in advance of your main code and in advance of the static initialisation.

这意味着,例如,您可以在静态构造函数内使用log4net日志记录.如果没有预初始化log4net的方法,在静态构造函数中,您将永远无法确定代码是否已正确初始化.

This means that you can, for example, use log4net logging within a static-constructor. Without a way to pre-initialise log4net, in the static constructor you'd never know for certain that the code has been initialised correctly.

该区域似乎没有很好的文档记录(或者很容易找到),但是我认为被调用方法的初始化是在程序集加载时执行的.

This area doesn't seem to be very well documented (or easy to find anyway) but I assume that the initialisation of called methods is performed at Assembly-load time.