Beispiel #1
0
 /// <summary>
 /// Configure Logger
 /// </summary>
 private void ConfigureLogger()
 {
     DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
     IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
     LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
     Logger.SetLogWriter(logWriterFactory.Create());
 }
Beispiel #2
0
 private static LogWriter CreateLogWriter(IConfigurationSource config)
 {
     var factory = new LogWriterFactory(config);
     var writer = factory.Create();
     Logger.SetLogWriter(writer);
     return writer;
 }
        public static void WriteLog(string message, string category, string status, System.Diagnostics.TraceEventType eventType, string name, string filename, int priority)
        {
            //DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
            //DatabaseProviderFactory factory = new DatabaseProviderFactory();
            //Database db = factory.Create("Logging");
               //DatabaseFactory.SetDatabaseProviderFactory(factory, true);
            DatabaseProviderFactory factory = new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection);
            DatabaseFactory.SetDatabaseProviderFactory(factory, false);
            LogWriterFactory logWriterFactory = new LogWriterFactory();

            Logger.SetLogWriter(logWriterFactory.Create());

            LogEntry log = new LogEntry();
            log.Categories.Add(category);
            log.Message = status + " : " + message;
            log.EventId = 1;
            log.Priority = priority;

            if (!string.IsNullOrEmpty(name.Trim()))
                log.ManagedThreadName = name;

            log.TimeStamp = System.DateTime.Now;
            log.Severity = eventType;

            if (!string.IsNullOrEmpty(filename.Trim()))
                log.Title = category + " : " + filename + " : " + message;
            else
                log.Title = category + " : " + message;

            Logger.Write(log);

            Logger.Reset();
        }
