public static List <TrinityObjectiveInfo> GetObjectiveInfo()
        {
            // Why you make things so difficult for me nesox?
            var objectives = new List <TrinityObjectiveInfo>();
            var logger     = (log4net.Repository.Hierarchy.Logger)log4net.LogManager.GetLogger(typeof(QuestObjectiveInfo))?.Logger;

            if (logger == null)
            {
                return(objectives);
            }
            var dbLogger = (log4net.Repository.Hierarchy.Logger)log4net.LogManager.GetLogger(typeof(Demonbuddy.MainWindow))?.Logger;

            if (dbLogger == null)
            {
                return(objectives);
            }
            var asyncAppender = dbLogger.Parent.Appenders.ToArray().OfType <Zeta.Common.Logger.AsyncAppender>().FirstOrDefault();
            var repository    = (Hierarchy)LogManager.GetRepository();

            repository.Root.RemoveAppender(asyncAppender);
            var appender = new MemoryAppender();

            logger.AddAppender(appender);
            QuestObjectiveInfo.DumpObjectives();
            objectives.AddRange(appender.GetEvents().Select(e => new TrinityObjectiveInfo(e.RenderedMessage)));
            logger.RemoveAppender(appender);
            repository.Root.AddAppender(asyncAppender);
            return(objectives);
        }
예제 #2
0
파일: Logging.cs 프로젝트: yash0924/taskt
        /// <summary>
        /// Sets up a new logging instance
        /// </summary>
        public static void Setup(string logName)
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout
            {
                ConversionPattern = "%date [%thread] %-5level - %message%newline"
            };

            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender
            {
                AppendToFile       = true,
                File               = Core.Common.GetLogFolderPath() + "\\" + logName + ".txt",
                Layout             = patternLayout,
                MaxSizeRollBackups = 5,
                MaximumFileSize    = "1GB",
                RollingStyle       = RollingFileAppender.RollingMode.Size,
                StaticLogFileName  = true
            };

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #3
0
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout()
            {
                ConversionPattern = "%date [%thread] %-5level %logger - %message%newline"
            };

            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender {
                AppendToFile = true, StaticLogFileName = true, File = @"Logs\Log.log", Layout = patternLayout, MaxSizeRollBackups = 5, MaximumFileSize = "5MB", RollingStyle = RollingFileAppender.RollingMode.Size
            };

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.All;
            BasicConfigurator.Configure(hierarchy);
            hierarchy.Configured = true;
        }
예제 #4
0
파일: Auxiliary.cs 프로젝트: sfcheewill/Blm
            public static void SetupLogger(String path)
            {
                Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

                if (hierarchy.Configured)
                {
                    return;
                }

                PatternLayout patternLayout = new PatternLayout();

                patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
                patternLayout.ActivateOptions();

                RollingFileAppender roller = new RollingFileAppender();

                roller.AppendToFile       = true;
                roller.File               = Path.Combine(path);
                roller.Layout             = patternLayout;
                roller.MaxSizeRollBackups = 5;
                roller.MaximumFileSize    = "10MB";
                roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
                roller.StaticLogFileName  = true;
                roller.LockingModel       = new FileAppender.MinimalLock();
                roller.ActivateOptions();
                hierarchy.Root.AddAppender(roller);

                MemoryAppender memory = new MemoryAppender();

                memory.ActivateOptions();
                hierarchy.Root.AddAppender(memory);

                hierarchy.Root.Level = Level.Info;
                hierarchy.Configured = true;
            }
예제 #5
0
        /// <summary>
        /// call this to direct logging to an array in memory - useful in performace tests where we may wish
        /// to parse the log for timing info
        /// code fragment from http://dhvik.blogspot.com/2008/08/adding-appender-to-log4net-in-runtime.html
        /// </summary>
        static public void AddMemoryAppender()
        {
            //First create and configure the appender
            MemoryAppender memoryAppender = new MemoryAppender {
                Name = "MemoryAppender"
            };                                                                            // Not L10N

            //Notify the appender on the configuration changes
            memoryAppender.ActivateOptions();

            //Get the logger repository hierarchy.
            Hierarchy repository = LogManager.GetRepository() as Hierarchy;

            if (repository != null)
            {
                //and add the appender to the root level
                //of the logging hierarchy
                repository.Root.AddAppender(memoryAppender);

                //configure the logging at the root.
                repository.Root.Level = Level.All;

                //mark repository as configured and
                //notify that is has changed.
                repository.Configured = true;
                repository.RaiseConfigurationChanged(EventArgs.Empty);
            }
        }
