The SPA program loads the first interface Eclipse card fix notes

Source: Internet
Author: User
Tags print format log4j

A problem has recently been encountered in the development of the SPA program project because it is in the development phase, so the project is launched directly in Eclipse.

Every time you enter the first interface, Eclipse has a long lag, and the front-end interface is not loaded, which affects development efficiency.

When you look for a problem, you find that the project on the test environment does not have this problem.

The last discovery is caused by log4j logging.

Because when entering the first interface, there will be a lot of data preprocessing, when we log4j configuration console print level is debug,

So there will be a lot of log information needed to print the Eclipse Workbench, and Eclipse is also in Dayton.

the solution is to lower the log4j console log level .

log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout== 

Detailed configuration of the log4j is attached.

Basic Configuration

#配置根Loggerlog4j. Rootlogger   =   [level]   ,  appenderName1,  appenderName2,  ... # Configuration log information Output destination Appenderlog4j.appender.appenderName  =  fully.qualified.name.of.appender.    Class  log4j.appender.appenderName.option1  =  value1 ... Log4j.appender.appenderName.optionN  =  Valuen # Configuration log Information Format (layout) log4j.appender.appenderName.layout  =  fully.qualified.name.of.layout.    Class  log4j.appender.appenderName.layout.option1  =  value1 ... Log4j.appender.appenderName.layout.optionN  =  

Where [level] is the log output levels, there are 5 levels:

FATAL      0  ERROR      3  WARN       4  INFO       6  DEBUG      

Appender for the log output destination, LOG4J provides the following types of Appender:

Org.apache.log4j.ConsoleAppender (console), Org.apache.log4j.FileAppender (file), Org.apache.log4j.DailyRollingFileAppender (daily generation of one day Log file), Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size), Org.apache.log4j.WriterAppender (sends the log information in stream format to any specified location)

Layout: Log output format, LOG4J provides the following types of layout:

 

Org.apache.log4j.HTMLLayout (layout in an HTML table), Org.apache.log4j.PatternLayout (with the flexibility to specify layout mode), Org.apache.log4j.SimpleLayout (contains log information The level and information string), Org.apache.log4j.TTCCLayout (contains information about the time, thread, category, etc.) of the log

Printing parameters: log4j Format the log information in a print format similar to the printf function in C, as follows

The   %p output priority of the message specified in the%M output code   , that is, the Debug,info,warn,error,fatal%r   output from the application boot to output the log information the number of milliseconds that the   output belongs to. Usually the full name of the class%t   output the thread name that generated the log event%n   output a carriage return newline character, the Windows platform is "/r/n", the UNIX platform is "/n"%d the   date or time of the output log point of time, the default format is ISO8601, You can also specify the format later, for example:%d{yyy MMM dd HH:mm:ss, SSS}, output similar to: October 18, 2002  22:10:28, 921  %l   

 

Here's an example.

Log4j.rootlogger = Debug, stdout, D, e### output to console # # #log4j. appender.stdout = Org.apache.log4j.ConsoleAppenderlog4j.ap Pender.stdout.Target = System.outlog4j.appender.stdout.layout = Org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern =%d{absolute}%5p%c{1}:%l-%m%n### Output to log file # # #log4j. APPENDER.D = Org.apache.log4j.dailyrollingfileappenderlog4j.appender.d.file = logs/ Log.loglog4j.appender.d.append = Truelog4j.appender.d.threshold = Debug # # Output debug level above the log log4j.appender.d.layout = Org.apache.log4j.patternlayoutlog4j.appender.d.layout.conversionpattern =%-d{yyyy-mm-dd HH:mm:ss} [%t:%r]-[%p]%m %n### Save exception information to a separate file # # #log4j. APPENDER.D = Org.apache.log4j.dailyrollingfileappenderlog4j.appender.d.file = logs/ Error.log # # Exception Log filename log4j.appender.d.append = Truelog4j.appender.d.threshold = error # # Output only logs above the error level!!! Log4j.appender.d.layout = Org.apache.log4j.patternlayoutlog4j.appender.d.layout.conversionpattern =%-d{yyyy-MM-dd HH:MM:SS} [%t:%r]-[%p]%m%n 

  

The SPA program loads the first interface Eclipse card fix notes

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.