Beispiel #4
0
        static void LogWithFluentInterface(CustomLogEntry logEntry)
        {
            var builder = new ConfigurationSourceBuilder();

            builder.ConfigureData()
                .ForDatabaseNamed("Logging")
                    .ThatIs.ASqlDatabase()
                    .WithConnectionString(@"data source=.\SQLEXPRESS;Integrated Security=SSPI;Database=Logging")
                .AsDefault();

            builder.ConfigureLogging()
                    .WithOptions
                        .DoNotRevertImpersonation()
                    .LogToCategoryNamed("General")
                        .WithOptions.SetAsDefaultCategory()
                        .SendTo.CustomDatabase("Custom Database Trace Listener")
                        .WithAddCategoryStoredProcedure("AddCategory")
                        .UseDatabase("Logging")
                        .Filter(System.Diagnostics.SourceLevels.All)
                        .WithWriteLogStoredProcedure("WriteLog")
                        .FormatWithSharedFormatter("Text Formatter")
                    .SpecialSources.LoggingErrorsAndWarningsCategory
                        .SendTo.EventLog("Event Log Listener")
                        .FormatWith(new FormatterBuilder()
                             .TextFormatterNamed("Text Formatter")
                               .UsingTemplate(@"Timestamp: {timestamp}{newline}
            Message: {message}{newline}
            Category: {category}{newline}
            Priority: {priority}{newline}
            EventId: {eventid}{newline}
            Severity: {severity}{newline}
            Title:{title}{newline}
            Machine: {localMachine}{newline}
            App Domain: {localAppDomain}{newline}
            ProcessId: {localProcessId}{newline}
            Process Name: {localProcessName}{newline}
            Thread Name: {threadName}{newline}
            Win32 ThreadId:{win32ThreadId}{newline}
            Extended Properties: {dictionary({key} - {value}{newline})}"))
                            .ToLog("Application")
                            .ToMachine(".")
                            .UsingEventLogSource("Enterprise Library Logging")
                            .Filter(SourceLevels.All)
                            ;

            var configSource = new DictionaryConfigurationSource();
            builder.UpdateConfigurationWithReplace(configSource);

            var dbProviderFactory = new DatabaseProviderFactory(configSource);
            DatabaseFactory.SetDatabaseProviderFactory(dbProviderFactory, false);

            var logWriterFactory = new LogWriterFactory(configSource);
            var logWriter = logWriterFactory.Create();
            logWriter.Write(logEntry);

            // Re-initialize static Logger
            Logger.SetLogWriter(logWriter, false);
            Logger.Write("Test2", "General");
        }
        static DataMapperFactory()
        {
            var configurationSource = ConfigurationSourceFactory.Create();
            var logWriterFactory = new LogWriterFactory(configurationSource);
            DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
            Logger.SetLogWriter(logWriterFactory.Create());

            FactoryType = ConfigurationManager.AppSettings["FactoryType"];
        }
 protected override ILoggerInventory CreateLoggerInventory()
 {
     return new LoggerInventory<LogWriter>(
         (name) => GetRepositoryConfigFile(name),
         (name, file) =>
         {
             var factory = new LogWriterFactory(new FileConfigurationSource(file));
             return factory.Create();
         },
         (resp, name) => new EnterpriseLibraryLogger(resp, name));
 }
 static Logger()
 {
     try
     {
         IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
         ms.LogWriterFactory  logWriterFactory    = new ms.LogWriterFactory(configurationSource);
         ms.Logger.SetLogWriter(new ms.LogWriterFactory().Create());
     }
     catch (Exception)
     {
     }
 }
        /// <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;
        }
Beispiel #9
0
        static void LogWithConfigFile(CustomLogEntry logEntry)
        {
            // Need to initialize the Database Application Block since it is used by the custom trace listener
            DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());

            var logWriterFactory = new LogWriterFactory();
            var logWriter = logWriterFactory.Create();
            logWriter.Write(logEntry);

            // Initialize static Logger
            Logger.SetLogWriter(logWriter);
            Logger.Write("Test1", "General");
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            // Previously this would could throw an exception if permission issues or an invalid network drive occurred
            var logWriter = new LogWriterFactory().Create();

            // This will throw the exception encountered during initialization above but the exception will be
            // attempted to be logged to the errors special source (in this project the Event Log under the
            // source Enterprise Library Logging) and the exception swallowed
            logWriter.Write("To be...", "Failure Category");

            // This will create a logs directory and write to rolling.log file in the logs directory
            logWriter.Write("or not to be.", "Success Category");
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            //从Data.config配置文件获取设置
            DatabaseProviderFactory dbFactory =
                new DatabaseProviderFactory(GetFileConfigurationSource("Data Configuration Source"));

            Database db = dbFactory.Create("Connection String");
            Console.WriteLine(db.ConnectionString);

            //从Log.config的配置文件获取设置
            LogWriter lw = new LogWriterFactory(GetFileConfigurationSource("Log Configuration Source")).Create();
            lw.Write("123");
        }
        /// <summary>
        /// The Log method logs the entry to event logs and rolling flat file
        /// </summary>
        /// <param name="logEntry">The logEntry parameter</param>        
        public void Log(AnetLogEntry logEntry)
        {
            LogEntry log = new LogEntry();
            log.Message = logEntry.Message;
            log.Severity = logEntry.Severity;

            IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
            LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);

            Logger.SetLogWriter(logWriterFactory.Create(), false);
            Logger.SetContextItem("correlationID", AnetConfiguration.CorrelationId);
            Logger.Write(log);
            Logger.FlushContextItems();
            Logger.Reset();
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            var logger = new LogWriterFactory().Create();

            // log for 10 minutes...config is set to keep 7 files
            for (int i = 0; i < 10; i++)
            {
                Console.Write("\nWriting log");
                logger.Write("Testing!", "General");

                for (int j = 0; j < 60; j++)
                {
                    System.Threading.Thread.Sleep(1000);
                    Console.Write(".");
                }
            }
        }
