1: First, you need to download the dll on the official website. This is not difficult: the official website is: logging. apache. orglog4net. After the download, use vs to compile and obtain log4net. dll. Introduce it into the project again and add reference. 2: add a line of code to the AssemblyInfo. cs file in the project to specify the search for Web. Co
1: first need to download dll on the official website, This is not difficult: the official website is: http://logging.apache.org/log4net/, download and use vs to compile get log4net. dll. Introduce it into the project again and add reference. 2: add a line of code to the AssemblyInfo. cs file in the project to specify the search for Web. Co
1: first need to download dll on the official website, This is not difficult: Official Website: http://logging.apache.org/log4net/, download afterUseVs compiled to obtain log4net. dll.
Introduce it againProjectProject, add reference.
2: Then setProjectAdd a line of code in the AssemblyInfo. cs file to specify the log4net configuration information in the Web. Config file:
[Assembly: log4net. Config. XmlConfigurator (ConfigFile = "Web. config", Watch = true)]
3: Start to configure the web. Config file:
Add the above Code Node.
4: Configure log4 output mode
Note: The SystemLog table here isDatabaseMust exist.
5. frontend interface call
Public partial class Index: System. Web. UI. Page
{
Private static log4net. ILog loger = log4net. logManager. getLogger (System. reflection. methodBase. getCurrentMethod (). declaringType); = log4net. logManager. getLogger (System. reflection. methodBase. getCurrentMethod (). declaringType );
Loger. Info ("TestRecordLogsToDatabase. ");
}
Note: System. Reflection. MethodBase. GetCurrentMethod (). DeclaringType indicates the callRecordLogsMethod class. For example, the above class is Index.
The above code can be written to any event.