Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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.");
            }
        }
Esempio n. 3
0
 public AccessImporter(LogWriter logger, LO30Context context, bool seed = true)
 {
   _logger = logger;
   _context = context;
   _lo30ContextService = new LO30ContextService(context);
   _seed = seed;
 }
Esempio n. 4
0
 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;
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        public EnterpriseLibraryLogger(LoggingConfiguration config)
        {
            if (config == null)
                throw new ArgumentNullException("config");

            m_LogWriter = new LogWriter(config);
        }
Esempio n. 7
0
        /// <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();
            }
        }
        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 + ")";
        }
 /// <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);
 }
Esempio n. 10
0
        public AdvSurveysController(ISurveyService surveyService,
            IDipendentiService dipendentiService,
            LogWriter logger
            )
        {
            this.surveyService = surveyService;
            this.logger = logger;

        }
 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);
 }
        public CleanerService()
        {
            InitializeComponent();
            _logger = new LogWriter(BuildProgrammaticConfig());

            _cacheDir = ConfigurationManager.AppSettings[OfficeCacheFolderKey];
            _maxAgeMinutes = int.Parse(ConfigurationManager.AppSettings[LastAccessTimeMinutesBeforeDeleteKey]);
            _cleanIntervalMinutes = int.Parse(ConfigurationManager.AppSettings[CleanIntervalMinutes]);
        }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
        public EntLibLogger(LogWriter logWriter)
        {
            if (logWriter == null)
            {
                throw new ArgumentNullException("logWriter");
            }

            this.logWriter = logWriter;
        }
        /// <summary>
        /// Create an instance of <see cref="TraceManager"/> giving the <see cref="LogWriter"/>.
        /// </summary>
        /// <param name="logWriter">The <see cref="LogWriter"/> that is used to write trace messages.</param>
        /// <param name="instrumentationProvider">The <see cref="ITracerInstrumentationProvider"/> used to determine if instrumentation should be enabled</param>
        public TraceManager(LogWriter logWriter, ITracerInstrumentationProvider instrumentationProvider)
        {
            if (logWriter == null)
            {
                throw new ArgumentNullException("logWriter");
            }

            this.logWriter = logWriter;
            this.instrumentationProvider = instrumentationProvider;
        }
Esempio n. 16
0
 public StoresController(
     [ServiceDependency] IGeoLocationServiceAgent geocodeServiceAgent,
     [CreateNew] IUnitOfWork unitOfWork
     )
 {
     this.geocodeServiceAgent = geocodeServiceAgent;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     this.unitOfWork = unitOfWork;
 }
 /// <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;
 }
Esempio n. 18
0
 public LogImplementation(SourceLevels level)
 {
     var factory = new LoggingConfigurationSourceFactory();
     var configurationSource = factory.Create(level);
     this.entLibSettings =
         configurationSource.GetSection(EntLib.LoggingSettings.SectionName)
         as EntLib.LoggingSettings;
     this.logWriter = new LogWriterFactory(configurationSource).Create();
     this.loggingEnabled = true;
 }
Esempio n. 19
0
        public LoggingViewModel()
        {
            var logFormatter = new TextFormatter();

            var flatFileTraceListener = new FlatFileTraceListener("log.hblog", "-------------------------",
                "-------------------------", logFormatter);

            var config = new LoggingConfiguration();
            config.AddLogSource("Hummingbird", SourceLevels.All, true).AddTraceListener(flatFileTraceListener);
            Logger = new LogWriter(config);
        }
 //private readonly IGeoLocationServiceAgent geolocationService;
 /// <summary>
 /// Initializes a new instance of the LcboStoresServiceAgent class.
 /// </summary>
 public LcboStoresServiceAgent(
     [ServiceDependency]IPageRetrieverFactory pageRetrieverFactory
     //,
     //[ServiceDependency]IGeoLocationServiceAgent geolocationService
     )
 {
     this.storeDetailsPageRetriever = pageRetrieverFactory.StoreDetailsPageRetriever;
     this.storeListPageRetriever = pageRetrieverFactory.StoreListPageRetriever;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     //this.geolocationService = geolocationService;
 }
