Exemplo n.º 1
0
        private static void ConfigureDebugLogging()
        {
            if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config")))
            {
                return;                // that overrides the default config
            }
            var loggerRepository = LogManager.GetRepository(typeof(HttpServer).Assembly);

            var patternLayout   = new PatternLayout(PatternLayout.DefaultConversionPattern);
            var consoleAppender = new ConsoleAppender
            {
                Layout = patternLayout,
            };

            consoleAppender.ActivateOptions();
            ((Logger)loggerRepository.GetLogger(typeof(HttpServer).FullName)).AddAppender(consoleAppender);
            var fileAppender = new RollingFileAppender
            {
                AppendToFile       = false,
                File               = "Raven.Server.log",
                Layout             = patternLayout,
                MaxSizeRollBackups = 3,
                MaximumFileSize    = "1024KB",
                StaticLogFileName  = true,
                LockingModel       = new FileAppender.MinimalLock()
            };

            fileAppender.ActivateOptions();

            var asyncBufferingAppender = new AsyncBufferingAppender();

            asyncBufferingAppender.AddAppender(fileAppender);

            ((Hierarchy)loggerRepository).Root.AddAppender(asyncBufferingAppender);
            loggerRepository.Configured = true;
        }
Exemplo n.º 2
0
    	private static void ConfigureDebugLogging()
    	{
			if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config")))
				return;// that overrides the default config

			var loggerRepository = LogManager.GetRepository(typeof(HttpServer).Assembly);
			
			var patternLayout = new PatternLayout(PatternLayout.DefaultConversionPattern);
    		var consoleAppender = new ConsoleAppender
    		                      	{
    		                      		Layout = patternLayout,
    		                      	};
    		consoleAppender.ActivateOptions();
    		((Logger)loggerRepository.GetLogger(typeof(HttpServer).FullName)).AddAppender(consoleAppender);
    		var fileAppender = new RollingFileAppender
    		                   	{
    		                   		AppendToFile = false,
    		                   		File = "Raven.Server.log",
    		                   		Layout = patternLayout,
    		                   		MaxSizeRollBackups = 3,
    		                   		MaximumFileSize = "1024KB",
    		                   		StaticLogFileName = true,
									LockingModel = new FileAppender.MinimalLock()
    		                   	};
    		fileAppender.ActivateOptions();

    		var asyncBufferingAppender = new AsyncBufferingAppender();
    		asyncBufferingAppender.AddAppender(fileAppender);

    		((Hierarchy) loggerRepository).Root.AddAppender(asyncBufferingAppender);
    		loggerRepository.Configured = true;
    	}