小编Nig*_*lis的帖子

Serilog 不记录信息日志

在我的 .NET Core 2.1 项目中,我安装了Serilog,但由于某种原因它不会记录信息事件。但它会记录错误事件。

在我的应用程序设置中,我有:

    "Serilog": {
        "MinimumLevel": {
          "Default": "Information",
          "Override": {
            "Microsoft": "Fatal",
            "System": "Fatal"
          }
        },
        "WriteTo": [
          {
            "Name": "File",
            "Args": {
              "restrictedToMinimumLevel": "Information",
              "path": "D:\\Web\\098_VDSNet4\\Logs\\API.AdminPortal\\.txt",
              "rollingInterval": "Day"
            }
          }
        ]
      }
Run Code Online (Sandbox Code Playgroud)

在我的 Startup.cs 中我有:

                Log.Logger = new LoggerConfiguration()
                    .MinimumLevel.Verbose()
                    .ReadFrom.Configuration(Configuration)
                    .CreateLogger();

                services.AddLogging(logging =>
                    logging.AddSerilog(dispose: true)
                );
Run Code Online (Sandbox Code Playgroud)

在我的代码中有:

            public IActionResult Post(Address address)
            {
                string functionName = "AddressController:Post";

                try
                {
                    logger.LogInformation($"{functionName}");

                    // TOOD Additional Address validation
                    addressRepository.Add(address);
                    addressRepository.Save();

                    return Ok(address);
                }
                catch(Exception ex)
                { …
Run Code Online (Sandbox Code Playgroud)

c# serilog asp.net-core asp.net-core-2.1

5
推荐指数
1
解决办法
2万
查看次数

C#Linq to Entities:join子句中某个表达式的类型不正确.类型推断失败

我正在尝试使用C#linq连接两个表到实体.

一个表有客户端,另一个表有许可证.这些表由Client_ID和ClientLicence_ClientID连接.由于某种原因(它们不是我的表),Client_ID是一个i​​nt,而ClientLicence_ClientID是一个字符串.

我的代码是:

var licences = (from client in entities.Clients
                            join licence in entities.ClientLicences
                            on new { clientId = SqlFunctions.StringConvert((double)client.Client_ID) } equals
                            new { licence.ClientLicence_ClientID }
                            into clientGroup
                            where (filter.clientId == 0 || client.Client_ID == filter.clientId)
                            select licence);
Run Code Online (Sandbox Code Playgroud)

当我尝试编译它时,我得到一个错误:join子句中的一个表达式的类型是不正确的.在对"GroupJoin"的调用中类型推断失败.

如果我注释掉where语句那么它可以工作(尽管没有过滤结果).

filter变量是传递给函数的类.它只有一个属性:int clientId.

c# linq inference join where

4
推荐指数
1
解决办法
2861
查看次数

标签 统计

c# ×2

asp.net-core ×1

asp.net-core-2.1 ×1

inference ×1

join ×1

linq ×1

serilog ×1

where ×1