Beispiel #14
0
        static void Main()
        {
            var loggingConfig = new LoggingConfiguration();
            var customizedWriter = new LogWriter(loggingConfig);

            var logWriterFactory = new LogWriterFactory();
            var defaultWriter = logWriterFactory.Create();

            var logEntry = new LogEntry
                {
                    EventId = 100,
                    Priority = 2,
                    Message = "Informational message",
                    Categories = { "Trace", "UI Events" }
                };

            new ManagedSecurityContextInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);
            new DebugInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);
            new ComPlusInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);
            new UnmanagedSecurityContextInformationProvider().PopulateDictionary(logEntry.ExtendedProperties);

            defaultWriter.Write(logEntry);

            var traceManager = new TraceManager(defaultWriter);
            using (traceManager.StartTrace("Trace"))
            {
                defaultWriter.Write("Operation 1");
            }

            using (traceManager.StartTrace("UI Events", Guid.NewGuid()))
            {
                defaultWriter.Write("Operation 2", "Trace");
            }

            using (traceManager.StartTrace("Trace"))
            {
                using (traceManager.StartTrace("UI Events"))
                {
                    defaultWriter.Write("Operation 3");
                }
            }
        }
        public void LogException(Exception ex)
        {
            if(writer == null)
            {
                LogWriterFactory factory = new LogWriterFactory();
                writer = factory.Create();
            }

            StringBuilder builder = new StringBuilder();
            builder.AppendLine("Exception Message: " + ex.Message);
            builder.AppendLine("Exception Stack: " + ex.StackTrace);

            if(ex.InnerException != null)
            {
                builder.AppendLine("Inner Exception Message: " + ex.InnerException.Message);
                builder.AppendLine("Inner Exception Stack: " + ex.InnerException.StackTrace);
            }

            LogEntry entry = new LogEntry(builder.ToString(), "General", 1, 9001, System.Diagnostics.TraceEventType.Error, "EDS TIR Error", null);
            writer.Write(entry);
        }
Beispiel #16
0
        /// <summary>
        /// Actually log the messgae
        /// </summary>
        /// <param name="message">the message to log</param>
        /// <param name="severity">log entry severity</param>
        public static void LogMessage(String message, TraceEventType severity)
        {
            // build the log entry
            LogEntry le = new LogEntry();
            le.Message = message;
            le.ProcessName = Process.GetCurrentProcess().ProcessName;
            le.ProcessId = Process.GetCurrentProcess().Id.ToString();
            le.TimeStamp = DateTime.Now;
            le.MachineName = Environment.MachineName;
            le.Priority = Logger.LOG_PRIORITY;
            le.Title = Logger.LOG_TITLE;
            le.Severity = severity;

            // actually log the message
            if (Logger.logWriter == null)
            {
                LogWriterFactory logWriterFactory = new LogWriterFactory();
                Logger.logWriter = logWriterFactory.Create();
            }
            Logger.logWriter.Write(le);

            // write the message to the console
            Console.WriteLine(String.Format("[{0}] {1} - {2}", DateTime.Now.ToString(), severity.ToString().ToUpper(), message));
        }
Beispiel #17
0
 static EntLibLogger()
 {
     // If you are using EntLib v5, the folowing two statements must be commented.
     var logWriter = new LogWriterFactory().Create();
     Logger.SetLogWriter(logWriter);
 }
Beispiel #18
0
		static AwLogger()
		{
			var configSource = ConfigurationSourceFactory.Create();
			var logWriterFactory = new LogWriterFactory(configSource);
			Logger.SetLogWriter(logWriterFactory.Create());
		}
 /// <summary>
 /// CTOR
 /// </summary>
 public LoggingService()
 {
     LogWriterFactory logWriterFactory = new LogWriterFactory();
     this.Writer = logWriterFactory.Create();
 }