Esempio n. 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntLibLogger"/> class.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="logWriter">the <see cref="LogWriter"/> to write log events to.</param>
        /// <param name="settings">the logger settings</param>
        public EntLibLogger(string category, LogWriter logWriter, EntLibLoggerSettings settings)
        {
            this.category = category;
            this.logWriter = logWriter;
            this.settings = settings;

            VerboseLogEntry = new TraceLevelLogEntry(category, TraceEventType.Verbose);
            InformationLogEntry = new TraceLevelLogEntry(category, TraceEventType.Information);
            WarningLogEntry = new TraceLevelLogEntry(category, TraceEventType.Warning);
            ErrorLogEntry = new TraceLevelLogEntry(category, TraceEventType.Error);
            CriticalLogEntry = new TraceLevelLogEntry(category, TraceEventType.Critical);
        }
Esempio n. 22
0
 public InventoryController(
     [ServiceDependency] ILcboInventoryService lcboService,
     [ServiceDependency] ILcboStoresService lcboStoresService,
     [CreateNew] IDomainContext domainContext
     )
 {
     this.lcboService = lcboService;
     this.lcboStoresService = lcboStoresService;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     this.domainContext = domainContext;
 }
        /// <summary>
        /// Initializes the specified configuration files, we only use the first found one
        /// </summary>
        /// <param name="configFiles">All the potential configuration files, order by priority.</param>
        /// <returns></returns>
        public override bool Initialize(string[] configFiles)
        {
            if (!base.Initialize(configFiles))
                return false;

            var configurationSource = new FileConfigurationSource(this.ConfigFile);

            var factory = new LogWriterFactory(configurationSource);
            m_LogWriter = factory.Create();

            return true;
        }
Esempio n. 24
0
		private Logger()
		{
			string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
			TextFormatter formatter = new TextFormatter();
			var databaseTraceListener =
			  new FormattedDatabaseTraceListener(new SqlDatabase(connectionString)
			  , "WriteLog", "AddCategory", formatter);

			var config = new LoggingConfiguration();
			config.AddLogSource(LogCategories.General.ToString(), SourceLevels.All, true).AddTraceListener(databaseTraceListener);
			writer = new LogWriter(config);
			writer.Write("Starting...", LogCategories.General.ToString(), 9, 0, TraceEventType.Verbose, "Log Starting");
		}
Esempio n. 25
0
		static void Main(string[] args)
		{
			TextFormatter briefFormatter = new TextFormatter();

			var flatFileTraceListerner = new FlatFileTraceListener(@"C:\temp\xxx.log",
				"-------------------------------",
				"-------------------------------",
				briefFormatter);

			var config = new LoggingConfiguration();
			config.AddLogSource("my_log", System.Diagnostics.SourceLevels.All, true).AddTraceListener(flatFileTraceListerner);
			LogWriter logger = new LogWriter(config);
		}
        public NWindController()
        {
            Logger = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

            ProductDal = new ProductDal();

            CustomerDal = new CustomerDal();

            EmployeeDal = new EmployeeDal();

            SupplierDal = new SupplierDal();

            Logger.Write(new LogEntry() { Message = "ready." });
        }
Esempio n. 27
0
 public AdminController(
     [CreateNew] IUnitOfWork unitOfWork,
     [ServiceDependency] ILcboProductsService lcboProductsService,
     [ServiceDependency] ILcboStoresService lcboStoresService,
     [CreateNew] IFastDomainContext domainContext
     )
 {
     this.unitOfWork = unitOfWork;
     this.logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
     this.traceManager = new TraceManager(this.logWriter);
     this.lcboProductsService = lcboProductsService;
     this.lcboStoresService = lcboStoresService;
     this.domainContext = domainContext;
 }
        private static TestEntLibLoggerFactoryAdapter CreateTestEntLibLoggerFactoryAdapter(ILogFilter filter)
        {
            LogWriter logWriter = new LogWriter(
                new ILogFilter[] { filter }
                , new LogSource[] { new LogSource("logSource") }
                , new LogSource("defaultLogSource")
                , new LogSource("notProcessedLogSource")
                , new LogSource("errorsLogSource")
                , "DefaultCategory"
                , true
                , true
                );

            return new TestEntLibLoggerFactoryAdapter(5, EntLibLoggerSettings.DEFAULTEXCEPTIONFORMAT, logWriter);
        }
        protected override void Arrange()
        {
            this.traceListener = new MockTraceListener();
            var logWriter =
                new LogWriter(
                    new ILogFilter[0],
                    new LogSource[0],
                    new LogSource("all", new TraceListener[] { this.traceListener }, SourceLevels.All),
                    new LogSource(""),
                    new LogSource(""),
                    "default",
                    false,
                    false);

            Logger.SetLogWriter(logWriter, false);
        }
