September 4 training diary

Source: Internet
Author: User
Tags xml format example

1. Standard logging module in JDK
A) Why should we classify the recorded information? Applications can call the logger object to generate various levels of log messages. The logger object itself has a switch to control which levels of messages it outputs externally.
B) who will handle the messages output by the logger object? In what format?
C) What is the role of the handler object? What is the role of a formatter object?
D) All information of the logger object can be set through the configuration file. You can see how to set the configuration file through the help of logmanager.
E) You can create multiple logger objects in an application. A parent-child relationship is formed between logger Objects Based on their names, a logger object inherits the handler and level settings of the parent logger object. The Handler setting is an overlay relationship, And the level setting is an overwrite relationship.

2. Log4j logging Module
A) like the standard logging module provided in JDK, multiple log4j logger objects can be created in one application. A parent-child relationship is formed between logger Objects Based on their names.
B) appender corresponds to handler. layout corresponds to formatter. a logger object inherits the appender and level settings of the parent logger object. appender settings are overlay, while level settings are overwrite.
C) Unlike the standard logging module, the root logger object in log4j has no name and can only be obtained through the logger. getrootlogger method.
D) log levels in log4j: Debug, info, warn, error, fatal. Check the javadoc of log4j and their constant definitions can be seen in the level class. Each logger object has an output level. If it is not explicitly set, it inherits the level of the parent logger object.
E) by default, log4j does not set any appender for the root logger object. basicaggregator sets a leleappender for the root logger object and uses patternlayout. For details about the mode, refer to the help document of basicconfigurator. Configure.
F) the configuration file of log4j is more complex than the configuration file of JDK's standard logging module. You can use the properties and XML formats. View the API help documentation of the propertyconfigurator and domconfigurator classes for detailed information. Example:
Log4j. rootlogger = [level], appendername, appendername ,...
Log4j. Logger. logger_name = [level | inherited | null], appendername, appendername ,...
# For appender named appendername, set its class.
# Note: The appender name can contain dots.
Log4j. appender. appendername = fully. Qualified. Name. Of. appender. Class

# Set appender specific options.
Log4j. appender. appendername. option1 = value1
...
Log4j. appender. appendername. optionn = valuen
Log4j. appender. appendername. layout = fully. Qualified. Name. Of. layout. Class
Log4j. appender. appendername. layout. option1 = value1
....
Log4j. appender. appendername. layout. optionn = valuen

# Logger definitions:
# The Security logger inherits is level from root. However, it's output
# Will go to A1 appender defined above. It's additivity is non-cumulative.
Log4j. Logger. Security = inherit, A1
Log4j. additi.pdf. Security = false
G) read the DTD in the help document of domconfigurator to guide students to write configuration files in XML format. Configure Param under root, logger, appender, layout, appender, and layout. See the documentation in the org. Apache. log4j. xml. Examples package to see the XML format example.
H) You can store the log4j. properties and log4j. xml files in the root directory of classpath.

3. The role of commons logging.
A) Jakarta commons logging (jcl) provides a log interface that is lightweight and independent from specific log implementation tools. It provides a simple log operation abstraction for middleware/log Tool developers, allowing program developers to use different log implementation tools.
B) Call the logfactory to log object. Note that it is not a logger object.
C) commons logging will reasonably guess your favorite logging tools and then perform self-setting. You do not need to make any settings at all. You can view the help documentation to see how logfactory discovers and determines which log tool to use.

4. What is the code "the globally unique X instance object is created when class X is loaded?
Org. it315;
Class X
{
Static {x = new x ();}
Private X (){};
Public x getx {return x };
}
Even if there is only one sentence in the program, it will cause class loading:
X = NULL;
5. Knowledge
A) replace system. Out. printf ("% 1: % 2", name, age) with system. Out. Print (name + ":" + age );
B) Use eclipse to upload and download projects to CVS
C) use relative paths in Java programs.
Job:
A) The root logger object always has a level. How many levels are there in the experiment (view the output log information and the getlevel method?
B) The ancestor of a logger object can appear after it. How can this logger object inherit the level and appender of the ancestor after it appears?
C) analyze the log4j source program, study how to assemble the logger object, and analyze its (or other open-source projects) directory structure to understand how to plan the directory structure of the project for ant.
Problem:
A) How does eclipse copy the externally called jar files to a lib directory under the release program and copy the resources with directories to the corresponding directory of the release program.
B) How does CVS prevent multiple users from modifying the details of the same file.
 

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.