當前位置: 首頁>>代碼示例>>C#>>正文


C# Logging.LogWriter類代碼示例

本文整理匯總了C#中Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter的典型用法代碼示例。如果您正苦於以下問題:C# LogWriter類的具體用法?C# LogWriter怎麽用?C# LogWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LogWriter類屬於Microsoft.Practices.EnterpriseLibrary.Logging命名空間,在下文中一共展示了LogWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AccessImporter

 public AccessImporter(LogWriter logger, LO30Context context, bool seed = true)
 {
   _logger = logger;
   _context = context;
   _lo30ContextService = new LO30ContextService(context);
   _seed = seed;
 }
開發者ID:dkhunt27,項目名稱:LO30.v3,代碼行數:7,代碼來源:AccessImporter.cs

示例2: LogService

        static LogService()
        {
            var formatter = new TextFormatter
                ("Timestamp: {timestamp}{newline}" +
                 "Message: {message}{newline}" +
                 "Category: {category}{newline}");

            //Create the Trace listeners
            var logFileListener = new FlatFileTraceListener(@"C:\temp\temp.log", "",
                                                            "", formatter);

            //Add the trace listeners to the source
            var mainLogSource =
                new LogSource("MainLogSource", SourceLevels.All);
            mainLogSource.Listeners.Add(logFileListener);

            var nonExistantLogSource = new LogSource("Empty");

            IDictionary<string, LogSource> traceSources =
                new Dictionary<string, LogSource>
                    {{"Info", mainLogSource}, {"Warning", mainLogSource}, {"Error", mainLogSource}};

            Writer = new LogWriterImpl(new ILogFilter[0],
                                       traceSources,
                                       nonExistantLogSource,
                                       nonExistantLogSource,
                                       mainLogSource,
                                       "Info",
                                       false,
                                       true);
        }
開發者ID:Raconeisteron,項目名稱:bakopanos,代碼行數:31,代碼來源:LogService.cs

示例3: MyLoggingExceptionHandler

 internal MyLoggingExceptionHandler(string logCategory, int eventId, TraceEventType severity, string title, int priority, 
     Type formatterType, LogWriter writer, DocumentModel doc)
     : base(logCategory, eventId, severity, title, priority, formatterType, writer)
 {
     this.m_Writer = writer;
     this.doc = doc;
 }
開發者ID:NMO13,項目名稱:SolidTurn,代碼行數:7,代碼來源:ExceptionSupport.cs

示例4: EnterpriseLibraryLogger

        public EnterpriseLibraryLogger(LoggingConfiguration config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            m_LogWriter = new LogWriter(config);
        }
開發者ID:Hirede,項目名稱:Logging,代碼行數:7,代碼來源:EnterpriseLibraryLogger.cs

示例5: ShellViewModel

        public ShellViewModel(
            IRegionManager regionManager, 
            IEventAggregator eventAggregator, 
            INavigationService navigationService, 
            IApplicationCommands applicationCommands, 
            LogWriter logWriter)
        {
            this.regionManager = regionManager;
            this.eventAggregator = eventAggregator;
            this.navigationService = navigationService;
            this.applicationCommands = applicationCommands;
            this.logWriter = logWriter;
            this.EntitySelectorViews = new List<KeyValuePair<string, Type>>();
            this.ExitCommand = new DelegateCommand<object>(this.AppExit, this.CanAppExit);
            this.eventAggregator.Subscribe<BusyEvent>(this.SetBusy);
            this.eventAggregator.Subscribe<DialogOpenEvent>(this.DialogOpened);
            this.eventAggregator.Subscribe<StatusEvent>(this.UpdateStatus);
            this.eventAggregator.Subscribe<ErrorEvent>(this.ShowError);
            this.eventAggregator.Subscribe<CanSaveEvent>(this.UpdateCanSave);
            this.eventAggregator.Subscribe<EntitySelectEvent>(this.ShowSelectEntity);
            this.eventAggregator.Subscribe<EntitySelectedEvent>(this.HideSelectEntity);
            this.eventAggregator.Subscribe<MappingUpdateEvent>(this.ShowUpdateMapping);
            this.eventAggregator.Subscribe<MappingUpdatedEvent>(this.HideUpdateMapping);
            this.eventAggregator.Subscribe<CanCreateNewChangeEvent>(this.CanCreateNewChange);
            this.eventAggregator.Subscribe<CanCloneChangeEvent>(this.CanCloneChange);
            this.eventAggregator.Subscribe<ConfirmMappingDeleteEvent>(this.ConfirmMappingDelete);
            this.eventAggregator.Subscribe<MappingDeleteConfirmedEvent>(this.MappingDeleteConfirmed);
            this.NewEntityMenuItems = new ObservableCollection<MenuItemViewModel>();

            this.serverList = new ObservableCollection<string>();
            this.SetServerList();

            this.HelpToolTip = "Help Documentation (" + Assembly.GetExecutingAssembly().GetName().Version + ")";
        }
