当前位置:网站首页>Nlog自定义时间
Nlog自定义时间
2022-08-02 22:25:00 【@榴莲酥】
第一步重写 TimeSource类
/// <summary>
/// 自定义时间,网关里是的标准时间,这里我修改成北京时间
/// </summary>
[TimeSource("CustomTimeZone")]
public class CustomTimeZoneTimeSource : TimeSource
{
public override DateTime Time
{
get
{
return DateTime.UtcNow.AddHours(8);//这里你可以自定义返回时间
}
}
public override DateTime FromSystemTime(DateTime systemTime)
{
return DateTime.UtcNow.AddHours(8);//这里你可以自定义返回时间
}
}
第二步,实现刚才重写的类,即可
TimeSource.Current = new CustomTimeZoneTimeSource();
GitHub Nlog自定义时间说明地址:
边栏推荐
猜你喜欢
随机推荐
threejs dynamically adjust the camera position so that the camera can see the object exactly
APT级全面免杀拿Shell
HCIP(16)
一个很少见但很有用的SQL功能
go 反射 reflect 包
Jmeter二次开发实现rsa加密
如何通过 IDEA 数据库管理工具连接 TDengine?
[论文总结] 深度学习在农业领域应用论文笔记10
CWE4.8:2022年危害最大的25种软件安全问题
【Unity】Unity开发进阶(六)UnityEvent使用与源码解析
Token、Redis实现单点登录
四、字符常量 & 字符串
[TypeScript] Deep Learning of TypeScript Classes (Part 1)
Learn more TypeScript 】 【 TypeScript modular
数字化转型巨浪拍岸,成长型企业如何“渡河”?
B站回应HR称用户是Loser:涉事面试官去年底已被劝退
Towards a General Purpose CNN for Long Range Dependencies in ND
mysql根据多字段分组——group by带两个或多个参数
同样月薪6K,为什么同事跳槽月薪翻倍,而你只涨了1000?
00 -- jieba分词