zoukankan      html  css  js  c++  java
  • Configure Log Output

    最近在一直的练习用VB。NET来书写程序。在VB中加入一个app.config文件,会有自动帮你生成一段关于Log output的配置,具体请看

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.diagnostics>
            <sources>
                <!-- This section defines the logging configuration for My.Application.Log -->
                <source name="DefaultSource" switchName="DefaultSwitch">
                    <listeners>
                        <add name="FileLog"/>
                        <!-- Uncomment the below section to write to the Application Event Log -->
                        <!--<add name="EventLog"/>-->
                    </listeners>
                </source>
            </sources>
            <switches>
                <add name="DefaultSwitch" value="Information" />
            </switches>
            <sharedListeners>
                <add name="FileLog"
                     type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                     initializeData="FileLogWriter">
                <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
                <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
            </sharedListeners>
        </system.diagnostics>
    </configuration>

    这样配置完成后,运行后,日志会放在

    C:\Users\username\Application Data\Company\Product\Version\AppName.log下。

    但我感觉这样的目录太深了,不易于查找。 想换一个地方配置。 但利用VS2008的自动提示好像没有这样的设置项,这让我困惑了不少。但Google了一下发下还是可以做到的。 看来是VS2008里面的XML配置文件的Schema不是最新的(或是MS想隐藏些什么??)。

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.diagnostics>
            <sources>
                <!-- This section defines the logging configuration for My.Application.Log -->
                <source name="DefaultSource" switchName="DefaultSwitch">
                    <listeners>
                        <add name="FileLog"/>
                        <!-- Uncomment the below section to write to the Application Event Log -->
                        <!--<add name="EventLog"/>-->
                    </listeners>
                </source>
            </sources>
            <switches>
                <add name="DefaultSwitch" value="Information" />
            </switches>
            <sharedListeners>
                <add name="FileLog"
                     type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                     initializeData="FileLogWriter"
                      location="Custom"
                     customLocation="C:\test"/>

                <!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
                <!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
            </sharedListeners>
        </system.diagnostics>
    </configuration>

  • 相关阅读:
    4.2说说计算机中的异常
    1.1组合电路、时序电路在计算机课程中的地位
    EFM32JG系列MCU内部温度传感器使用方法
    +7虚拟内存的作用,通过什么方式提高虚拟内存的性能
    +6存储结构是怎样提高性能的,它和局部性的关系是什么。
    +5性能分析定律
    +4 高速缓存
    +3软件优化至关重要,软件优化一般有哪些方法?
    +2流水线是怎样提高性能的,会遇到什么问题,解决方法是什么
    +1阿姆达尔定律
  • 原文地址:https://www.cnblogs.com/buhaiqing/p/1407618.html
Copyright © 2011-2022 走看看