예제 #6
0
        public void TestThreadSafety()
        {
            ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
            var memoryAppender    = new MemoryAppender();
            var patternLayout     = new PatternLayout();

            memoryAppender.Layout = patternLayout;
            memoryAppender.ActivateOptions();
            BasicConfigurator.Configure(rep, memoryAppender);

            cThreadsRunning = cThreadsMax;
            var threads = Enumerable.Range(0, cThreadsMax)
                          .Select(i => new Thread(LogMessages(rep.Name)))
                          .ToList();

            foreach (var thread in threads)
            {
                thread.Start();
            }

            long cEventsRead = 0;

            while (cThreadsRunning > 0)
            {
                var events = memoryAppender.PopAllEvents();
                cEventsRead += events.Length;
            }
            foreach (var thread in threads)
            {
                thread.Join();
            }
            cEventsRead += memoryAppender.PopAllEvents().Length;
            Assert.AreEqual(cEventsExpected, cEventsRead, "Log events were lost.");
        }
        public override void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository)
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = false;
            roller.File               = ConfigurationManager.AppSettings["LogFileLocation"];
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize    = "1GB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
 public Log4NetLogProviderLoggingTests()
 {
     _memoryAppender = new MemoryAppender();
     BasicConfigurator.Configure(_memoryAppender);
     _logProvider = new Log4NetLogProvider();
     _sut         = new Log4NetLogProvider().GetLogger("Test");
 }
예제 #9
0
        public static void Configure()
        {
            if (isSetupLogHandler)
            {
                return;
            }
            isSetupLogHandler = true;

            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = true;
            roller.File               = Environment.ExpandEnvironmentVariables(@"%AppData%\MyGitHubProject\UseRegistryInWPF\UseRegistryInWPFLog.txt");
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 20;
            roller.MaximumFileSize    = "20MB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #10
0
        public async Task TransportHost_LogsError_WhenStartFails()
        {
            // arrange
            LogManager.Manager.AddListener(Log4NetStandardLogListener.Instance);
            var appender = new MemoryAppender();

            log4net.Config.BasicConfigurator.Configure(appender);
            const string errorMessage = "error message";

            _mockNServiceBusServer.Setup(m => m.Start(It.IsAny <string>(), It.IsAny <bool>())).ReturnsAsync(errorMessage);

            // act
            await _transportHost.Start(false, () => true);

            // Give the logging time to finish
            Thread.Sleep(1000);
            var logEntries = appender.GetEvents();

            Log4NetStandardLogListener.Clear();
            LogManager.Manager.ClearListeners();

            // assert
            Assert.AreEqual(1, logEntries.Length);
            Assert.AreEqual(errorMessage, logEntries.Single().RenderedMessage);
            _mockNServiceBusServer.Verify(m => m.Start(It.IsAny <string>(), It.IsAny <bool>()), Times.Once);
        }
예제 #11
0
        public void Init(string root)
        {
            this.root = root;
            string logpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dyn.log");

            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = true;
            roller.File               = logpath;
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize    = "4MB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;

            log = LogManager.GetLogger(GetType().FullName);
        }
예제 #12
0
        /// <summary>
        /// The Setup.
        /// </summary>
        /// <param name="appName">The appName<see cref="string"/>.</param>
        public static void Setup(string appName)
        {
            LogFilePath = GetLogFilePath(appName);
            var entryAssembly = Assembly.GetExecutingAssembly();
            var hierarchy     = (Hierarchy)LogManager.GetRepository(entryAssembly);

            var patternLayout = new PatternLayout
            {
                ConversionPattern = "%date [%thread] %-5level %logger - %message%newline"
            };

            patternLayout.ActivateOptions();

            var roller = new RollingFileAppender
            {
                AppendToFile       = false,
                File               = LogFilePath,
                Layout             = patternLayout,
                MaxSizeRollBackups = 5,
                MaximumFileSize    = "1GB",
                RollingStyle       = RollingFileAppender.RollingMode.Size,
                StaticLogFileName  = true
            };

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            var memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #13
0
        public void Test()
        {
            // Get the default hierarchy
            var h = LogManager.GetLoggerRepository() as Hierarchy;
            var m = new MemoryAppender();

            h.Root.AddAppender(m);
            log.Debug("test");
            var l1a = new L1("a");
            var l1b = new L1("b");

            l1a.L1CallL2();
            l1b.L1CallL2();
            var events = m.GetEvents();

            CheckEvent(0, events, typeof(ContextLoggerTests), "Test", "test");
            CheckEvent(1, events, typeof(L1), ".ctor", "[a] L1 logger created");
            CheckEvent(2, events, typeof(L1), ".ctor", "[b] L1 logger created");
            CheckEvent(3, events, typeof(L1), "L1CallL2", "[a] L1 calling L2");
            CheckEvent(4, events, typeof(L2), ".ctor", "[a] L2 logger created");
            CheckEvent(5, events, typeof(L2), "L2Call", "[a] L2 call");
            CheckEvent(6, events, typeof(L1), "L1CallL2", "[b] L1 calling L2");
            CheckEvent(7, events, typeof(L2), ".ctor", "[b] L2 logger created");
            CheckEvent(8, events, typeof(L2), "L2Call", "[b] L2 call");
            h.Root.RemoveAppender(m);
        }
예제 #14
0
        private void SetLogger()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "[%date][%level] %logger -> %message%newline";
            patternLayout.ActivateOptions();

            FileAppender roller = new FileAppender();
            String       fecha  = DateTime.Now.ToString("yyyy_MM_dd");

            roller.File         = "C:\\VentasSys_Logs\\" + fecha + "_VentasSys.log";
            roller.AppendToFile = true;
            roller.Layout       = patternLayout;

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = log4net.Core.Level.All;
            hierarchy.Configured = true;
        }
예제 #15
0
        public static void DebugConfig()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            hierarchy.Root.RemoveAllAppenders();
            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date|||[%thread]|||%-5level|||%property{method_name}|||%property{type}|||%property{model}|||%message%newline";
            patternLayout.ActivateOptions();
            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile                 = true;
            roller.LockingModel                 = new FileAppender.MinimalLock();
            roller.File                         = @"logs\";
            roller.Layout                       = patternLayout;
            roller.MaxSizeRollBackups           = 5;
            roller.MaximumFileSize              = "2048KB";
            roller.DatePattern                  = "dd.MM.yyyy'.log'";
            roller.RollingStyle                 = RollingFileAppender.RollingMode.Composite;
            roller.StaticLogFileName            = false;
            roller.PreserveLogFileNameExtension = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);
            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);
            hierarchy.Root.Level = Level.Debug;
            hierarchy.Configured = true;
        }
예제 #16
0
        public static void SetupLog()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = false;
            roller.File               = Application.UserAppDataPath + "\\ZonBarcodeLog.txt";
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize    = "10MB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;

            _ServiceLog = LogManager.GetLogger("ServiceLog");
        }
