Èý²½ÊµÏÖASP.NET 3.5ÖÐʹÓÃLog4Net
×÷Õߣº°½Ê¿Î°
Ò»¡¢ÏîÄ¿ÖÐÒýÓÃlog4net.dll
¶þ¡¢AssemblyInfo.csÖмÓÈ룺
[assembly:log4net.Config.DOMConfigurator(ConfigFile="log4net.xml", Watch=true)]
˵Ã÷£ºÖ¸Ã÷log4net.xmlÅäÖÃÎļþ
Èý¡¢´úÂëÖÐʹÓÃLog4net
using log4net;
ILog log = LogManager.GetLogger("log4net");
log.Info("It's OK!");
¸½£ºlog4net.xml £¨¼òµ¥Ê¹Óò»Ðè¸Ä¶¯£©
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="rollingFile" />
</root>
<appender name="rollingFile" type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="log.txt" />
<param name="AppendToFile" value="true" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy.MM.dd" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
<param name="Header" value=" ----------------------header-------------------------- " />
<param name="Footer" value=" ----------------------footer-------------------------- " />
</layout>
</appender>
<appender name="consoleApp" type="log4net.Appender.ConsoleAppender,log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<logger name="Log4Net.ProLog">
<level value="DEBUG" />
<appender-ref ref="rollingFile" />
<appender-ref ref="coloredConsoleApp" />
<appender-ref ref="SystemEvent" />
</logger>
</log4net>
Ïà¹ØÎĵµ£º
µÚ4Õ ASP.NETµÄÍøÒ³´úÂëÄ£Ðͼ°ÉúÃüÖÜÆÚ
´Ó±¾Õ¿ªÊ¼£¬¾Í½øÈëÁËASP.NETÓ¦ÓóÌÐò¿ª·¢µÄÊÀ½ç¡£ÔÚÁ˽âÁËC#µÄ½á¹¹£¬ÒÔ¼°ÃæÏò¶ÔÏóµÄ¸ÅÄîºó£¬¾Í¿ÉÒÔ´ÓÃæÏò¶ÔÏóµÄ˼Ï뿪·¢ASP.NETÓ¦ÓóÌÐò¡£ÔÚASP.NETÖУ¬Äܹ»Ê¹ÓÃÃæÏò¶ÔÏóµÄ˼ÏëºÍÈí¼þ¿ª·¢ÖеÄһЩ˼Ï룬ÀýÈç·â×°¡¢ÅÉÉú¡¢¼Ì³ÐÒÔ¼°¸ß¼¶µÄÉè¼ÆģʽµÈ¡£±¾ÕÂÊ×ÏȽéÉÜASP.NETÖÐ×îÖ ......
ÔÚASP.NETÖÐ,ÎÒÃÇ¿ÉÒÔÓÃÏÂÃæµÄ·½·¨ÊµÏÖ´ÓÊý¾Ý¿âÖжÁȡͼƬ²¢ÏÔʾÔÚÒ³ÃæÉÏ,·½·¨ÈçÏÂ:
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
String sql="SELECT image from append where id='" + strID + "'";
&n ......
ASP.NetÉú³É¾²Ì¬HTMLÒ³!
»·¾³:Microsoft .NET Framework SDK v1.1
OS:Windows Server 2003 ÖÐÎÄ°æ
ASP.NetÉú³É¾²Ì¬HTMLÒ³
ÔÚAspÖÐʵÏÖµÄÉú³É¾²Ì¬Ò³Óõ½µÄFileSystemObject¶ÔÏó!
ÔÚ.NetÖÐÉæ¼°´ËÀà²Ù×÷µÄÊÇSystem.IO
ÒÔÏÂÊdzÌÐò´úÂë ×¢:´Ë´úÂë·ÇÔ´´!²Î¿¼±ðÈË´úÂë
//Éú³ÉHTMLÒ³
public static bool W ......
1.¹Ø±Õ²»±ØÒªµÄSession
<%@ Page EnableSessionState="flase"%>
2.¹Ø±Õ²»±ØÒªµÄViewState
<asp:DataGrid EnableViewState="false" runat="server">
Èç¹ûÒ³Ã漶
<%@ Page EnableViewState="false"%>
3.²»ÒªÊ¹ÓÃException¿ØÖƳÌÐòÁ÷³Ì
ExceptionÊǺܺÄ×ÊÔ´µÄ
4.½ûÓÃVBºÍJScript¶¯Ì¬Êý ......
³öÏÖ´íÎó·¢ËÍEmail
¿ÉÒÔÔÚGlobal.asaxµÄvoid Application_Error(Object sender,EventArgs e)
{
//Óõ½ÁËSsytem.Net.Mail
MailMessage mail=new MailMessage();
mail.from=new MailAddress("automated@contoso.com");
mail.Subject="SIte Error at" +DateTime.Now;
mail.Body="E ......