Exemplo n.º 1
0
		public static void InitFileLogs()
		{
			root_folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
			file = System.IO.Path.Combine(LogSamples.root_folder, "log4net-file.log");
			file_copy = file + ".txt";

			global::log4net.Layout.SimpleLayout layout = new global::log4net.Layout.SimpleLayout();
			layout.ActivateOptions();

			FileAppender = new global::log4net.Appender.FileAppender();
			FileAppender.File = System.IO.Path.Combine(root_folder, "log4net-file.log");
			FileAppender.Layout = layout;
			FileAppender.ActivateOptions();
			global::log4net.Config.BasicConfigurator.Configure(FileAppender);

			RollingFileAppender = new global::log4net.Appender.RollingFileAppender();
			RollingFileAppender.File = System.IO.Path.Combine(root_folder, "log4net-file-rolling.log");
			RollingFileAppender.Layout = layout;
			RollingFileAppender.ActivateOptions();
			global::log4net.Config.BasicConfigurator.Configure(RollingFileAppender);

			global::log4net.Appender.AppenderCollection appenders =
					new global::log4net.Appender.AppenderCollection();
			appenders.Add(FileAppender);
			appenders.Add(RollingFileAppender);

			hierarchy_file =
				(global::log4net.Repository.Hierarchy.Hierarchy)
					global::log4net.LogManager.GetRepository();
			hierarchy_file.Root.AddAppender(FileAppender);
			hierarchy_file.Root.AddAppender(RollingFileAppender);

			//configure the logging at the root.  
			hierarchy_file.Root.Level = global::log4net.Core.Level.All;


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

			LogForFiles = global::log4net.LogManager.GetLogger("LogForFiles");
			//LogForFiles.Logger.Repository.ResetConfiguration();


			int a = hierarchy_file.Root.Appenders.Count;
		}
Exemplo n.º 2
0
        public static void InitFileLogs()
        {
            root_folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
            file        = System.IO.Path.Combine(LogSamples.root_folder, "log4net-file.log");
            file_copy   = file + ".txt";

            global::log4net.Layout.SimpleLayout layout = new global::log4net.Layout.SimpleLayout();
            layout.ActivateOptions();

            FileAppender        = new global::log4net.Appender.FileAppender();
            FileAppender.File   = System.IO.Path.Combine(root_folder, "log4net-file.log");
            FileAppender.Layout = layout;
            FileAppender.ActivateOptions();
            global::log4net.Config.BasicConfigurator.Configure(FileAppender);

            RollingFileAppender        = new global::log4net.Appender.RollingFileAppender();
            RollingFileAppender.File   = System.IO.Path.Combine(root_folder, "log4net-file-rolling.log");
            RollingFileAppender.Layout = layout;
            RollingFileAppender.ActivateOptions();
            global::log4net.Config.BasicConfigurator.Configure(RollingFileAppender);

            global::log4net.Appender.AppenderCollection appenders =
                new global::log4net.Appender.AppenderCollection();
            appenders.Add(FileAppender);
            appenders.Add(RollingFileAppender);

            hierarchy_file =
                (global::log4net.Repository.Hierarchy.Hierarchy)
                global::log4net.LogManager.GetRepository();
            hierarchy_file.Root.AddAppender(FileAppender);
            hierarchy_file.Root.AddAppender(RollingFileAppender);

            //configure the logging at the root.
            hierarchy_file.Root.Level = global::log4net.Core.Level.All;


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

            LogForFiles = global::log4net.LogManager.GetLogger("LogForFiles");
            //LogForFiles.Logger.Repository.ResetConfiguration();


            int a = hierarchy_file.Root.Appenders.Count;
        }