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
能打个几分呢?
查看全文
相关阅读:
经典假设检验理论记录一二
阿里云centos7.3安装tomcat8
PowerDesigner中Name与Code同步的问题
PowerDesigner中NAME和COMMENT的互相转换
树形结构的数据库表设计
Spring mybatis Access denied for user 'root'@'localhost' (using password:YES)
IOS上架审核问题
maven自动部署war包到tomcat 问题
SpringMVC +Hibernate JPA+Spring-data-jpa
Hibernate4.3.x Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
原文地址:https://www.cnblogs.com/xuzhong/p/362813.html
最新文章
Linux课程笔记 Day06 命令总结
模块介绍与导入
python 文件目录操作
Tomcat部署帆软服务器 浏览器标题修改
项目信息管理_添加
web自动化学习 _02 新增表单
慕课 爬虫学习 第三周 网络爬虫之实战
selenium 学习记录01
慕课 爬虫学习 第二周 网络爬虫之规则
问题记录 网页中可以选择元素,但代码却选择不到
热门文章
动态代理Ip爬取数据结合Jsoup
基于规则的分类——RIPPER算法
t分布与t检验的一点理解
探索性数据分析
数据预处理过程
开始挖掘数据前,该如何认识我们手上的数据?
数据测量与相似性分析
P类问题、NP类问题与NPC类问题
统计学中抽样调查和一些常用的方法
基于规则的分类技术
Copyright © 2011-2022 走看看