예제 #17
0
        /// <summary>
        /// Setup Log4NET logger.
        /// </summary>
        internal static void Setup()
        {
            var hierarchy = (Hierarchy)LogManager.GetRepository();

            var patternLayout = new PatternLayout
            {
                ConversionPattern = "%date [%thread] %-5level %logger - %message%newline"
            };

            patternLayout.ActivateOptions();

            var roller = new FileAppender
            {
                AppendToFile = false,
                File         = @"AllureLog.txt",
                Layout       = patternLayout
            };

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            var memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout
            {
                ConversionPattern = "%date{dd-MMM-yyyy HH:mm:ss} %level %message%newline"
            };

            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender
            {
                AppendToFile = true,
                File         = @"..\..\LoggFiles\\" +
                               DateTime.Now.ToString("dd-MMM-yyyy") /*+ "\\" + DateTime.Now.ToString("hh.mm.ss") */ + ".txt",
                Layout             = patternLayout,
                MaxSizeRollBackups = 5,
                MaximumFileSize    = "1GB",
                RollingStyle       = RollingFileAppender.RollingMode.Size,
                StaticLogFileName  = true
            };

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #19
0
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date %-5level - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = true;
            roller.File               = @"logs\";
            roller.DatePattern        = "yyyy.MM.dd'.log'";
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 30;
            roller.MaximumFileSize    = "5MB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Composite;
            roller.StaticLogFileName  = false;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #20
0
        /// <summary>
        /// Init log4net memoryAppender
        /// http://dhvik.blogspot.com/2008/08/adding-appender-to-log4net-in-runtime.html
        /// </summary>
        void InitLogger()
        {
            //First create and configure the appender
            this.memoryAppender      = new MemoryAppender();
            this.memoryAppender.Name = this.GetType().Name + "MemoryAppender";

            PatternLayout layout = new PatternLayout();

            layout.ConversionPattern = "%date %-5level %20.20logger{1} - %message%newline";
            layout.ActivateOptions();
            this.memoryAppender.Layout = layout;

            //Notify the appender on the configuration changes
            this.memoryAppender.ActivateOptions();

            //Get the logger repository hierarchy.
            this.repository = (Hierarchy)LogManager.GetRepository();

            //and add the appender to the root level
            //of the logging hierarchy
            this.repository.Root.AddAppender(memoryAppender);

            //configure the logging at the root.
            //this.repository.Root.Level = Level.Info;

            //mark repository as configured and notify that is has changed.
            this.repository.Configured = true;
            this.repository.RaiseConfigurationChanged(EventArgs.Empty);

            this.msgWriter = new StringWriter();
        }
예제 #21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // gather log4net output with small hack to get results...
        ILoggerRepository repository = LogManager.GetRepository();

        IAppender[]    appenders = repository.GetAppenders();
        MemoryAppender appender  = null;

        foreach (IAppender a in appenders)
        {
            if (a is MemoryAppender)
            {
                // we found our appender to look results from
                appender = a as MemoryAppender;
                break;
            }
        }

        if (appender != null)
        {
            appender.Clear();
            fulfillmentService.ProcessCustomer(customerEditController.CurrentCustomer.Id);
            LoggingEvent[] events       = appender.GetEvents();
            StringWriter   stringWriter = new StringWriter();
            PatternLayout  layout       = new PatternLayout("%date{HH:mm:ss} %-5level %logger{1}: %message<br />");
            foreach (LoggingEvent loggingEvent in events)
            {
                layout.Format(stringWriter, loggingEvent);
            }

            results.Text = stringWriter.ToString();
        }
    }
예제 #22
0
        private LogHelper()
        {
            var hierarchy = (Hierarchy)LogManager.GetRepository(Assembly.GetCallingAssembly());

            var patternLayout = new PatternLayout
            {
                ConversionPattern = LogPatternLayout
            };

            patternLayout.ActivateOptions();

            var roller = new RollingFileAppender
            {
                AppendToFile       = true,
                File               = $@"Logs\\{Path.GetFileNameWithoutExtension(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path))}.log",
                Layout             = patternLayout,
                MaxSizeRollBackups = 300,
                MaximumFileSize    = "1MB",
                RollingStyle       = RollingFileAppender.RollingMode.Date,
                StaticLogFileName  = true,
                DatePattern        = ".yyyy.MM.dd'.log'"
            };

            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            var memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;
            InternalLogger       = LogManager.GetLogger(this.GetType());
        }
예제 #23
0
        public object Log()
        {
            var baseUrl = Request.RequestUri.Authority;
            var node    = ServerManager.Get(baseUrl);

            return(MemoryAppender.GetMessage(node.BaseUrl));
        }
예제 #24
0
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date{dd/MM/yyyy hh:mm:ss.fff tt} | %logger[%method:%line] %level - %message%newline%exception";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = false;
            roller.Encoding           = Encoding.UTF8;
            roller.File               = Path.Combine(AddonEx.dir_Logs, "AddonManager.log");
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize    = "5MB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;

            doFirstEntry();
        }
예제 #25
0
        public static void ConfigureLog4NetForSetup()
        {
            String path = @"C:\Users\Public\Documents\OctaneTfsPlugin\logs\setup.log";

            Directory.CreateDirectory(Path.GetDirectoryName(path));

            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = true;
            roller.File               = path;
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 2;
            roller.MaximumFileSize    = "3MB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            roller.LockingModel = new FileAppender.MinimalLock();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Debug;
            hierarchy.Configured = true;
        }