Esempio n. 30
0
        public DynamicELLogger(string logRoot, IEnumerable<string> applications)
        {
            string[] categories = new string[] { "Info", "Error", "Debug", "Perf" };

            LoggingSettings loggingSetting = LoggingSettings.GetLoggingSettings(ConfigurationSourceFactory.Create());

            Dictionary<string, TextFormatter> formatters = new Dictionary<string, TextFormatter>(categories.Count(), StringComparer.OrdinalIgnoreCase);

            foreach (string cate in categories)
            {
                var formatData = loggingSetting.Formatters.Where(f => f.Name.Equals(cate, StringComparison.OrdinalIgnoreCase)).SingleOrDefault() as TextFormatterData;

                if (formatData == null)
                    throw new Exception(string.Format("Missing logging formatter \"{0}\"", cate));

                TextFormatter formatter = new TextFormatter(formatData.Template);
                formatters[cate] = formatter;
            }

            string baseLogPath = Path.Combine(logRoot, "{0}.log");
            string logPath = Path.Combine(logRoot, "{0}\\{1}.log");

            List<LogSource> logSources = new List<LogSource>();

            foreach (var cate in categories)
            {
                logSources.Add(new LogSource(cate, new List<TraceListener>
                    {
                        new RollingFlatFileTraceListener(string.Format(baseLogPath, cate), "", "", formatters[cate], 0, "yyyyMMdd", RollFileExistsBehavior.Overwrite, RollInterval.Day)
                    }, SourceLevels.All));
            }

            foreach (var app in applications)
            {
                foreach (var cate in categories)
                {
                    logSources.Add(new LogSource(app + "." + cate, new List<TraceListener>
                        {
                            new RollingFlatFileTraceListener(string.Format(logPath, app, cate), "", "", formatters[cate], 0, "yyyyMMdd", RollFileExistsBehavior.Overwrite, RollInterval.Day)
                        }, SourceLevels.All));
                }
            }

            var nonExistantLog = new LogSource("Empty");

            m_Writer = new LogWriter(new ILogFilter[0], logSources, nonExistantLog, categories[0]);
        }
