LogManager to manage all logger objects. It has a static GetLogger () method that uses the name parameters we provide to retrieve existing Logger objects. If this Logger object does not exist in the framework, it will also create a Logger object for us. The Code is as follows:Log4net. ILog log = log4net. LogManager. GetLogge
some parameters.
(3) The
Then, by calling the LogManager. GetLogger ("testAPP. Logging") function, you can retrieve logs with this name. If LogManager. GetLogger (...) If the log object is not a predefined log object, the log object inherits the attributes of the root log object. With this in mind, we can say that t
I started to access. net logs. Please give me more advice if there is anything wrong!
LLog4Net is used to record logs. It can output information during the program running to some places (files, databases, EventLog, etc.). logs are the program's black box, you can view the running process of the system through Logs to discover system problems. Log function: records the running steps and successes and failures, and records key data to analyze system problems. Log4J.L look at the log files searche
My.net
DEBUG
DEBUG
My.net. tcp
None
DEBUG
The corresponding configuration file should be:
In the preceding example, three Logger types are defined and stored in Hierarchy. The three Logger form an inheritance relationship,ChildLoggerAll attributes not defined inMedium inheritance.
Once your application obtains the ILog (that is, the logger agent) through log4net. LogManager.
Log4j This dongdong, everyone has been using, but really how many people know, why to be like that with the column. Or how many do not copy can own a log4j column. Readers can ask themselves if they can do it. In this chapter, we will analyze some important links combined with source code.
First, log4j is the place to read the configuration file.
Before answering this question, first think about how we use log4j to print the log in the program.
1. Obtain logger, such as
private static Logger Lo
JDK1.4 provides a logging package: java. util. logging, which can be used to control the log records in the program. For example, you can specify the Log Level and log location (console, file, socket, memory buffer), or create a sub-recorder, you can use the program control method to specify the content you want to record, or you can use the configuration file to specify the content without modifying the program. Compared with Log4j, Log4j is simpler and lighter. It is undoubtedly a better choic
It is too complicated to simulate HttpContext for testing-driven development on the Web.
The moq framework provides powerful simulation capabilities. However, you still need to manually simulate an HttpContext object.
For this reason, I wrote a method to complete the job. Log4Net is also used to output its working conditions.
View sourceprint?
01 ///
02 // create a context simulation object
03 // at least support required
04 // Request
05 // AppRelativeCurrentExecutionFilePath,
06 // Applicatio
exceed 1 MB, when the size of a log file exceeds 1 MB, rollingfileappender generates a new log file; (2) date. This method generates a log file every day. In this article, I will give an example based on the two rolling methods.
At the time of writing this article, log4net has been released to version 1.2.11 (the new version has not been released yet ). Available in http://logging.apache.org/log4net/Source codeYou can also directly download binaries. After downloading binaries, you can see
Namespace MyLog4net{Public static class Mylog4net{Public enum ErrorLogType{/// /// Fatal error log/// FatalLog,/// /// Error Log/// ErrorLog}
/// /// When a prompt is required, you must specify the log type, which is generally used when the system prompts you how to operate,/// This type should be used for even warning operations/// Public enum NormalLogType{/// /// Common operation log/// InfoLog,/// /// Warning log/// WarnLog,/// /// Debug log/// DebugLog}/// /// System Operation Log (info, wa
). You only need to activate the webpage and do not need the result/// /// /// Public static void notify (string URL){Backgroundworker BW = new backgroundworker (); // defines a background object.
// Define what needs to be done in the Child threadBw. dowork + = new system. componentmodel. doworkeventhandler (bw_dowork );Bw. runworkerasync (URL );
}
/// /// Run in the background: Open the webpage/// /// /// Static void bw_dowork (Object sender, system. componentmodel. doworkeventargs E){Str
) for more information about how to configure ASP. NET applications, visit
7) http://go.microsoft.com/fwlink? Linkid = 169433
8) -->
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
28)
29)
30)
31)
32)
33)
34)
35)
36) Note:
37) The test code is as follows (this is the background code of a website with only one button ):
Using system;
Using system. Collections. Generic;
Text format description
The log types that can be recorded include fatal, error, warn, info, and debug ).
Text parameter description
% M (Message): the output Log message, such as ilog. debug (...) Output Message% N (New Line): line feed% D (datetime): time when the current statement is output% R (Run time): OutputProgramNumber of milliseconds consumed from running to execution to the current statement% T (thread ID): The thread ID of the current statement is equivalent to % thread% P (prio
Http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx
* Note that "Property Export" should be compared with the previous article (2) "Property import.
Public class loggerpart{[Export]Public ilog Logger{Get {return logmanager. getlogger ("logger");} // logmanager. getlogger is a "non-MEF program" and is encapsulated
IIS7.5 migration, iis7.5 Configuration
When the Asp.net application is migrated to IIS7.5, the site reports an HTTP Error 404.0-Not Found. The process is as follows:Runtime Environment: Framework 2.0, IIS7.5, and a set of Web sites without source code. The application pool is in Classic mode by default.The URL of the error page is as follows: http: // localhost/HL2008/UI/AutoMonitor/135? Autorun = trueWhen we see this URL address, the first response is that the HttpModule is overwritten. We deco
Use of log4net in. net, and use of. netlog4net
The console application is used as an example.
First, add reference:
After installation, you can see that log4net references are added to the project:
Add the application configuration file app. config and configure log4net
Add code to Program. cs:
Static void Main (string [] args) {log4net. config. xmlConfigurator. configure (); // create a logging component instance ILog log = log4net. logManager
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.