zoukankan
html css js c++ java
[CSharp]向日志中写日志的代码,这样的代码能给打几分呢?
WriteAppEventLog.cs
/**/
/*
*******************************************************************
created: 2006/03/30
created: 30:3:2006 15:42
file ext: cs
author: xuzhong
purpose: 实现向应用程序日志中写日志
********************************************************************
*/
using
System;
namespace
XZSoftware.App.ZhengJun
{
public
class
WriteEventLog
{
public
WriteEventLog()
{
}
public
static
int
Main(
string
[] args)
{
int
argsLength
=
args.Length;
if
( argsLength
!=
4
)
{
Purging();
return
1
;
}
else
{
string
source
=
args[
0
];
string
message
=
args[
1
];
string
type
=
args[
2
];
string
id
=
args[
3
];
try
{
System.Diagnostics.EventLog.WriteEntry(
source , message , GetEventType(type) ,
int
.Parse(id) );
return
0
;
}
catch
{
return
-
1
;
}
}
}
public
static
System.Diagnostics.EventLogEntryType GetEventType(
string
type )
{
switch
( type.ToLower())
{
case
"
error
"
:
return
System.Diagnostics.EventLogEntryType.Error;
case
"
warning
"
:
return
System.Diagnostics.EventLogEntryType.Warning;
case
"
failureaudit
"
:
return
System.Diagnostics.EventLogEntryType.FailureAudit;
case
"
information
"
:
return
System.Diagnostics.EventLogEntryType.Information;
case
"
successaudit
"
:
return
System.Diagnostics.EventLogEntryType.SuccessAudit;
default
:
return
System.Diagnostics.EventLogEntryType.Error;
}
}
public
static
void
Purging()
{
Console.WriteLine(
""
);
Console.WriteLine(
""
);
Console.WriteLine(
"
********************************************************************
"
);
Console.WriteLine(
"
created: 2006/03/30
"
);
Console.WriteLine(
"
created: 30:3:2006 15:42
"
);
Console.WriteLine(
"
file ext: cs
"
);
Console.WriteLine(
"
author: xuzhong
"
);
Console.WriteLine(
"
"
);
Console.WriteLine(
"
purpose: 实现向应用程序日志中写日志
"
);
Console.WriteLine(
"
*********************************************************************
"
);
Console.WriteLine(
""
);
Console.WriteLine(
""
);
Console.WriteLine(
"
WriteAppEventLog.exe <source> <message> <type> <id>
"
);
Console.WriteLine(
"
source : 源
"
);
Console.WriteLine(
"
message : 内容信息
"
);
Console.WriteLine(
"
type : 日志类型 ( Error | Warning | Information | SuccessAudit | FailureAudit )
"
);
Console.WriteLine(
"
id : 标识错误的ID
"
);
Console.WriteLine(
""
);
Console.Write (
"
Sample :
"
);
Console.WriteLine(
"
WriteAppEventLog.exe \
"
My_Application\
"
\
"
This
is
a test.\
"
\
"
Error\
"
\
"
1000
\
""
);
}
}
}
build.bat
csc
/
t:exe
*
.cs
能打个几分呢?
查看全文
相关阅读:
spring mvc velocity多视图
ubuntu 的远程桌面
nhibernate 3.3 linq扩展
MongoDB资料汇总专题[转发]
SQLServer 2008 删除、压缩日志
VS2012和2010 设置framework版本
引用的程序集 没有强名称
Xamarin for OSX – SetUp
Xamarin devexpress datagrid 样式
Xamarin devexpress Grid
原文地址:https://www.cnblogs.com/xuzhong/p/362813.html
最新文章
2018/11/23 20:57:55 螺纹钢
2018/11/22 20:02:43 螺纹钢
2018/11/21 20:31:21 螺纹钢
2018/11/20 21:50:39
2018/11/19 20:14:22
2018/11/15 19:53:42 夜盘
2018/11/14 20:41:41 夜盘
2018/11/13 23:17:25
2018/11/12 21:49:54
2018/11/9 21:50:45
热门文章
关于仁和智的理解
赵氏孤儿-简化版
不以物乱官、不以官乱心-论手机之祸
R语言-生成序列化标签
R语言-查询向量中指定条件的数据-which
apache mxnet 深度学习神经网络小试
ionic radio控件无法点击的解决方案
R语言实战-统计分析基础-描述性统计4-psych-describe
R语言实战-统计分析基础-描述性统计3-pastecs-stat.desc
R语言实战-统计分析基础-描述性统计3-Hmisc-describe
Copyright © 2011-2022 走看看