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
能打个几分呢?
查看全文
相关阅读:
js node 节点 原生遍历 createNodeIterator
nodejs fs copy本地文件src dst
axios 请求常用组件,及其错误
【IntelliJ IDEA学习之三】IntelliJ IDEA常用快捷键
【IntelliJ IDEA学习之二】IntelliJ IDEA常用配置
【IntelliJ IDEA学习之一】IntelliJ IDEA安装激活、VM参数
【python学习案例】python判断自身是否正在运行
【Linux脚本学习案例】shell脚本多通道并发执行存储过程
【Activiti学习之四】Activiti API(三)
【Activiti学习之三】Activiti API(二)
原文地址:https://www.cnblogs.com/xuzhong/p/362813.html
最新文章
Linux中的cron计划任务配置方法(详细)
IE WebDriver 因保护模式无法启动的解决 (转载)
python编码规范
C++通用WMI接口实现获取Windows操作系统内核版本号
探索PowerShell 【十三】WMI对象
powershell 常用命令之取磁盘分区信息
win10设置操作备忘
Powershell 函数中的CmdletBinding()是怎么回事?
Powershell同时使用可选强制参数
PowerShell-自定义函数(五)-参数互斥:ParameterSetName
热门文章
powershell 函数, foreach中格式化
Python 执行 shellcode
Python exe2shellcode,shellcode2exe
几个不错的自动化测试工具
redis blog
elastic 查询
elastic 基本操作
git push 到 github
Django 数据库模块 单独使用
python 有用的库
Copyright © 2011-2022 走看看