当前位置: 首页>>代码示例>>C#>>正文


C# LogWriter类代码示例

本文整理汇总了C#中LogWriter的典型用法代码示例。如果您正苦于以下问题:C# LogWriter类的具体用法?C# LogWriter怎么用?C# LogWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LogWriter类属于命名空间,在下文中一共展示了LogWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        public void Setup()
        {
            this.callHandlerData =
                new LogCallHandlerData("logging")
                {
                    Order = 400,

                    LogBehavior = HandlerLogBehavior.BeforeAndAfter,
                    BeforeMessage = "before",
                    AfterMessage = "after",
                    EventId = 1000,
                    IncludeCallStack = true,
                    IncludeCallTime = false,
                    IncludeParameterValues = true,
                    Priority = 500,
                    Severity = TraceEventType.Warning,
                    Categories = 
                    { 
                        new LogCallHandlerCategoryEntry("cat1"), 
                        new LogCallHandlerCategoryEntry("cat2"), 
                        new LogCallHandlerCategoryEntry("cat3")
                    }
                };

            this.logWriter = new LogWriter(new LoggingConfiguration());
            Logger.SetLogWriter(this.logWriter, false);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:27,代码来源:LogHandlerDataFixture.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Utils.CheckLoggedUser(Session["userEmployee"], UserTypeEmployee))
                    Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlLogin"]);

                if (!Utils.CheckAccountStatus(Session["userEmployee"], UserTypeEmployee))
                    Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlEmployeePasswordChange"]);

                if (!IsPostBack)
                {
                    LoadTexts();
                    Session.Remove("user");
                }
            }
            catch (ThreadAbortException)
            {

            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "Page_Load", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
开发者ID:unlz,项目名称:InscripcionesCursos,代码行数:27,代码来源:CambioTextos.aspx.cs

示例3: CanGetLogFiltersByType

        public void CanGetLogFiltersByType()
        {
            ICollection<ILogFilter> filters = new List<ILogFilter>();

            ICollection<string> categories = new List<string>();
            categories.Add("cat1");
            categories.Add("cat2");
            categories.Add("cat3");
            categories.Add("cat4");
            filters.Add(new CategoryFilter("category", categories, CategoryFilterMode.AllowAllExceptDenied));
            filters.Add(new PriorityFilter("priority", 100));
            filters.Add(new LogEnabledFilter("enable", true));

            LogWriter writer = new LogWriter(filters, new Dictionary<string, LogSource>(), new LogSource("errors"), "default");
            CategoryFilter categoryFilter = writer.GetFilter<CategoryFilter>();
            PriorityFilter priorityFilter = writer.GetFilter<PriorityFilter>();
            LogEnabledFilter enabledFilter = writer.GetFilter<LogEnabledFilter>();

            Assert.IsNotNull(categoryFilter);
            Assert.AreEqual(4, categoryFilter.CategoryFilters.Count);
            Assert.IsNotNull(priorityFilter);
            Assert.AreEqual(100, priorityFilter.MinimumPriority);
            Assert.IsNotNull(enabledFilter);
            Assert.IsTrue(enabledFilter.Enabled);
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:25,代码来源:LogWriterFixture.cs

示例4: Page_Load

        public void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    if (!Utils.CheckLoggedUser(Session["userEmployee"], UserTypeEmployee))
                        Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlLogin"]);
                    Session.Remove("user");
                }

                if (InscripcionDTO.CheckEmployeeTest())
                    btnClean.Enabled = true;

                FailureText.Visible = false;
                divNoDisponible.Visible = false;
            }
            catch (ThreadAbortException)
            {

            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "Page_Load", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
开发者ID:unlz,项目名称:InscripcionesCursos,代码行数:28,代码来源:InscripcionCursos.aspx.cs

示例5: CanFindMatchingCategories

        public void CanFindMatchingCategories()
        {
            Dictionary<string, LogSource> traceSources = new Dictionary<string, LogSource>();
            traceSources.Add("newcat1", new LogSource("newcat1"));
            traceSources.Add("newcat2", new LogSource("newcat2"));
            traceSources.Add("newcat3", new LogSource("newcat3"));
            traceSources.Add("newcat4", new LogSource("newcat4"));
            LogWriter logWriter = new LogWriter(emptyFilters, traceSources, new LogSource("errors"), "default");

            string[] categories = new string[] { "newcat1", "newcat2", "newcat5", "newcat6" };
            LogEntry logEntry = new LogEntry();
            logEntry.Categories = categories;
            IEnumerable<LogSource> matchingTraceSources = logWriter.GetMatchingTraceSources(logEntry);

            logWriter.Dispose();

            Dictionary<string, LogSource> matchingTraceSourcesDictionary = new Dictionary<string, LogSource>();
            foreach (LogSource traceSource in matchingTraceSources)
            {
                matchingTraceSourcesDictionary.Add(traceSource.Name, traceSource);
            }

            Assert.AreEqual(2, matchingTraceSourcesDictionary.Count);
            Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[0]));
            Assert.IsTrue(matchingTraceSourcesDictionary.ContainsKey(categories[1]));
            Assert.IsFalse(matchingTraceSourcesDictionary.ContainsKey(categories[2]));
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:27,代码来源:LogDistributorFixture.cs

