Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

教程中 NET微服务-日志,关于 Serilog 的示例代码不正确 #36

Open
VEmpYi opened this issue May 1, 2024 · 1 comment
Open

Comments

@VEmpYi
Copy link

VEmpYi commented May 1, 2024

在学习 使用-详细使用-日志属性 的示例代码中,第 12 行代码:

// 示例代码
Log.Information("Processed {@Count} records in {Time} ms.", new { Count = 10, Time = 123 });
// 我的输出结果
[21:27:40 INF] Processed {"Count": 10, "Time": 123} records in {Time} ms.
// 教程给定结果
Processed { Count: 10, Time: 123 } records in 0 ms.

占位符属性 {Time} 没有对应的参数,我的运行结果是直接输出了属性名而非一个值。
是由于版本不同而出现的不同结果么?

Serilog version: 3.1.1
Serilog.Sinks.Console version: 5.0.1
Visual Studio 2022 version: 17.9.6
.NET version: 8.0.4

@VEmpYi
Copy link
Author

VEmpYi commented May 1, 2024

此外,还有一项疑问。
使用-详细使用-输出到文件,第九行的注释:
//单个文件大小: 1024000 1024000是1M,我有一些不同的观点。

根据我了解到的一些知识,
基于 计算机二进制的特性,1024 的关系来说,我觉得 1 MB = 1 * 1024 * 1024 = 1,048,576 Bytes;
基于 SI(国际单位制)中的标准,1000 的关系来说,这种情况 1 MB = 1,000,000 Bytes。

是否计算错误了,还请为我解惑。谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant