微軟分布式緩衝 AppFabric(Velocity)-開發篇(三)緩衝日誌

來源:互聯網
上載者:User

Velocity提供了很詳細的日誌。緩衝在群集中的生命週期和訪問記錄等都可以記錄下來。

以下在代碼中示範啟用日誌

using System;using System.Collections.Generic;using System.Linq;using System.Text;//添?加ó命ü名?空?間?using Microsoft.Data.Caching;using System.Diagnostics;namespace VolocityDemo{    class Log    {        DataCacheFactory factory;        public Log()        {            factory = new DataCacheFactory();        }        ~Log()        {            //factory.Dispose();        }        public void Test()        {            //create a list for the desired log sinks            List<DataCacheLogSink> sinklist = new List<DataCacheLogSink>(2);            //create file-based log sink, capture warnings and errors            DataCacheLogSink fileBasedSink = new DataCacheLogSink(DataCacheSinkType.FILE,                TraceLevel.Verbose, "DCache/yyyy-MM-dd");            //create console-based log sink, capture warnings and errors            DataCacheLogSink consoleBasedSink = new DataCacheLogSink(DataCacheSinkType.CONSOLE,                TraceLevel.Verbose);            //add the log sinks to the sink list            sinklist.Add(fileBasedSink);            sinklist.Add(consoleBasedSink);            //enable the sinks            DataCacheFactory.CreateLogSinks(sinklist);        }    }}

開啟日誌後,在命令控制台上可以看到詳細的日誌(樣本中將TraceLevel屬性設為:Verbose,記錄了所有日誌)。

同時在應用程式的目錄下可以看到記錄的文本日誌。本救命中的名稱為:DCache2011-08-19.log

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.