開發者ID:RaoulHolzer,項目名稱:EnergyTrading-MDM-Sample,代碼行數:34,代碼來源:ShellViewModel.cs

示例6: Main

        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            try
            {
                logWriter = ConfigureEntLibLogging.ConfigureLogWriter();

                if (logWriter.IsLoggingEnabled())
                {
                    using (logWriter)
                    {
                        logWriter.Write("Enterprise Library Logging test app has been started!");
                    }
                }

                //EntLibLogTest logTest = new EntLibLogTest();
                //logTest.PrintLogEvent();
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                return;
            }
            finally
            {
                logWriter.Dispose();
            }
        }
開發者ID:paulmac2015,項目名稱:loggingframeworks,代碼行數:31,代碼來源:Program.cs

示例7: SimpleLogWriterWrite

        static void SimpleLogWriterWrite()
        {
          // Build the configuration programtically.
          LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
          defaultWriter = new LogWriter(loggingConfiguration);


          // Check if logging is enabled before creating log entries.
            if (defaultWriter.IsLoggingEnabled())
            {
                // The default values if not specified in call to Write method are:
                // - Category: "General"
                // - Priority: -1
                // - Event ID: 1
                // - Severity: Information
                // - Title: [none]
                defaultWriter.Write("Log entry created using the simplest overload.");
                Console.WriteLine("Created a Log Entry using the simplest overload.");
                defaultWriter.Write("Log entry with a single category.", "General");
                Console.WriteLine("Created a Log Entry with a single category.");
                defaultWriter.Write("Log entry with a category, priority, and event ID.", "General", 6, 9001);
                Console.WriteLine("Created a Log Entry with a category, priority, and event ID.");
                defaultWriter.Write("Log entry with a category, priority, event ID, and severity.", "General", 5, 9002, TraceEventType.Warning);
                Console.WriteLine("Created a Log Entry with a category, priority, event ID, and severity.");
                defaultWriter.Write("Log entry with a category, priority, event ID, severity, and title.", "General", 8, 9003, TraceEventType.Warning, "Logging Block Examples");
                Console.WriteLine("Created a Log Entry with a category, priority, event ID, severity, and title.");
                Console.WriteLine();
                Console.WriteLine(@"Open 'C:\Temp\ConfigSampleFlatFile.log' to see the results.");
            }
            else
            {
                Console.WriteLine("Logging is disabled in the configuration.");
            }
        }
開發者ID:HondaBey,項目名稱:EnterpriseLibrary6,代碼行數:34,代碼來源:Program.cs

示例8: Logger

        private Logger()
        {
            TraceManager traceMgr;

            DatabaseProviderFactory factory = new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection);
            DatabaseFactory.SetDatabaseProviderFactory(factory, false);

            LoggingConfiguration loggingConfiguration = BuildProgrammaticConfig();
            defaultWriter = new LogWriter(loggingConfiguration);

            // Create a TraceManager object for use in activity tracing example.
            traceMgr = new TraceManager(defaultWriter);
            try
            {
                if (!Directory.Exists(@"C:\Temp"))
                {
                    Directory.CreateDirectory(@"C:\Temp");
                }
            }
            catch
            {
                //Console.WriteLine(@"WARNING: Folder C:\Temp cannot be created for disk log files");
                //Console.WriteLine();
            }
        }