Esempio n. 31
0
        /// <summary>
        /// Creates an Enterprise Library exception handler that utilizes
        /// a rolling flat file trace listener to write to log files.
        /// </summary>
        /// <param name="Name">The name of the <see cref="EnterpriseExceptionLogging.LoggingExceptionHandler"/>.</param>
        /// <param name="FilePath">Location of log file. If this is not provided, <see cref="DEFAULT_CONFIG_FILE_PATH"/> is used to try and retrieve file path from Web.config file.</param>
        /// <param name="FileName">Name of log file. If this is not provided, "default_rolling.log" is used.</param>
        /// <param name="Interval">How often a new file should be created.</param>
        /// <param name="Save">States whether or not to store the handler in memory.</param>
        /// <returns></returns>
        private EnterpriseExceptionLogging.LoggingExceptionHandler CreateTempLogger(string Name = "", string FilePath = "", string FileName = "", LoggingInterval Interval = LoggingInterval.Day, /*bool ForceCreate = false,*/ bool Save = true)
        {
            string default_file_path = FilePath;

            if (string.IsNullOrEmpty(default_file_path))
            {
                try { default_file_path = ConfigurationManager.AppSettings[DEFAULT_CONFIG_FILE_PATH]; }
                catch (ConfigurationErrorsException) { }
            }

            if (string.IsNullOrEmpty(default_file_path))
            {
                return(default(EnterpriseExceptionLogging.LoggingExceptionHandler));
            }

            if (string.IsNullOrEmpty(Name))
            {
                Name = default_file_path + (!string.IsNullOrEmpty(FileName) ? FileName : "default_rolling.log");
            }

            string FullName = default_file_path + (!string.IsNullOrEmpty(FileName) ? FileName : "default_rolling.log");

            if (!FullName.EndsWith(".log"))
            {
                FullName += ".log";
            }

            if (_temp_enterprise_loggers.ContainsKey(Name))
            {
                return(_temp_enterprise_loggers[Name]);
            }

            EnterpriseExceptionLogging.LoggingExceptionHandler handler = default(EnterpriseExceptionLogging.LoggingExceptionHandler);
            try
            {
                //EnterpriseLogging.LogWriter writer = default(EnterpriseLogging.LogWriter);
                //using (EnterpriseLogging.LogWriterFactory factory = new EnterpriseLogging.LogWriterFactory())
                //using (writer = factory.CreateDefault())
                //{
                //    if (writer == null)
                //        return handler;

                //    if (!ForceCreate && writer.TraceSources.Count > 0)
                //    {
                //        // there already exists listeners in web config that we do
                //        // not want to overwrite, so there is no need to create a
                //        // default listener
                //        return handler;
                //    }
                //}

                // create formatter for rolling log file
                EnterpriseLogging.Formatters.TextFormatter formatter = new EnterpriseLogging.Formatters.TextFormatter(
                    template:
                    "GMT Timestamp: {timestamp(MM/dd/yyyy HH:mm:ss)}\n" +
                    "Local Timestamp: {timestamp(local:hh:mm:ss:tt)}\n" +
                    "Message: {message}\n" +
                    "Category: {category}\n" +
                    "Priority: {priority}\n" +
                    "EventId: {eventid}\n" +
                    "Severity: {severity}\n" +
                    "Title:{title}\n" +
                    "Machine: {machine}\n" +
                    "Application Domain: {appDomain}\n" +
                    "Process Id: {processId}\n" +
                    "Process Name: {processName}\n" +
                    "Win32 Thread Id: {win32ThreadId}\n" +
                    "Thread Name: {threadName}\n" +
                    "Extended Properties: {dictionary({key} - {value})}\n");

                EnterpriseLogging.TraceListeners.RollInterval interval;
                if (!Enum.TryParse(Enum.GetName(typeof(LoggingInterval), Interval), true, out interval))
                {
                    interval = EnterpriseLogging.TraceListeners.RollInterval.Day;
                }

                // create trace listener for exception handler
                EnterpriseLogging.TraceListeners.RollingFlatFileTraceListener listener =
                    new EnterpriseLogging.TraceListeners.RollingFlatFileTraceListener(
                        fileName: FullName,
                        header: "----------------------------------------",
                        footer: "----------------------------------------",
                        formatter: formatter,
                        rollSizeKB: 0,
                        timeStampPattern: "yyyy-MM-dd",
                        rollFileExistsBehavior: EnterpriseLogging.TraceListeners.RollFileExistsBehavior.Overwrite,
                        rollInterval: interval);
                listener.TraceOutputOptions = TraceOptions.None;
                listener.Name = "Default Rolling Flat File Trace Listener";

                // add trace listener to the log writer's sources
                //if (OverwriteTraceListeners)
                //    writer.TraceSources.Clear();
                //if (writer.TraceSources.ContainsKey("General"))
                //    writer.TraceSources["General"].Listeners.Add(listener);
                //else
                //    writer.TraceSources.Add(
                //        key: "General",
                //        value: new EnterpriseLogging.LogSource(
                //            name: "Default Enterprise Logger",
                //            level: SourceLevels.All,
                //            traceListeners: new List<TraceListener>(1) { listener },
                //            autoFlush: true
                //            ));

                // create the exception handler that will handle the exceptions
                //handler = new EnterpriseExceptionLogging.LoggingExceptionHandler(
                //    logCategory: "General",
                //    eventId: 100,
                //    severity: TraceEventType.Error,
                //    title: "Default Enterprise Library Exception Handler",
                //    priority: 0,
                //    formatterType: typeof(TextExceptionFormatter),
                //    writer: writer);



                //List<EnterpriseLogging.Filters.LogFilter> filters = new List<EnterpriseLogging.Filters.LogFilter>();
                //EnterpriseLogging.LogSource main_source = new EnterpriseLogging.LogSource(
                //    name: "Default Enterprise Logger",
                //    level: SourceLevels.All,
                //    traceListeners: new List<TraceListener>(1) { listener },
                //    autoFlush: true
                //    );
                //IDictionary<string, EnterpriseLogging.LogSource> trace_sources = new Dictionary<string, EnterpriseLogging.LogSource>();
                //trace_sources.Add("General", main_source);
                //EnterpriseLogging.LogWriterStructureHolder holder = new EnterpriseLogging.LogWriterStructureHolder(filters, trace_sources, main_source, main_source, main_source, "General", true, true, false);
                //EnterpriseLogging.LogWriterImpl writer = new EnterpriseLogging.LogWriterImpl(holder, new EnterpriseLogging.Instrumentation.LoggingInstrumentationProvider(false, true, "EnhancedPartnerCenter"), new EnterpriseLogging.LoggingUpdateCoordinator(new Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ConfigurationChangeEventSourceImpl()));

                //handler = new EnterpriseExceptionLogging.LoggingExceptionHandler(
                //    logCategory: "General",
                //    eventId: 100,
                //    severity: TraceEventType.Error,
                //    title: "Default Enterprise Library Exception Handler",
                //    priority: 0,
                //    formatterType: typeof(TextExceptionFormatter),
                //    writer: writer);

                //if (Save)
                //    _temp_enterprise_loggers.Add(Name, handler);


                // Try to fix this to work..
                List <EnterpriseLogging.Filters.LogFilter> filters = new List <EnterpriseLogging.Filters.LogFilter>();
                EnterpriseLogging.LogSource main_source            = new EnterpriseLogging.LogSource(
                    name: "Default Enterprise Logger",
                    level: SourceLevels.All,
                    traceListeners: new List <TraceListener>(1)
                {
                    listener
                },
                    autoFlush: true
                    );

                IDictionary <string, EnterpriseLogging.LogSource> trace_sources = new Dictionary <string, EnterpriseLogging.LogSource>();
                trace_sources.Add("General", main_source);

                EnterpriseLogging.LogWriterFactory         factory_writer = new EnterpriseLogging.LogWriterFactory();
                EnterpriseLogging.LogWriterStructureHolder holder         = new EnterpriseLogging.LogWriterStructureHolder(filters, trace_sources, main_source, main_source, main_source, "General", true, true, false);
                EnterpriseLogging.LogWriter writer = factory_writer.Create();
                // this is where chiz hit the fan
                writer.Configure(new Action <EnterpriseLogging.LoggingConfiguration>((EnterpriseLogging.LoggingConfiguration lc) =>
                {
                    lc.AddLogSource("");
                }));

                handler = new EnterpriseExceptionLogging.LoggingExceptionHandler(
                    logCategory: "General",
                    eventId: 100,
                    severity: TraceEventType.Error,
                    title: "Default Enterprise Library Exception Handler",
                    priority: 0,
                    formatterType: typeof(TextExceptionFormatter),
                    writer: writer);
            }
            catch (Exception)
            {
                handler = default(EnterpriseExceptionLogging.LoggingExceptionHandler);
            }

            return(handler);
        }
Esempio n. 32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnterpriseLibraryLoggingManagerAdapter"/> class.
 /// </summary>
 public EnterpriseLibraryLoggingManagerAdapter()
 {
     _loggingManager = EnterpriseLibraryContainer.Current.GetInstance <EntLog.LogWriter>();
     LoggingEnabled  = _loggingManager.IsLoggingEnabled();
 }