在.net核心中找不到ILogger类

从.netframework迁移到.net核心时,此类生成,并且我在ILogger和Logtype中发现错误。 我尝试找到此类,但未找到。

namespace Namespace1
{

    public class FileLogger : ILogger
    {
        private static readonly string s_Path = "C:\\log.txt";
        public IObfuscationEngine ObfuscationEngine { get; private set; }

        public FileLogger()
        {
            this.ObfuscationEngine = new DefaultObfuscationEngine();

            Clear();
        }

        private static void Clear()
        {
            try
            {
                if (!File.Exists(s_Path))
                    File.Create(s_Path);
            }
            catch (Exception)
            {
                throw new Exception("Cannot write to file: " + s_Path);
            }

            // empty the file to avoid it growing
            System.IO.File.WriteAllText(s_Path, string.Empty);

            using (StreamWriter sw = new StreamWriter(s_Path, true))
            {
                // write many empty lines to clear the buffers
                for (int i = 0; i < 50; i++)
                {
                    sw.WriteLine("");
                }
            }
        }

        public void MethodInfo(
            LogType traceLevel,
            string traceMessage,
            [CallerMemberName] string memberName = "",
            [CallerFilePath] string sourceFilePath = "",
            [CallerLineNumber] int sourceLineNumber = 0)
        {
            using (StreamWriter sw = new StreamWriter(s_Path, true))
            {
                sw.WriteLine("{0} {1}: {2},{3}({4}) - {5}", 
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    traceLevel,
                    memberName, 
                    Path.GetFileName(sourceFilePath),
                    sourceLineNumber,
                    traceMessage);
            }
        }

        public void ErrorInfo(
            string traceMessage,
            [CallerMemberName] string memberName = "",
            [CallerFilePath] string sourceFilePath = "",
            [CallerLineNumber] int sourceLineNumber = 0)
        {
            using (StreamWriter sw = new StreamWriter(s_Path, true))
            {
                sw.WriteLine("{0} {1}: {2},{3}({4}) - {5}",
                    DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    "ERROR",
                    memberName,
                    Path.GetFileName(sourceFilePath),
                    sourceLineNumber,
                    traceMessage);
            }
        }
    }
}

第一个错误

错误CS0246找不到类型或名称空间名称“ ILogger”(您是否缺少using指令或程序集引用?)

第二次错误

错误CS0246找不到类型或名称空间名称'LogType'(是否缺少using指令或程序集引用?)

这是我通过检查每个依赖项从头开始创建的cs.proj文件。

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>

        <TargetFramework>netcoreapp3.1</TargetFramework>
        <GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
        <GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
        <GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>

        <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
        <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
        <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>

    </PropertyGroup>
    <PropertyGroup>
        <WppDefine>WPP_CGWPROXY</WppDefine>
        <WppProvider>Microsoft.Rtc.Internal.ConferencingGatewayProxy.Utilities.WppTraceHelper.tracer</WppProvider>
    </PropertyGroup>
    <ItemGroup>
      <PackageReference Include="Autofac" Version="5.2.0" />
      <PackageReference Include="Autofac.Owin" Version="5.0.1" />
      <PackageReference Include="Microsoft.AspNet.WebApi.Owin" Version="5.2.7" />
      <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
      <PackageReference Include="Microsoft.Owin" Version="4.1.0" />
      <PackageReference Include="Microsoft.RTC" Version="6.0.9297.1" />
      <PackageReference Include="Microsoft.Skype.AdvancedVoice.AzureUcmaRuntimeLib" Version="201903.21.1" />
      <PackageReference Include="Microsoft.Skype.Internal.Razzle.Management" Version="7.0.2699" />
      <PackageReference Include="Microsoft.Skype.SipStack" Version="1.0.20132.3" />
      <PackageReference Include="Microsoft.Skype.SipStackFx" Version="1.0.20133.1" />
      <PackageReference Include="Microsoft.Skype.SipStackFx.Http.Proxy" Version="1.0.19084.2" />
      <PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
      <PackageReference Include="Microsoft.WindowsAzure.SDK" Version="2.9.0" />
      <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
      <PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
      <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
      <PackageReference Include="System.Data.Common" Version="4.3.0" />
      <PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
      <PackageReference Include="System.Drawing.Common" Version="4.7.0" />
      <PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
      <PackageReference Include="System.Net.Http" Version="4.3.4" />
      <PackageReference Include="System.Net.Requests" Version="4.3.0" />
      <PackageReference Include="System.Runtime" Version="4.3.1" />
      <PackageReference Include="System.ServiceProcess.ServiceController" Version="4.7.0" />
      <PackageReference Include="System.Xml.Linq" Version="3.5.21022.801" />
      <PackageReference Include="System.Xml.ReaderWriter" Version="4.3.1" />
      <PackageReference Include="System.Xml.XDocument" Version="4.3.0" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\..\HybridEdgeCommon\HybridEdgeCommon.csproj" />
    </ItemGroup>

    <ItemGroup>
        <Reference Include="Microsoft.Rtc.Server.WebInfrastructure.dll">
            <HintPath>..\..\..\..\ExternalBins\Microsoft.Rtc.Server.WebInfrastructure.dll</HintPath>
        </Reference>
        <Reference Include="Microsoft.Rtc.Server.Infrastructure.dll">
            <HintPath>..\..\..\..\ExternalBins\Microsoft.Rtc.Server.Infrastructure.dll</HintPath>
        </Reference>
    </ItemGroup>

    <ItemGroup>
        <Content Include="Web.config">
            <SubType>Designer</SubType>
        </Content>
    </ItemGroup>

    <ItemGroup>
        <Content Include="config.json" />
    </ItemGroup>
    <ItemGroup>
        <Compile Include="Properties\AssemblyInfo.cs" />
        <Compile Include="Services\HttpConfiguration.cs" />
        <Compile Include="Services\SipManagerFactory.cs" />
        <Compile Include="SIP\SipManager.cs" />
        <Compile Include="Utilities\CgwHttpClient.cs" />
        <Compile Include="Utilities\Configuration\ServiceConfiguration.cs" />
        <Compile Include="Utilities\Constants.cs" />
        <Compile Include="Utilities\HealthProbe.cs" />
        <Compile Include="Utilities\Configuration\Configuration.cs" />
        <Compile Include="Utilities\Logging\EventSourceListener.cs" />
        <Compile Include="Utilities\Logging\HttpLoggingHandler.cs" />
        <Compile Include="Utilities\Logging\ObfuscationManager.cs" />
        <Compile Include="Utilities\TargetedRouting.cs" />
        <Compile Include="Utilities\UnityConfiguration.cs" />
    </ItemGroup>
</Project>
评论