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
能打个几分呢?
查看全文
相关阅读:
设计模式--22、状态模式
设计模式--21、备忘录模式
设计模式--20、迭代器模式
关于分布式事务、两阶段提交协议、三阶提交协议
分布式系统的一致性探讨
分布式系统的BASE理论
分布式系统的CAP理论
Kafka集群环境搭建
Elasticsearch插件head的安装(有坑)
centos6 x64安装elasticsearch5.5.2启动报错
原文地址:https://www.cnblogs.com/xuzhong/p/362813.html
最新文章
解决scrapy fetch http://www.csdn.net ModuleNotFoundError No module named 'win32api'和ImportError DLL load failed找不到指定的模块
pip安装Scrapy框架报错
手动爬虫之糗事百科(ptyhon3)
MySQL DELETE
MySQL UPDATE
MySQL where
MySQL 查询数据
MySQL 插入数据
MySQL 删除数据表
MySQL 创建数据表
热门文章
MySQL 数据类型
MySQL 选择数据库
MySQL 删除数据库
junit学习之junit的基本介绍
程序员之网络安全系列
session的工作原理
重构的七宗罪
调试SPRING MVC(或者整合SSH)的时候遇到了org/objectweb/asm/Type
谈谈工厂的作用
设计模式--23、访问者模式
Copyright © 2011-2022 走看看