Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
szjay
WinFramework
提交
264b5305
W
WinFramework
项目概览
szjay
/
WinFramework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
WinFramework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
264b5305
编写于
7月 11, 2020
作者:
S
szjay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
No commit message
No commit message
上级
276de1e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
120 addition
and
0 deletion
+120
-0
Log/Log.csproj
Log/Log.csproj
+1
-0
Log/Log.csproj.user
Log/Log.csproj.user
+6
-0
Log/SysLogger.cs
Log/SysLogger.cs
+113
-0
未找到文件。
Log/Log.csproj
浏览文件 @
264b5305
...
...
@@ -69,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile
Include=
"HourlyLogger.cs"
/>
<Compile
Include=
"SysLogger.cs"
/>
<Compile
Include=
"VersionException.cs"
/>
<Compile
Include=
"ServiceException.cs"
/>
<Compile
Include=
"SystemLogger.cs"
/>
...
...
Log/Log.csproj.user
0 → 100644
浏览文件 @
264b5305
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<ProjectView>
ProjectFiles
</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
Log/SysLogger.cs
0 → 100644
浏览文件 @
264b5305
//==============================================================
// 版权所有:深圳杰文科技
// 文件名:SystemLogger.cs
// 版本:V1.0
// 创建者:Jay ( QQ: 85363208 )
// 创建时间:2017-11-28 16:18
// 创建描述:
// 修改者:
// 修改时间:
// 修改说明:
//==============================================================
using
System
;
using
System.Configuration
;
using
System.Diagnostics
;
using
System.IO
;
using
System.ServiceModel
;
using
System.ServiceModel.Channels
;
namespace
Infrastructure.Log
{
public
class
SysLogger
{
//public static readonly SystemLogger Instance = new SystemLogger();
private
static
readonly
Logger
_Logger
=
null
;
public
static
string
LogPath
=
""
;
public
static
bool
IsDebug
=
false
;
public
static
bool
IsDaily
=
false
;
static
SysLogger
()
{
if
(!
Directory
.
Exists
(
LogPath
))
{
LogPath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Log"
);
if
(!
Directory
.
Exists
(
LogPath
))
{
Directory
.
CreateDirectory
(
LogPath
);
}
}
if
(
IsDaily
)
{
_Logger
=
new
DailyLogger
(
LogPath
,
"DailyLogger"
);
}
else
{
_Logger
=
new
HourlyLogger
(
LogPath
,
"HourlyLog"
);
}
}
public
static
void
WriteAction
(
string
id
,
string
action
)
{
RealWrite
(
id
,
action
);
}
public
static
void
WriteSql
(
string
id
,
string
sql
)
{
RealWrite
(
id
,
sql
);
}
public
static
void
WriteError
(
Exception
error
)
{
WriteError
(
"ERROR"
,
error
);
}
public
static
void
WriteError
(
string
id
,
Exception
error
)
{
Exception
ex
=
error
.
InnerException
??
error
;
string
content
=
string
.
Format
(
"{0}:{1}\r\n{2}"
,
ex
.
GetType
(),
ex
.
Message
,
ex
.
StackTrace
);
RealWrite
(
id
,
content
);
}
public
static
void
Write
(
string
msg
)
{
RealWrite
(
""
,
msg
);
}
public
static
void
Write
(
string
id
,
string
msg
)
{
RealWrite
(
id
,
msg
);
}
private
static
void
RealWrite
(
string
id
,
string
msg
)
{
msg
=
string
.
Format
(
"【{0}({1})】{2}"
,
DateTime
.
Now
.
ToString
(
"HH:mm:ss.fff"
),
id
,
msg
);
if
(
IsDebug
)
{
Debug
.
WriteLine
(
msg
);
}
else
{
Console
.
WriteLine
(
msg
);
}
_Logger
.
Write
(
msg
);
}
public
void
Close
()
{
if
(
_Logger
!=
null
)
{
_Logger
.
Close
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录