示例6: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Utils.CheckLoggedUser(Session["userEmployee"], UserTypeEmployee))
                    Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlLogin"]);

                if (!Utils.CheckAccountStatus(Session["userEmployee"], UserTypeEmployee))
                    Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlEmployeePasswordChange"]);

                if (coleccionDniResend.IndexOf(((Usuario)Session["userEmployee"]).DNI.ToString()) == -1)
                    Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlEmployee"]);

                menuControl = (wucMenuNavegacionSimulador)Master.FindControl("menuSimulador");
                //Session.Remove("user");
                //menuControl.BtnBackClick += new EventHandler(btnBack_Click);
            }
            catch (ThreadAbortException)
            {

            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "Page_Load", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
开发者ID:unlz,项目名称:InscripcionesCursos,代码行数:28,代码来源:SimuladorAlumno.aspx.cs

示例7: btnEnviar_Click

 /// <summary>
 /// Event to save the password change
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnEnviar_Click(object sender, EventArgs e)
 {
     try
     {
         if (!loggedUser.CambioPrimerLogin)
         {
             if (ValidatePassword())
             {
                 loggedUser.CambioPrimerLogin = true;
                 SaveNewPassword();
                 Session.Add("userEmployee", loggedUser);
                 SetSuccessView();
                 Response.AddHeader("REFRESH", "5;URL=" + Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlEmployeeGenerarClaves"]);
             }
             else
             {
                 FailureText.Text = ConfigurationManager.AppSettings["ErrorMessagePasswordNoCambiada"];
                 divMessage.Visible = true;
             }
         }
     }
     catch (Exception ex)
     {
         LogWriter log = new LogWriter();
         log.WriteLog(ex.Message, "btnEnviar_Click", Path.GetFileName(Request.PhysicalPath));
         throw ex;
     }
 }
开发者ID:unlz,项目名称:InscripcionesCursos,代码行数:33,代码来源:CambioContrasenia.aspx.cs

示例8: Write

 /// <summary>
 /// Writes the given log entry to the log.
 /// </summary>
 /// <param name="entry">The log entry to write.</param>
 public void Write(LogEntry entry)
 {
     if (IsTracingEnabled())
     {
         LogWriter writer = new LogWriter(loggingConfigurationView.ConfigurationContext);
         writer.Write(entry);
     }
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:12,代码来源:ConfigurationTraceLogger.cs

示例9: TestInitialize

        public void TestInitialize()
        {
            AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);

            this.logWriter = new LogWriterImpl(new ILogFilter[0], new LogSource[0], new LogSource("name"), "default");
            this.container = new UnityContainer();
            this.container.RegisterInstance(this.logWriter);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:8,代码来源:LogCallHandlerAttributeFixture.cs

示例10: RunIt

        public void RunIt() {
			
            // First we create some delegates using the many syntaxes supported by C# 

			// Old fashioned delegate creation
			// initialize delegate with a named method.
            LogWriter delA = new LogWriter(MethodDelegate);

            // We can just also just assign a method group to a delegate variable
            LogWriter delB = MethodDelegateTwo;
			
			// Since C# 2.0 a delegate can be initialized with
			// an "anonymous method." 
            LogWriter delC = delegate(string s) { Console.WriteLine("AnonymousMethodDelegate[" + _captured_string + "]:\t\t" + s); };
			
			// Since C# 3.0 a delegate can be initialized with
			// a lambda expression. 
            LogWriter delD = (string s) => { Console.WriteLine("LambdaExpressionDelegate[" + _captured_string + "]:\t\t" + s); };
			
			// Since C# 3.0 a delegate can be initialized with
			// a lambda expression, the type of the argument is inferred by the compiler.
            LogWriter delE = s => { Console.WriteLine("InferredLambdaExpressionDelegate[" + _captured_string + "]:\t" + s); };
			
			// Invoke the delegates.
			delA("Peter Piper");
			delB("picked a peck");
            delC("of pickled peppers.");
            delD("A peck of pickled peppers");
            delE("Peter Piper picked.");

            // Change the captured parameter and run them again 
            this._captured_string = "aaaa";

            delA("Peter Piper");
            delB("picked a peck");
            delC("of pickled peppers.");
            delD("A peck of pickled peppers");
            delE("Peter Piper picked.");

            // Now Combine the delegates
            var chainDelegates = delA + delB + delC + delD + delE;

            // and invoke it
            chainDelegates("Chained Delegates");

            // remove delB and rerun
            chainDelegates -= delB;

            chainDelegates("Chained without MethodDelegateTwo");
            
            // Calculate (4 * (x^x)) + 1
            Processor<int> calcIt = (ref int x) => { x = x*x; };
            calcIt += (ref int x) => { x = 4 * x; };
            calcIt += (ref int x) => { x += 1; };
            int val = 5;
            calcIt(ref val);
            Console.WriteLine("(4 * (5^5)) + 1 = " + val);
        }
开发者ID:exaphaser,项目名称:cs2j,代码行数:58,代码来源:DelegateSampler.cs

示例11: SetUp

		public void SetUp()
		{
			logWriter = EnterpriseLibraryFactory.BuildUp<LogWriter>();
			MockTraceListener.Reset();
			ErrorsMockTraceListener.Reset();
			
			emptyTraceSource = new LogSource("none");
			if (emptyTraceSource.Listeners.Count == 1)
				emptyTraceSource.Listeners.RemoveAt(0);
		}
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:10,代码来源:LogDistributorFixture.cs

示例12: Assembly_info_is_written_on_log_writer_construction

        public void Assembly_info_is_written_on_log_writer_construction()
        {
            var encoder = Substitute.For<ILogEncoder>();
              var byteWriter = Substitute.For<IByteWriter>();

              // ReSharper disable once UnusedVariable
              var logWriter = new LogWriter(encoder, byteWriter);

              encoder.Received(1).EncodeAssemblyInfo();
              byteWriter.Received(1).WriteBytes(Arg.Any<byte[]>());
        }
开发者ID:DangerousDarlow,项目名称:Logging,代码行数:11,代码来源:LogWriterTest.cs

示例13: SetUp

        public void SetUp()
        {
            AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);

            logWriter = new LogWriterFactory().Create();
            MockTraceListener.Reset();
            ErrorsMockTraceListener.Reset();

            emptyTraceSource = new LogSource("none", Enumerable.Empty<TraceListener>(), SourceLevels.All);
            Assert.IsFalse(emptyTraceSource.Listeners.Any());
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:11,代码来源:LogDistributorFixture.cs

示例14: CreateSafeLogWriter

	/// <summary>
	/// 
	/// </summary>
	/// <returns></returns>
	static LogWriter CreateSafeLogWriter()
	{
		bool bHasDDrive = Directory.Exists( "D:" );
		bool bHasFDrive = Directory.Exists( "F:" );
		
		string LogsPath = bHasFDrive ? "F:/" : (bHasDDrive ? "D:/" : "C:/");
		LogsPath += "CrashReportWebsiteLogs";

		LogWriter Log = new LogWriter( "CrashReportWebSite-" + GetCleanUserName(), LogsPath );
		return Log;
	}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:15,代码来源:PerformanceTimers.cs

示例15: SetUp

        public void SetUp()
        {
            AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory);

            logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
            MockTraceListener.Reset();
            ErrorsMockTraceListener.Reset();

            emptyTraceSource = new LogSource("none");
            if (emptyTraceSource.Listeners.Count == 1)
                emptyTraceSource.Listeners.RemoveAt(0);
        }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:12,代码来源:LogDistributorFixture.cs


注:本文中的LogWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。