Alibabacloud.com offers a wide variety of articles about spring log4j configuration example, easily find your spring log4j configuration example information here online.
Log4j It consists of three important components: log information priority, log information output destination, and log information output format. The priority of log information ranges from high to low. Error , Warn , Info , Debug To specify the importance of the log information. The log output destination specifies whether the log will be printed to the console or a file. The output format controls the display of the log information. 1, D
I have said before about the major use of Java Log Tracking framework, also said, in fact, in which log4j plays a very important role. At present, most of the framework is also the use of log4j, although it has stopped the update, the author also re-logback the project, but Logback currently in the domestic use is quite small. Most of the current projects still use log4
location where the output log event occurs, including the class name, the thread that occurred, and the number of lines in the code.
log4j.appender.console.layout.conversionpattern=%-4r[%t]%-5p%c%l%x-%m%n
# The following defines the output format of the log file on the hard disk when the specified size is reached
Log4j.appender.file.layout=org.apache.log4j.patternlayout
log4j.appender.file.layout.conversionpattern=%p-%m%l%n
Struts and Spring Framew
Original address: http://blog.csdn.net/naruto1021/article/details/7969535
When using the spring framework, we can easily configure the log4j for log management.
Before configuring, you must first download the jar package (Log4j-1.2.11.jar)
The configuration is as follows:
1. At the top of Web. XML, add the following
We know that the default logging tool in spring boot is logback, but for developers accustomed to log4j, spring boot can still be very well supported, just need to do some small configuration functions. Spring boot using log4j onl
Configure the Job Timer task class - BeanID= "Triggercalculatelecturerprofitjob"class= "Com.itzixi.quartz.job.CalculateLecturerProfitJob">Bean> Configure Jobdetail - BeanID= "Triggercalculatelecturerprofitjobmethod"class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> Propertyname= "TargetObject"> refBean= "Triggercalculatelecturerprofitjob"/> Property> the name of the method to execute Triggercalculatelecturerprofitjob
Transaction management under Spring-using AOP XML configuration management (IBatis as an example)
There are three ways to manage things under Spring: programmatic transaction management, declarative transaction management, and AOP transaction management. AOP transaction management is divided into AOP annotation transac
First, the XML configuration form1. Add a facet-oriented configuration in the spring configuration fileThe method in the slice class is executed when any method of the Com.activemq.service.impl.ConsumerServiceImpl interface implementation class is called.2. Write Slice classAttention:1) can not do the Web layer (for
Appenders configuration of log4j, log4jappenders
Because log4j was used at the beginning, many configuration items were not understood and recorded.
The following is a log4j. xml configuration file automatically generated by me wh
four levels, from high to low, respectively, for error, WARN, INFO, and DEBUG.
By the level defined here, you can control the corresponding level in the application
LogInformation on the switch. For example, where the info level is defined, all debug levels in the application
LogInformation will not be printed.
L Output Destination
Output format configuration for specific output
L Output-type
Today, I made a one-day remote log configuration. Due to the lack of documents and strategies, debugging was very difficult. Most of the items searched on the Internet are only code-based and do not describe the principles at all. Finally, the configuration is successful, and now the process is organized as follows.
Summary: socket-based remote log is composed of the server and client. The server needs to s
In the selection of slf4j-api-1.7.7.jar + slf4j-log4j12-1.7.7.jar + log4j-1.2.17.jar output (the premise is that there is a corresponding configuration file log4j. properties, put in the root directory, usually SRC folder) to the file logs. log and errors. Log
1. The basic format is as follows:
# Configure root loggerlog4j. rootlogger = [level], appendername1, a
1. Do not place log4j. properties under the root directory of classpath
When you use JUnit for local testing, the following message is displayed:
Log4j: warn no appenders cocould be found for logger (Org. springframework. Beans. Factory. Access. singletonbeanfactorylocator ).Log4j: Warn please initialize the log4j sys
file. This is often used. Correspondingly, the log output file name should be specified in the configuration file. For example, the logfile name is dglog.txt.Log4j.appender.a2.file1_dglog.txt
Replace A2 with the appender alias in the specific configuration.
4.2.3 dailyrollingappender
You can use fileappender to output log information to a file, but it is inconve
1. Do not place log4j. properties under the root directory of classpathWhen you use JUnit for local testing, the following message is displayed:
Log4j: warn no appenders cocould be found for logger (Org. springframework. Beans. Factory. Access. singletonbeanfactorylocator ).Log4j: Warn please initialize the log4j syste
the type of Simplelog, get a Logger object instance, it is easy to understand, this logger instance isSimplelog the exclusive logger for this class, then we can use the Logger object to log information.After completing the code, print the console output as follows warning:This is because we did not tell log4j where the log output was, that we did not provide a configuration file for
specified thereafter, such as:%d{yyymmm ddhh:mm:ss, SSS}, output similar: October 18, 2002 22:10:28, 921 %l Output Log event occurrence Location, including the class name, the thread that occurred, and the number of lines in the code. Example: Testlog4.main (testlog4.java:10)
2. Initializing logger in code: 1) calling Basicconfigurator.configure () in the program Method: Add a consoleappender to the root logger, the output format is set to
configuration file
LOG4J supports two types of configuration file formats:
1. XML-formatted files
2. File in properties format
You can also configure the LOG4J environment in code without using a configuration file at all. However, using a
break. For Windows, the return value is "RN", and for UNIX, the return value is "N"
### -- % D date or time of the log output time point. The default format is iso8601. You can also specify the format after it, for example, % d {yyyy Mmm dd hh: mm: SS, SSS}, output: October 18, 2002 22:10:28, 921
### -- % L location where the log event is output, equivalent to % C. % m (% F: % L) combination, including the category name, the thread that occurs, and t
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.