Log4j. rootlogger = info, stdout, R # Configure the root logger. info indicates the logger level (including off, fatal, error, warn, info, debug, and all ). # Or a Custom Level. We recommend that you use only four levels of log4j. The priority ranges from high to low: error, warn, info, and debug. # The level defined here, you can control the switch to the corresponding level of log information in the application. For example, info is defined here. # No. logs of all debug levels in the application will not be printed if they are equal to or higher than this level. #) Stdout and R are the places where the log files are to be output. They can have multiple names that are customized. Log4j. appender. stdout = org. Apache. log4j. leleappender # Define org. Apache. log4j. leleappender for the above stdout to output the log information to the console. # Log4j provides the following appender types: # Org. Apache. log4j. leleappender (console ), # Org. Apache. log4j. fileappender (file ), # Org. Apache. log4j. dailyrollingfileappender (a log file is generated every day ), # Org. Apache. log4j. rollingfileappender (a new file is generated when the file size reaches the specified size ), # Org. Apache. log4j. writerappender (send log information to any specified place in stream format) Log4j. appender. stdout. layout = org. Apache. log4j. patternlayout # Log4j provides the following layout types: # Org. Apache. log4j. htmllayout (in the form of HTML tables ), # Org. Apache. log4j. patternlayout (you can flexibly specify the layout mode ), # Org. Apache. log4j. simplelayout (including the log information level and information string ), # Org. Apache. log4j. ttcclayout (including the log generation time, thread, category, and other information) # Log4j. appender. stdout. layout. conversionpattern = [QC] % P [% T] % C. % m (% L) | % m % N Log4j. appender. r = org. Apache. log4j. dailyrollingfileappender Log4j. appender. R. File = logs. Log # Specify the log file output path (logs. log is under the project directory) Log4j. appender. R. layout = org. Apache. log4j. patternlayout # You can use log4j. appender. R. maxfilesize = 100kb to set the file size, or use # log4j. appender. R. maxbackupindex = 1 to save a backup file. Log4j. appender. R. layout. conversionpattern = % d-[ts] % P % T % C-% m % N # Formatting log information # Log4j uses a printing format similar to the printf function in C language to format log information. The print parameters are as follows: # % M output the specified message in the code # % P output priority, namely debug, info, warn, error, fatal # % R the number of milliseconds it takes to output the log information from application startup to output # % C output category, usually the full name of the class # % T name of the thread that outputs the log event # % N output a carriage return line 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 is similar to: October 18, 2002 22:10:28, 921 # % L location of log event output, including category name, thread, and number of lines in the code. Log4j. Logger. log4j = warn # Set the level of all classes in the log4j package to warn. |