開發者ID:KeyHu,項目名稱:SanscsHomework,代碼行數:25,代碼來源:Logger.cs

示例9: LcboInventoryServiceAgent

 /// <summary>
 /// Initializes a new instance of the <see cref="LcboInventoryServiceAgent"/> class.
 /// </summary>
 /// <param name="pageRetrieverFactory">The page retriever factory.</param>
 public LcboInventoryServiceAgent(
     [ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
     )
 {
     this.pageRetriever = pageRetrieverFactory.InventoryPageRetriever;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
 }
開發者ID:claq2,項目名稱:lcbodrinkfinder,代碼行數:12,代碼來源:LcboInventoryServiceAgent.cs

示例10: MagicLogger

 public MagicLogger()
 {
     var config = new LoggingConfiguration();
     var txtFormatter = new TxtFormatter(new NameValueCollection());
     config.AddLogSource("Error", SourceLevels.Error, true).AddTraceListener(new FlatFileListener("error.txt", formatter: txtFormatter));
     config.AddLogSource("Information", SourceLevels.Information, true).AddTraceListener(new FlatFileListener("information.txt", formatter: txtFormatter));
     var loggerWriter = new LogWriter(config);
     Logger.SetLogWriter(loggerWriter, false);
 }
開發者ID:Enyu,項目名稱:MSEnterpriseLogging,代碼行數:9,代碼來源:MagicLogger.cs

示例11: CleanerService

        public CleanerService()
        {
            InitializeComponent();
            _logger = new LogWriter(BuildProgrammaticConfig());

            _cacheDir = ConfigurationManager.AppSettings[OfficeCacheFolderKey];
            _maxAgeMinutes = int.Parse(ConfigurationManager.AppSettings[LastAccessTimeMinutesBeforeDeleteKey]);
            _cleanIntervalMinutes = int.Parse(ConfigurationManager.AppSettings[CleanIntervalMinutes]);
        }
開發者ID:webhacking,項目名稱:OfficeCacheCleaner,代碼行數:9,代碼來源:CleanerService.cs

示例12: LcboProductServiceAgent

 public LcboProductServiceAgent(
     [ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
     )
 {
     this.productDetailsPageRetriever = pageRetrieverFactory.ProductDetailsPageRetriever;
     this.productListPageRetriever = pageRetrieverFactory.ProductListPageRetriever;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
 }
開發者ID:claq2,項目名稱:lcbodrinkfinder,代碼行數:9,代碼來源:LcboProductServiceAgent.cs

示例13: EntLibLogger

        public EntLibLogger(LogWriter logWriter)
        {
            if (logWriter == null)
            {
                throw new ArgumentNullException("logWriter");
            }

            this.logWriter = logWriter;
        }
開發者ID:RustyF,項目名稱:EnergyTrading-Core,代碼行數:9,代碼來源:EntLibLogger.cs

示例14: AdvSurveysController

        public AdvSurveysController(ISurveyService surveyService,
            IDipendentiService dipendentiService,
            LogWriter logger
            )
        {
            this.surveyService = surveyService;
            this.logger = logger;

        }
開發者ID:salem84,項目名稱:GeCo.Survey,代碼行數:9,代碼來源:AdvSurveysController.cs

示例15: PersonalLocationsController

 /// <summary>
 /// Initializes a new instance of the <see cref="PersonalLocationsController"/> class.
 /// </summary>
 public PersonalLocationsController(
     [CreateNew] IDomainContext domainContext,
     [ServiceDependency] IGeoLocationServiceAgent geoLocationService
     )
 {
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     this.geoLocationService = geoLocationService;
     this.domainContext = domainContext;
 }
開發者ID:claq2,項目名稱:lcbodrinkfinder,代碼行數:13,代碼來源:PersonalLocationsController.cs


注:本文中的Microsoft.Practices.EnterpriseLibrary.Logging.LogWriter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。