예제 #26
0
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile = true;

            roller.File               = @"C:/Log.txt";
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize    = "1GB";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Date;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
 public Log4NetLogProviderLoggingDisabledTests()
 {
     _memoryAppender = new MemoryAppender();
     _memoryAppender.AddFilter(new DenyAllFilter());
     BasicConfigurator.Configure(_memoryAppender);
     _sut = new Log4NetLogProvider().GetLogger("Test");
 }
        public void SimpleTest()
        {
            container.Register(Component.For(typeof(SimpleLoggingComponent)).Named("component1"));
            SimpleLoggingComponent test = container.Resolve <SimpleLoggingComponent>("component1");

            test.DoSomething();

            String         expectedLogOutput = String.Format("[INFO ] [{0}] - Hello world" + Environment.NewLine, typeof(SimpleLoggingComponent).FullName);
            MemoryAppender memoryAppender    = ((Hierarchy)LogManager.GetRepository()).Root.GetAppender("memory") as MemoryAppender;
            TextWriter     actualLogOutput   = new StringWriter();
            PatternLayout  patternLayout     = new PatternLayout("[%-5level] [%logger] - %message%newline");

            patternLayout.Format(actualLogOutput, memoryAppender.GetEvents()[0]);

            Assert.AreEqual(expectedLogOutput, actualLogOutput.ToString());

            container.Register(Component.For(typeof(SmtpServer)).Named("component2"));
            ISmtpServer smtpServer = container.Resolve <ISmtpServer>("component2");

            smtpServer.Start();
            smtpServer.InternalSend("*****@*****.**", "*****@*****.**", "We're looking for a few good porgrammars.");
            smtpServer.Stop();

            expectedLogOutput = String.Format("[DEBUG] [Castle.Facilities.Logging.Tests.Classes.SmtpServer] - Stopped" + Environment.NewLine, typeof(SimpleLoggingComponent).FullName);
            memoryAppender    = ((Hierarchy)LogManager.GetRepository()).Root.GetAppender("memory") as MemoryAppender;
            actualLogOutput   = new StringWriter();
            patternLayout     = new PatternLayout("[%-5level] [%logger] - %message%newline");

            Assert.AreEqual(memoryAppender.GetEvents().Length, 4);

            patternLayout.Format(actualLogOutput, memoryAppender.GetEvents()[3]);

            Assert.AreEqual(expectedLogOutput, actualLogOutput.ToString());
        }
예제 #29
0
        public void FilterDefWithoutReference()
        {
            const string filterDef = @"<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' >

	<filter-def name='LiveFilter'>
		<filter-param name='LiveParam' type='boolean'/>
	</filter-def>

</hibernate-mapping>";

            var cfg = GetConfiguration();

            cfg.AddXmlString(filterDef);
            var memoryAppender = new MemoryAppender();

            BasicConfigurator.Configure(LogManager.GetRepository(typeof(ConfigFixture).Assembly), memoryAppender);
            try
            {
                cfg.BuildSessionFactory();

                var wholeLog = String.Join("\r\n", memoryAppender.GetEvents().Select(x => x.RenderedMessage).ToArray());
                Assert.That(wholeLog, Does.Contain("filter-def for filter named"));
                Assert.That(wholeLog, Does.Contain("was never used to filter classes nor collections."));
            }
            finally
            {
                LogManager.Shutdown();
            }
        }
예제 #30
0
        public static void Setup()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            PatternLayout patternLayout = new PatternLayout();

            patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
            patternLayout.ActivateOptions();

            RollingFileAppender roller = new RollingFileAppender();

            roller.AppendToFile       = false;
            roller.File               = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "xltrail", "logs", "xltrail-addin.log");
            roller.Layout             = patternLayout;
            roller.MaxSizeRollBackups = 5;
            roller.MaximumFileSize    = "1048576";
            roller.RollingStyle       = RollingFileAppender.RollingMode.Size;
            roller.StaticLogFileName  = true;
            roller.ActivateOptions();
            hierarchy.Root.AddAppender(roller);

            MemoryAppender memory = new MemoryAppender();

            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #31
0
        /// <summary>
        /// Creates the memory logger.
        /// </summary>
        private static MemoryAppender CreateMemoryLogger()
        {
            var hierarchy = (Hierarchy) LogManager.GetRepository();

            var memory = new MemoryAppender();
            memory.ActivateOptions();
            hierarchy.Root.AddAppender(memory);

            hierarchy.Root.Level = Level.All;
            hierarchy.Configured = true;

            return memory;
        }