我们有一个自定义的TraceListener(继承自System.Diagnostics.TraceListener),用于我们的ASP.NET Web应用程序记录日志。一直以来都表现良好,从未出现问题。但突然间在我们的开发环境中停止工作了(TraceListener.TraceEvent()不再触发)。我们对它突然停止工作感到困惑。我们所做的唯一更改是增加了更多的构建配置(Dev、Test、Stage、Prod),之前只有Debug和Release。
我注意到,当我使用Debug配置进行本地测试时,TraceListener.TraceEvent()能够正常触发。但当我切换到其他构建配置(例如Test)时,TraceEvent()就不再被触发了。这是我的Web .csproj文件的一部分:
我不确定为什么切换构建配置似乎会关闭我们的日志记录。有人能给我指点吗?
我注意到,当我使用Debug配置进行本地测试时,TraceListener.TraceEvent()能够正常触发。但当我切换到其他构建配置(例如Test)时,TraceEvent()就不再被触发了。这是我的Web .csproj文件的一部分:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;SkipPostSharp</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE;DEBUG;SkipPostSharp</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ExcludeGeneratedDebugSymbol>false</ExcludeGeneratedDebugSymbol>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Stage|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Prod|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
我不确定为什么切换构建配置似乎会关闭我们的日志记录。有人能给我指点吗?