• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LogWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: CreateSafeLogWriter

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

		string LogFileName = bUseGlobal ? "Global-" + Guid.NewGuid().ToString( "N" ) : string.Format( "{1}-[{0}]", System.Threading.Thread.CurrentThread.ManagedThreadId, GetPathName() );

		LogWriter Log = new LogWriter( LogFileName,LogsPath );
		return Log;
	}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:17,代码来源:PerformanceTimers.cs


示例17: Assembly_info_is_not_written_if_encoder_returns_null

        public void Assembly_info_is_not_written_if_encoder_returns_null()
        {
            var encoder = Substitute.For<ILogEncoder>();
              encoder.EncodeAssemblyInfo().Returns(x => null);

              var byteWriter = Substitute.For<IByteWriter>();

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

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


示例18: btnClean_Click

 protected void btnClean_Click(object sender, EventArgs e)
 {
     try
     {
         InscripcionDTO.DeleteEmployeeTestInscription();
         btnClean.Enabled = false;
     }
     catch (Exception ex)
     {
         LogWriter log = new LogWriter();
         log.WriteLog(ex.Message, "btnClean_Click", Path.GetFileName(Request.PhysicalPath));
         throw ex;
     }
 }
开发者ID:unlz,项目名称:InscripcionesCursos,代码行数:14,代码来源:InscripcionCursos.aspx.cs


示例19: Setup

 public void Setup()
 {
     this.traceListener = new MockTraceListener("original");
     this.logWriter =
         new LogWriter(
             new LogWriterStructureHolder(
                 new ILogFilter[0],
                 new Dictionary<string, LogSource>(),
                 new LogSource("all", new[] { traceListener }, SourceLevels.All),
                 new LogSource("not processed"),
                 new LogSource("error"),
                 "default",
                 false,
                 false,
                 false));
 }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:16,代码来源:LogWriterInjectionFixture.cs


示例20: LogCallHandler

 /// <summary>
 /// Creates a new <see cref="LogCallHandler"/> that writes to the specified <see cref="LogWriter"/>
 /// using the given logging settings.
 /// </summary>
 /// <param name="logWriter"><see cref="LogWriter"/> to write log entries to.</param>
 /// <param name="eventId">EventId to include in log entries.</param>
 /// <param name="logBeforeCall">Should the handler log information before calling the target?</param>
 /// <param name="logAfterCall">Should the handler log information after calling the target?</param>
 /// <param name="beforeMessage">Message to include in a before-call log entry.</param>
 /// <param name="afterMessage">Message to include in an after-call log entry.</param>
 /// <param name="includeParameters">Should the parameter values be included in the log entry?</param>
 /// <param name="includeCallStack">Should the current call stack be included in the log entry?</param>
 /// <param name="includeCallTime">Should the time to execute the target be included in the log entry?</param>
 /// <param name="priority">Priority of the log entry.</param>
 public LogCallHandler(LogWriter logWriter, int eventId,
                       bool logBeforeCall,
                       bool logAfterCall, string beforeMessage, string afterMessage,
                       bool includeParameters, bool includeCallStack,
                       bool includeCallTime, int priority)
 {
     this.logWriter = logWriter;
     this.eventId = eventId;
     this.logBeforeCall = logBeforeCall;
     this.logAfterCall = logAfterCall;
     this.beforeMessage = beforeMessage;
     this.afterMessage = afterMessage;
     this.includeParameters = includeParameters;
     this.includeCallStack = includeCallStack;
     this.includeCallTime = includeCallTime;
     this.priority = priority;
 }
开发者ID:jmeckley,项目名称:Enterprise-Library-5.0,代码行数:31,代码来源:LogCallHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Log_Reports类代码示例发布时间:2022-05-24
下一篇:
C# LogType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap