如题
解决方案 »
- 纠结于SQL的卸载于安装啊,大侠们
- 在.net中使用memcached
- 确认删除 问题
- .net1.1转2.0后的问题
- showModalDialog的问题!
- asp.net中的hceckbox奇怪的问题
- 用(URLReWriter) url重写 在本地没有问题,但上传到虚拟服务器上出下面错误,是什么问题
- 请各位推荐一个新闻组的客户端
- 救命!!!asp.net中如何创建文件目录啊?
- IIS 经常断掉 错误出现在w3wp.exe中,求大神进来看看日志帮分析下
- 非常奇怪的问题,为什么我的网站文件夹的名字会影响DEVEXPRESS的ASPxPivotGrid控件的结果?
- 设置Require secure channel(SSL)
{ string sLogFormat = "";
string sErrorTime = "";
TStagingApp_Log_SQL _tstagingapplog = null;
public CreateLogFiles()
{
try
{
sLogFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " ==> "; sErrorTime=System.DateTime.Now.ToString("yyyyMMdd");
}
catch (Exception ex)
{
_tstagingapplog = new TStagingApp_Log_SQL();
_tstagingapplog.CreatedOn = System.DateTime.Now;
_tstagingapplog.Notes = ex.Message;
_tstagingapplog.Save();
}
} public void ErrorLog(string sPathName, string sErrMsg)
{
string path = sPathName + sErrorTime + ".txt";
string ServiceName = HttpContext.Current.Server.MachineName;
string IpAddress = HttpContext.Current.Request.UserHostAddress;
if (!File.Exists(path))
{
try
{
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("ServiceName:" + ServiceName + "\r\n" + "IPAddress:" + IpAddress + "\r\n" + sLogFormat + "\r\n" + sErrMsg);
sw.Flush();
sw.Close();
}
//StreamWriter sw = new StreamWriter(sPathName + sErrorTime + ".txt", true, System.Text.Encoding.Unicode);//when the property set false,then file data is bestrow. }
catch (Exception ex)
{
_tstagingapplog = new TStagingApp_Log_SQL();
_tstagingapplog.CreatedOn = System.DateTime.Now;
_tstagingapplog.Notes = ex.Message;
_tstagingapplog.Save();
}
}
else
{
try
{
using (StreamWriter sw = File.AppendText(path))
{
if ((File.GetAttributes(path) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
File.SetAttributes(path, FileAttributes.Normal);
sw.WriteLine("ServiceName:" + ServiceName + "\r\n" + "IPAddress:" + IpAddress + "\r\n" + sLogFormat +"\r\n"+ sErrMsg);
sw.Flush();
sw.Close();
} //StreamWriter sw = new StreamWriter(sPathName + sErrorTime + ".txt", true, System.Text.Encoding.Unicode);//when the property set false,then file data is bestrow. }
catch (Exception ex)
{
_tstagingapplog = new TStagingApp_Log_SQL();
_tstagingapplog.CreatedOn = System.DateTime.Now;
_tstagingapplog.Notes = ex.Message;
_tstagingapplog.Save();
}
}
}
}