ITPub博客

首页 > > > Repository

Repository

作者:doudourabbit 时间:2019-09-06 16:44:28 0 删除 编辑

Repository [NETCoreRepository] is already defined. Repositories cannot be redefined.


.netcore 日志使用Log4Net的时候,封装个帮助类,偶尔会有这样的异常。
“Repository [NETCoreRepository] is already defined. Repositories cannot be redefined.”
private static ILog log
{
get
{
try
{
if (_log == null)
{

                    Configure();
                }
                return _log;
            }
            catch (Exception ex)
            {
                return null;
            }

        }
    }

    public static void Configure(string repositoryName = "NETCoreRepository", string configFile = "Config/log4net.config")
    {
        try
        {
            repository = LogManager.CreateRepository(repositoryName);
            XmlConfigurator.Configure(repository, new FileInfo(configFile));
            _log = LogManager.GetLogger(repositoryName, repositoryName);
        }
        catch (LogException ex)
        {
            //没有数据 
            _log = LogManager.GetLogger(repositoryName, repositoryName);
        }
        catch (Exception ex2)
        {
            //出现异常

        }


    }


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4809/viewspace-3133286/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-25

  • 博文量
    193
  • 访问量
    1438