Beispiel #20
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);
        }
 private static LogWriter GetWriterFromConfiguration(IConfigurationSource configSource)
 {
     if (configSource != lastUsedConfigSource)
     {
         lock (logWriterCacheLock)
         {
             if (configSource != lastUsedConfigSource)
             {
                 lastUsedConfigSource = configSource;
                 LogWriterFactory factory = new LogWriterFactory(configSource);
                 lastUsedLogWriter = factory.Create();
             }
         }
     }
     return lastUsedLogWriter;
 }
 public static void Initialize()
 {
     IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
     LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
     Logger.SetLogWriter(logWriterFactory.Create());
 }
 public EnterpriseLibraryLogger(IConfigurationSource configurationSource)
 {
     configurationSource = configurationSource ?? ConfigurationSourceFactory.Create();
     var logWriter = new LogWriterFactory(configurationSource).Create();
     _logWriter = new EnterpriseLibraryLogWriter(logWriter);
 }
 public LoggerService()
 {
     LogWriterFactory logWriterFactory = new LogWriterFactory();
     var logWriter = logWriterFactory.Create();
     Microsoft.Practices.EnterpriseLibrary.Logging.Logger.SetLogWriter(logWriter, false);
 }
Beispiel #25
0
        static void SimpleLogWriterWriteDecalarative()
        {
          // Create the default LogWriter object from the configuration.
          // The actual concrete type is determined by the configuration settings.
          Console.WriteLine("This example reads the configuration data from the config file.");
          LogWriterFactory logWriterFactory = new LogWriterFactory();
          var logWriter = logWriterFactory.Create();

          // Check if logging is enabled before creating log entries.
          if (logWriter.IsLoggingEnabled())
          {
            // The default values if not specified in call to Write method are:
            // - Category: "General"
            // - Priority: -1
            // - Event ID: 1
            // - Severity: Information
            // - Title: [none]
            logWriter.Write("Log entry created using the simplest overload (Declarative configuration).");
            Console.WriteLine("Created a Log Entry using the simplest overload.");
            logWriter.Write("Log entry with a single category. (Declarative configuration)", "General");
            Console.WriteLine("Created a Log Entry with a single category.");
            logWriter.Write("Log entry with a category, priority, and event ID. (Declarative configuration)", "General", 6, 9001);
            Console.WriteLine("Created a Log Entry with a category, priority, and event ID.");
            logWriter.Write("Log entry with a category, priority, event ID, and severity. (Declarative configuration)", "General", 5, 9002, TraceEventType.Warning);
            Console.WriteLine("Created a Log Entry with a category, priority, event ID, and severity.");
            logWriter.Write("Log entry with a category, priority, event ID, severity, and title. (Declarative configuration)", "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 Windows Event Viewer 'Application' Log to see the results.");
          }
          else
          {
            Console.WriteLine("Logging is disabled in the configuration.");
          }
        }
 private void EnterpriseLibrary_Init(IUnityContainer unityContainer)
 {
     DependencyFactory.SetUnityContainerProviderFactory(unityContainer);
     DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
     LogWriterFactory logWriterFactory = new LogWriterFactory();
     Logger.SetLogWriter(logWriterFactory.Create());
 }
 public void Application_InitEnterpriseLibrary()
 {
     DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory());
     DependencyFactory.SetUnityContainerProviderFactory(UnityContainerProvider.GetContainer(FrontEndUnityContainerAvailable.ProxiesToAzure));
     LogWriterFactory logWriterFactory = new LogWriterFactory();
     Logger.SetLogWriter(logWriterFactory.Create());
 }
        private LogWriter GetWriter()
        {
            //per http://growingtech.blogspot.it/2013/05/enterprise-library-60-logwriter-has-not.html 
            //  we have to explicitly set the writer for EntLib6 before we can return it
            var configurationSource = ConfigurationSourceFactory.Create();
            var logWriterFactory = new LogWriterFactory(configurationSource);
            Logger.SetLogWriter(logWriterFactory.Create());

            return Logger.Writer;
        }