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
能打个几分呢?
查看全文
相关阅读:
工资是用来支付给责任的,责任越大,工资越高。 涨工资,是因为承担了更大的责任。
水平分库分表的关键问题及解决思路
APP多版本共存,服务端如何兼容?
ListView动态加载数据分页(使用Handler+线程和AsyncTask两种方法)
Java 并发专题 :闭锁 CountDownLatch 之一家人一起吃个饭
Java进阶 创建和销毁对象
Java OCR tesseract 图像智能字符识别技术
网页信息抓取进阶 支持Js生成数据 Jsoup的不足之处
从原理角度解析Android (Java) http 文件上传
android pop3与imap方式接收邮件(javamail)
原文地址:https://www.cnblogs.com/xuzhong/p/362813.html
最新文章
spring-session(一)揭秘
Spring Data Jpa系列教程--------实体解析和关联关系
JPA中映射关系详细说明(一对多,多对一,一对一、多对多)、@JoinColumn、mappedBy说明
Delphi绘图相关对象(TCanvas对象的方法)
让delphi2010操作界面回到delphi7模式
禁止Delphi2010检测新版本
Delphi中预编译指令
delphi 10.2 创建并使用资源文件(一共22种格式,RCDATA是自定义格式)
IIS连接数、IIS并发连接数、IIS最大并发工作线程数、应用程序池的队列长度
Disruptor
热门文章
前端框架、类库、工具
NetCore1.1+Linux
virtualenv对python
MVC底层原理
iis配置反向代理oss
System.ArgumentException: 已添加了具有相同键的项。(An item with the same key has already been added) 在 System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) 在 System.Web.Mvc.Js
极速的矩形核腐蚀和膨胀(最大值和最小值)
数据库高可用方案
Java实现视频网站的视频上传、视频转码、视频关键帧抽图, 及视频播放功能
Configure Two DataSources ---
Copyright © 2011-2022 走看看