Postsharp is designed based on the. NET platform, which emphasizes the easy-to-learn and easy-to-use AOP framework and the concept of AOP. For the advantages, see:
Http://www.cnblogs.com/wayfarer/category/35983.html
Here is a brief introduction to several scenarios using postsharp for your reference.I. LogsGenerally, there are two ways to write business logs,1. Simply record the occurrence time, trigger user, and service method name of the business method.We record the traditional solution i
level of logger // (We will see the log level later) Bool isdebugenabled; Bool isinfoenabled; //... Boolean attribute corresponding to other methods } Log4netThe Framework defines a class called logmanager to manage all the logger objects. It has a static getlogger () method that uses the name parameters we provide to retrieveThe existing logger object. If this logger object does not exist in the framework, it will also create a logger object f
://www.vogella.com/tutorials/Logging/article.html3) Http://en.wikipedia.org/wiki/Java_logging_framework2. Log Environment initializationThe so-called log environment initialization, in fact, is Logmanager initialization. Through source reading, the process of Logmanager initialization is:1.1 load Logmanager through the class loaderLogmanager can be customized, an
The main classes in the Java.util.logging package are the following:Logmanager There is a single global Logmanager object that can be used to maintain a shared set of Logger and log services. Logger Logger objects are used to record log messages for a particular system or application component LogRecord LogRecord objects are used to pass log requests between the log framework and a single log Handler Handler object to get log infor
, fortunately, the advent of spring AOP will be the headache of the problem. Using spring annotations to cross-slice the facets into each service class can solve the problem of code redundancy and difficult to maintain.This figure is summarized in the code as follows:Package com.test.util; @Aspectpublic class Authorityservice {@Autowiredprivate Logmanager logmanager; @Before (" Execution (* com.test.web.*.*
Open-source project log4android Usage Details, open-source project
Let's talk about theme directly.
Log4android is an open-source android logging project similar to log4j. The project was adapted based on microlog and added various new definition methods for file output.
Project address: Click Here (https://github.com/lisicnu/Log4Android)
Usage:
0. Import the package.
The project has been released to the maven repository. You can import the package directly. The current version is 1.0.0.
Gradl
Technorati label: log4net configuration, independent log4net. config, non-embedded
Example 1:
Vs2003The created Asp.net project, the log4net file is placed in the web. config file
1. Add a reference to log4net. dll (download DLL)
2. Add in Web. config (Note the location of the peer, under the
3. Page_load in webform1.aspx. CS
Log4net. ilog logger = log4net. logmanager. getlogger (system. reflection. methodbase. getcurrentmethod ()
For a product or project, a detailed log is usually printed during testing. After the product is released, the highest level of log4j is usually set to Improve the efficiency, once a problem occurs to the customer, it is important to check the detailed log information to confirm the log printing. However, it is not good to let the customer manually modify the log4j configuration file.Modify the log4j levelPublic class log4jconfig {
Public void enableinfo (string target ){
turned out to be log4net.
According to my personal experience, many open-source projects use log4net to record logs, for example, I have encountered this problem when using a client implemented by the C # client of ibatis.net, postsharp, fastdfs, And the C # client of memcached.
Can I quickly find the cause of the same problem next time? Can we stop wasting time? Can we do something more valuable?
Or is it missing a log4net reference? Kao, Tian xiaode.
Appendix: refer to the getcurrent
First type: Global exception handling1. First class to save the exception (that is, to write the exception information to the file)C # codeCopypublic class Logmanager { private string LogFilePath = String. Empty; Public Logmanager (String logfilepath) { this.logfilepath = LogFilePath; FileInfo file = new FileInfo (LogFilePath); if (!file. Exists) {
Open-source project log4android Usage Details, log4net open-source
Let's talk about theme directly.
Log4android is an open-source android logging project similar to log4j. The project was adapted based on microlog and added various new definition methods for file output.
Project address: Click Here (https://github.com/lisicnu/Log4Android)
Usage:
0. Import the package.
The project has been released to the maven repository. You can import the package directly. The current version is 1.0.0.
Gradl
appear in the console. Therefore, to view low-level logs in the console, you need to manually overwrite the Loggermanager configuration class.Load configuration fileJava8 previous global profile in Jre/lib, moved from JAVA9 to jre/conf, but I highly recommend that you change the configuration here, I recommend that you load it separately, only for your app to take effect. Here's how springboot loads the global log profile, and I put the custom configuration file in the/resources/logging.propert
After several years of development, log4j finally ushered in its sister version, log4j 2.0. With the emphasis on reusable component development, in addition to developing a reusable log operation class from start to end, Apache provides us with a powerful log operation package-log4j. Major upgrades must bring significant features. We will explain the disruptive features of 2.0 in the future. Today we will look at one of its features, the default level.
When using log4j 1. X, we all need to provi
The 1:java SDK has its own logger profile located in the SDK home directory:
Jdk1.6.0_25\jre\lib\logging.properties
2: There are two ways to enable this log configuration
1) with Java-djava.util.logging.config.file=myfile property
Java-djava.util.logging.config.file=myfile Javaclass2 Initialize Logmanager in the program, which also applies to Web projects based on Tomcat
Logmanager
Spring injection, to put it bluntly, is to use configuration files to manage the instantiation and association between them. This is the same with the purpose of using interfaces in projects: reducing code coupling.
Interface injection and setter injection are different. For example, the parameter of the setter method is of the interface type. However, interface injection has obvious drawbacks. To allow containers to inject dependencies, all components must implement specific interfaces. Because
types of errors, such as primary/foreign key problems, data type problems, and other exceptions caused by message data errors, they should be saved to the file and logged, for manual review, and then process the following message data.So the program code alone handles errors such as the ORA-00028 (Session kill) ORA-02396 (exceed idle time) ORA-01012 (not logon) and ORA-12535 (timeout), and exits the message processing function, and re-called in the main function to re-connect to the database an
prefix of the log file.
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Public class logmanager{Private Static string logpath = string. empty;/// /// Folder for saving logs/// Public static string logpath{Get{If (logpath = string. Empty){If (system. Web. httpcontext. Current = NULL)// Windows Forms ApplicationLogpath = appdomain. currentdomain. basedirectory;Else// Web applicationLogpath = appdomain
) { Catalina.this.stop(); } } catch (Throwable ex) { log.error(sm.getString("catalina.shutdownHookFail"), ex); } finally { // If JULI is used, shut JULI down *after* the server shuts down // so log messages aren't lost LogManager logManager = LogManager.getLogManager(); if (
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.