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
能打个几分呢?
查看全文
相关阅读:
JAVA AES加密算法实现代码
JAVA BASE64 加密解密实现代码
eclipseLuna (4.4.0) 安装velocity 插件
NIO中的Buffer
Oracle死锁处理
DWR、Comet4j在Nginx+Tomcat组合下的优化
网站已运行时间代码
常用DB2命令
DB2分页查询简单示例
comet4j推送 405/500 JSON转换异常
原文地址:https://www.cnblogs.com/xuzhong/p/362813.html
最新文章
关系数据库设计
ASP.NET Web API编程——向客户端返回执行结果
MongoDB模拟多文档事务操作
Android N preview 试用
Android 防止OOM优化
android开发文档工具集(持续更新中...)
Android版本和API Level对应关系
Android性能优化篇
android应用保活机制
android应用锁之获取前台进程包名方法
热门文章
android应用锁之监听应用前后台切换方式
android产品业务逻辑对app稳定影响太大
MultiDex到底有多坑
c3p0,Druid,Tomcat Jdbc Pool,dbcp2,proxoo数据源性能比较
win7上安装多个Mysql1
mysql 快速生成百万条测试数据
JAVA抓取网页图片并下载到本地
JAVA获取相对时间,几分前、几天前、几月前
solr+solrJ facet.pivot 用法实例
JAVA RSA加密解决及数字签名实现代码
Copyright © 2011-2022 走看看