In log4j It can be divided into off, fatal, error, warn, info, debug, Trace, all, or your defined level. We recommend that you use only four levels of log4j. The priority ranges from high to low: error, warn, info, and debug. By defining the level here, you can control the switch to the corresponding level of log information in the application. For example, if th
Use log4j to generate logs, worry about for a long time if generated into a file inside there is very large, consider daily generated log files, the file name has the date of the day.
The solution is simple:
Log4j.appender.file=org.apache.log4j.dailyrollingfileappender#log4j. Appender.file.file=hibernate.logLog4j.appender.file.file=.. /webapps/bjjjpcdemo/logs/l
I often see this problem in the end so that the iddebugenabled attribute is not used. The problem is often debated, and the focus is often on performance. The answer is simple. Since there is this attribute, of course it is used. But you need to be careful when you use it. For example, in my code, I use the following.Java code
Log.debug ("I am There");
This example is a good practice. However, if I use the following way, I think it is unnecessary.Java code
//Not good pra
Tomcat6 default use java.util.logging to log, when embedded TOMCAT6 program use log4j, need to modify TOMCAT6 also use log4j to log, so that the external program and TOMCAT6 log can be unified. The modification method is as follows (for reference in Tomcat6 doc):1. Use ant t
# This defines the logging level for the Rootlogger. It is not required # If your are going to keep ' at debug as the ' Rootlogger by default # are at the debug Lev El. The value after the comma was the appender for the # root and we have given it the name R # Log4j.rootlogger=debug , R
## Since We to log to a database, we tell log4j that we'll use the# Jdbcappender. To complete the "configuration for
flume Installation and configuration:
Download flume, and then unpack:
Tar xvf apache-flume-1.5.2-bin.tar.gz-c./
Configure Flume, under Conf/flume-conf.properties (not created, anyway template):
# example.conf:a Single-node Flume Configuration
# Name The components on this agent
a1.sources = R1
a1.sinks = K1
a1.channels = C1
# describe/configure the source
a1.sources.r1.type = Avro A1.sources.r1.bind
= Loc Alhost
a1.sources.r1.port = 44446
# Describe the sink
a1.sinks.k1.type = Logger
# Us
This article only records the successful configuration of a tomcat and does not explain the detailed use of the log4j configuration.
This configuration generates a new log file (Debug level: Log.log) (Error level: Error.log) on a daily basis under Tomcat's Logs folder, and then modifies the name of the previous day's log file Log.log and Error.log to Log.log_ Yyy
The log recorder (Logger) is the core component of log processing. LOG4J has 5 levels of normal (level).Available level levels for the logger (Logger) (excluding custom level levels),Static level DEBUG
The debug level indicates that fine-grained informational events are useful for debugging applications.
Static level INFO
The INFO level indicates that the mess
Usually when building a Web project, we usually need to configure the log for it, in order to understand what happened during the boot process, if an error occurred during startup, it is easy to view the wrong information, but when the project is deployed to the server, the log information will take a lot of time, the boot speed will be very slow ,So how do I turn off these
When we record logs, each class will define a log object and then use this object to write logs. When we process logs, how can I record the class, method, and row number of a log object? How does log4j implement this function? In fact, we can get the current thread information when writing the Log Code, so that we can
Develop a demo when you want to output the log to the final packaged jar in the directory, from the online learning experiment after finishing the configuration as follows,Log4j.propertiesLog4j.rootlogger =Info,console,logfilelog4j.appender.console=Org.apache.log4j.ConsoleAppenderlog4j.appender.console.Threshold=INFOlog4j.appender.console.ImmediateFlush=trueLog4j.appender.console.Target=System.outlog4j.appender.console.layout=Org.apache.log4j.PatternL
For task requirements, the output log needs to be saved as file name + date format.
The workaround is simple:
Log4j.appender.file=org.apache.log4j.dailyrollingfileappender#log4j. Appender.file.file=hibernate.logLog4j.appender.file.file=. /logs/Log_Log4j.appender.file.datepattern=yyyy-mm-dd '. txt ' #后缀可为. txt/. Log/. HTML, etc.Log4j.appender.file.layout=org.apa
Configuration of log4j
The specific configuration of the log4j log file is described separately because its configuration will directly determine how the log is generated, where it is stored, and how it is exported.
Establish log4j.properties under/src. The contents are as follows:
# here defines the
Brief introduction:LOG4J is an Apache open source project, through the use of log4j, we can control the log information delivery destination is the console, files, GUI components, even the socket server, NT Event recorder, UNIX syslog daemon, etc. We can also control the output format of each log, and by defining the level of each
then make a corresponding configuration in log4j.properties. Don't forget to use different logger for different logs (such as the output to Test1.log using Logger1. info ("abc")).
Another problem is that these custom logs are output to the log that Log4j.rootlogger is configured by default, and how they can only be exported to their own specified log. Don't wo
Due to the activation of the Timer refresh program, a large number of logs are made in the Catalina.out configuration file, which makes the program difficult to debug. The log cannot be viewed properly. Therefore, the customer requests that the performance traffic configuration log be migrated out of the Catalina.out directory. After modifying the log4j conf
Log4j log output garbled characters in Linux-general Linux technology-Linux programming and kernel information. For details, refer to the following section. Currently, log4j is very popular. in the Windows system, garbled characters are not encountered. But recently, garbled characters have been encountered in the LINUX environment. in xml (I am using a configura
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.