【问题标题】:What is the equivalent LogWriterImpl in Enterprise Library 6.0Enterprise Library 6.0 中等效的 LogWriterImpl 是什么
【发布时间】:2014-11-02 09:32:06
【问题描述】:

我正在尝试将我们使用 Enterprise Library 5.0 开发的一些代码迁移到 6.0。以下代码给出了错误:找不到类型或命名空间名称“LogWriterImpl”(您是否缺少 using 指令或程序集引用?)。显然这个类已被弃用。我想知道对以下代码 sn-p 的等效调用是什么。

    public static void Configure(string logLevel, string logFile, int logFileSize, bool addFileTraceListener, bool addConsoleTraceListener, bool addEventLogTraceListener)
    {
        lock (_lockObj)
        {
            _logFilePath = logFile;
            _logLevel = logLevel;
            _contextTrace = "";
            _logSizeKB = logFileSize; //2MB default log file size

            LogSource logSource = new LogSource("Empty");
            IDictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();

            _formatter = (_logLevel == "DEBUG" || _logLevel == "ERROR") ?
            new CustomTextFormatter("\n{timestamp(local)}\t {category}\n{message}\n") :
            new CustomTextFormatter("{timestamp(local)} {shortcat} {message}");

            IEnumerable<TraceListener> listeners = GetListeners(_logLevel, addFileTraceListener,
                addConsoleTraceListener, addEventLogTraceListener);

            logSource = new LogSource("MainLogSource", listeners, SourceLevels.All);
            traceSources.Add("ERROR", logSource);
            traceSources.Add("CRITICAL", logSource);
            traceSources.Add("WARNING", logSource);
            traceSources.Add("DEBUG", logSource);
            traceSources.Add("INFO", logSource);
            traceSources.Add("ACTIVITY", logSource);


            //create the log writer 
            _writer = new LogWriterImpl(new ILogFilter[0], traceSources, new LogSource("Empty"), new LogSource("Empty"), logSource, "Error", false, true);

            isConfigured = true;
        }
    }

【问题讨论】:

    标签: .net logging enterprise


    【解决方案1】:

    我自己想出来的。简单如下:

    _writer = new LogWriter(new ILogFilter[0], traceSources, new LogSource("Empty"), new LogSource("Empty"), logSource, "Error", false, true);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-23
      • 2010-09-12
      • 2013-06-23
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 2015-10-20
      • 2015-10-17
      相关资源
      最近更新 更多