using System; using System.Web; using System.IO; namespace Common { /// summary /// ExceptionLog 的摘要说明。 /// /summary public class ExceptionLog : ApplicationException { public ExceptionLog(string message) : base(message) { Init(); Log
using System;
using System.Web;
using System.IO;
namespace Common
{
///
/// ExceptionLog 的摘要说明。
///
public class ExceptionLog : ApplicationException
{
public ExceptionLog(string message)
: base(message)
{
Init();
Log();
}
public ExceptionLog(Exception inner)
{
ex = inner;
Init();
Log();
}
public Exception ex = null;
public override string Message
{
get
{
string msg = base.Message;
if (ex != null)
{
msg = ex.Message;
}
return msg;
}
}
string username = string.Empty;
public string UserName
{
get
{
return username;
}
set
{
username = value;
}
}
string userAgent = string.Empty;
public string UserAgent
{
get
{
return userAgent;
}
set
{
userAgent = value;
}
}
string ipAddress = string.Empty;
public string IPAddress
{
get
{
return ipAddress;
}
set
{
ipAddress = value;
}
}
string httpReferrer = string.Empty;
public string HttpReferrer
{
get
{
return httpReferrer;
}
set
{
httpReferrer = value;
}
}
string httpVerb = string.Empty;
public string HttpVerb
{
get
{
return httpVerb;
}
set
{
httpVerb = value;
}
}
string httpPathAndQuery = string.Empty;
public string HttpPathAndQuery
{
get
{
return httpPathAndQuery;
}
set
{
httpPathAndQuery = value;
}
}
DateTime dateCreated;
public DateTime DateCreated
{
get
{
return dateCreated;
}
set
{
dateCreated = value;
}
}
void Init()
{
DateCreated = DateTime.Now;
if (HttpContext.Current.Request.UrlReferrer != null)
httpReferrer = HttpContext.Current.Request.UrlReferrer.ToString();
if (HttpContext.Current.Request.UserAgent != null)
userAgent = HttpContext.Current.Request.UserAgent;
if (HttpContext.Current.Request.UserHostAddress != null)
ipAddress = HttpContext.Current.Request.UserHostAddress;
try
{
if (HttpContext.Current.Request != null
&& HttpContext.Current.Request.RequestType != null)
httpVerb = HttpContext.Current.Request.RequestType;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
if (HttpContext.Current.Request != null
&& HttpContext.Current.Request.Url != null
&& HttpContext.Current.Request.Url.PathAndQuery != null)
httpPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
if (HttpContext.Current.Request != null
&& HttpContext.Current.Request.UrlReferrer != null
&& HttpContext.Current.Request.Url.PathAndQuery != null)
httpReferrer = HttpContext.Current.Request.UrlReferrer.ToString();
}
public void Log()
{
string LogName = DateTime.Now.ToShortDateString() + ".txt";
string FilePath = HttpContext.Current.Request.PhysicalApplicationPath + "//Log//" + LogName;
if (!File.Exists(FilePath))
{
using (StreamWriter sw = File.CreateText(FilePath))
{
sw.WriteLine("Fields :Value");
sw.WriteLine();
}
}
using (StreamWriter sw = File.AppendText(FilePath))
{
sw.WriteLine("======================================");
sw.WriteLine("DateTime :" + this.DateCreated);
sw.WriteLine("Message :" + this.Message);
sw.WriteLine("IPAddress :" + this.IPAddress);
sw.WriteLine("HttpReferrer :" + this.HttpReferrer);
sw.WriteLine("HttpVerb :" + this.HttpVerb);
sw.WriteLine("HttpPathAndQuery :" + this.HttpPathAndQuery);
sw.WriteLine("UserName :" + this.UserName);
sw.WriteLine("UserAgent :" + this.UserAgent);
sw.WriteLine();
}
}
}
}
//页面引用
try
{
}
catch (Exception ex)
{
throw new Common.ExceptionLog(ex);
}

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ZendStudio 13.5.1 Mac
強力な PHP 統合開発環境

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)
