1. Use an ILog object to record logs
Var log = LogManager. GetLogger (MethodBase. GetCurrentMethod (). DeclaringType );Log. Warn ("error", new Exception ("Exception! "));
Prerequisites:
1) Reference log4net. dll
2) namespace Prefix:[Assembly: log4net. Config. XmlConfigurator (Watch = true)]
3) The first node under the configuration node of App. config must be configSection, which is:
4) added under the con
desktop interaction. In this way, the service can start the document conversion program normally when running.
Key 2: A Conversion error occurs when the Conversion Program encounters a malicious file uploaded by the user, and the process is dead. This will cause a large amount of resources to be wasted and occupied by the server. To make rational use of resources, we also need to compile a Process Monitoring Service to specifically monitor the corresponding dead processes.
The Process Monitorin
Log System:The log records all the events, system initialization, status, and performance information of the ogre-based program each time it runs. The output content is stored on the disk file. The default file name is ogre. log. You can also manually display the creation log system, which needs to be implemented before the Root object is created.// Create an instance of LogManager prior to using LogManager
its attributes or methods. For example, the name, password, signin, and signout methods of the user type are all related to objects. To call these attributes and methods, you can only call them by instantiating objects, as shown below:User user = new user ();User. Name = "Bruce Zhang ";User. Password = "password ";User. signin ();User. signout ();
However, when defining a class member, we can also use the static keyword to define some class members irrelevant to the object state, such as the f
convenient configuration.
Refer to official learning documents: http://www.quartz-scheduler.net/documentation/index.html
Quickly build a Quartz and download the source code
Step 1: create a solution and related projects, and install related packages, as shown in:
Quartz depends on Common. logging and Common. logging. log4Net, and Log4Net are also familiar with log tools. Therefore, we use log4net to record logs, and the scheduled jobs are generally in the window service, we can also use Top
:
In the task management module, you can stop and enable jobs.
Introduction to three-Table Structure
BackgroundJob is the task information storage table
BackgroundJobLog is the task execution trace log table
IV. Implementation
Use the task management module to configure the project where the developed Job is located and store it in the BackgroundJob table.
Create a ManagerJob class in the Only. Jobs project and manage Job scheduling tasks.1 [DisallowConcurrentExecution] 2 public class Manag
output directory"To"Always copy"
Step 3: Call
Using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; using System. IO; using log4net; using log4net. config; namespace WHTR. demo. log4net {class Program {static void Main (string [] args) {InitLog4Net (); var logger = LogManager. getLogger (typeof (Program); logger. info ("message"); logger.
[] Conditions {get {return _ conditions;} set {_ conditions = value ;}} private NOrder [] _ orderFields; // sort public NOrder [] OrderFields {get {return _ orderFields;} set {_ orderFields = value ;}} private int pageSize = 10; public int PageSize {get {return pageSize;} set {pageSize = value ;}} private int _ recordCount; public int RecordCount {get {return _ recordCount ;} set {_ recordCount = value ;}} private int pageCount; public int PageCount {get {return pageCount ;}set {pageCount = val
7. Add log capability for presentation layer project 1. Add the following code in Web. Config: configdivsdivnamelog4nettypelog4net. Config. Log4NetConfigurationdivHandler, log4netconfigdivslog4netrootlevelvalueINFOappender-refrefLogFileAppendera
7. Add log capabilities for the presentation layer project 1. add the following code to Config: configps p name = "log4net" type = "log4net. config. log4NetConfigurationpHandler, log4net "// configps log4net root level value =" INFO "/appender-ref =" Log
Simple use of Log4net and simple use of Log4net
First, add a reference to log4net. You can download it using VS Nuget.
1. Configure the Web. config file and configure the section in configSections under the configuration node.
2. Add a log4net node under the configuration Node
When writing logs in the background:
Public ActionResult Index () {ILog log = log4net. logManager. getLogger ("RollingLogFileAp
configure the Log Level and various Appender, then, you can use LogManager to obtain an Ilog object in ILoggerRepository to write logs. The Code is as follows:
ILog GetLogger( repositoryName = (.IsNullOrEmpty(repositoryName)) LogManager.GetLogger(= = (repository != LogManager.GetLogger(repositoryName, == appSet = logLevel = hasSettings = (hasSe
. Weixin. mp sdk public platform development tutorial Index
The following code is used to explain in detail how my ASP. NET WebAPI accesses the public platform.
1. Obtain four parameters. here we can see whether the Log can output the four parameters obtained.
/// Declare the Log global variablePrivate static log4net. ILog Log = LogManager. GetLogger ("WeChatConnect ");/// Declare Token public readonly stri
Public class refreshserve: system. web. UI. page {Private Static ilog log = logmanager. getlogger (typeof (refreshserve); Private readonly string refresh_ticket_name = "_ refreshticketarray"; private readonly string hidden_field_name = "_ refreshhiddenfield "; private readonly string hidden_page_guid = "_ refreshpageguid"; //
When you need to refresh the judgment function, the new page only needs to inheri
,[Message] [varchar] (4000) not null,[Exception] [varchar] (2000) null)How to obtain publickeytoken:Use Sn-T c: \ windows \ Microsoft. NET \ framework \ v2.0.50727 \ System. Data. dll in the vs2005 Console6. The selected appender is specified for the root node. In this example, the adonetappender is selected.7. You have configured log4net at the current location. It can be directly used in our application.8. The following describes the application methods:To output logs, you must first obtain th
Define a log class in the underlying Class Library Project
Public class LogHelper{Private static log4net. ILog log = log4net. LogManager. GetLogger ("MyLogger ");Public static void Debug (string content){Log. Debug (content );
}Public static void Info (string content){Log. Info (content );
}}
Reference log4net. dll in this class library, and
Add in assemblyInfo. cs
[Assembly: log4net. Config. DOMConfigurato
Use log4net-1.2.0-beta8
1> set it in the assemblyinfo. CS file of the project... If you forget this step, you will not be able to monitor the log file.
[Assembly: log4net. config. domconfiguratorattribute (watch = true)]Or[Assembly: log4net. config. xmlconfigurator (watch = true)]
2> Add and edit the project configuration file (App. config by default). The content is as follows:
Content 1:
Or content 2 :]
(Content 2 can be directly copied for later use)
Use the f
You don't need to reference log4net. dll first.
The configuration and usage are as follows:
Configure in Web. config
The next step is to use
Private Static ilog log = logmanager. getlogger (typeof (mylog ));
Mylog is the current class name.
Then, you can log. Error (MSG), log. debug (MSG), and log. Warn (MSG) as needed.
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.