Log4Net on .Net Standard has no version for getting logger without repository

旧时模样 提交于 2019-12-01 23:34:37

The implementation of GetLogger is simple:

public static ILog GetLogger(string name)
{
    return GetLogger(Assembly.GetCallingAssembly(), name);
}

Assuming you want to use your class library's assembly, you can write your own helper method for that easily:

private static ILog GetLogger(string name) =>
    LogManager.GetLogger(typeof(SomeTypeInYourLibrary).Assembly, name);

It's basically hard-coding the assembly to be "the assembly containing the type you've specified" which is what you'd always get from calling GetLogger(string) from your library anyway.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!