예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntLib5Logger"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        public EntLib5Logger(Type type)
        {
            var factory = new EntLib5Factory();

            logWriter = factory.CreateDefault();
            logWriter.SetContextItem("type", type.Name);
        }
        public void EntLib5FactoryTestWithFluentConfig()
        {
            // construct the Configuration Source to use
            var builder = new ConfigurationSourceBuilder();

            // fluent API configuration
            builder.ConfigureLogging()
                .WithOptions
                    .DoNotRevertImpersonation()
                .LogToCategoryNamed("Simple")
                    .SendTo.FlatFile("Simple Log File")
                     .FormatWith(new FormatterBuilder()
                        .TextFormatterNamed("simpleFormat")
                            .UsingTemplate("{timestamp} : {message}{newline}"))
                     .ToFile("simple.log");

            var configSource = new DictionaryConfigurationSource();
            builder.UpdateConfigurationWithReplace(configSource);
            EnterpriseLibraryContainer.Current
                = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

            // initialize the EntLib5 Logger factory with configuration file
            EntLib5Factory factory = new EntLib5Factory();

            ILog log = factory.GetLogger(GetType());
            Assert.IsNotNull(log);
            Assert.IsNotNull(log as EntLib5Logger);
        }
 public void EntLib5FactoryTest()
 {
     // initialize the EntLib5 Logger Factory - will use App.Config for settings
     EntLib5Factory factory = new EntLib5Factory();
     ILog log = factory.GetLogger(GetType());
     Assert.IsNotNull(log);
     Assert.IsNotNull(log as EntLib5Logger);
 }
        public void EntLib5FactoryTestWithExistingConfigFile()
        {
            // set up a Configuration file and ensure it exists
            const string configFile = "EntLib5.Test.config";
            Assert.IsTrue(File.Exists(configFile), "Test setup failure. Required Enterprise Library config file is missing.");

            // initialize the EntLib5 Logger factory with configuration file
            EntLib5Factory factory = new EntLib5Factory(configFile);

            ILog log = factory.GetLogger(GetType());
            Assert.IsNotNull(log);
            Assert.IsNotNull(log as EntLib5Logger);
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntLib5Logger"/> class.
        /// </summary>
        public EntLib5Logger()
        {
            var factory = new EntLib5Factory();

            logWriter = factory.CreateDefault();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntLib5Logger"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 public EntLib5Logger(Type type)
 {
     var factory = new EntLib5Factory();
     logWriter = factory.CreateDefault();
     logWriter.SetContextItem("type", type.Name);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntLib5Logger"/> class.
 /// </summary>
 public EntLib5Logger()
 {
     var factory = new EntLib5Factory();
     logWriter = factory.CreateDefault();
 }