Log4j. rootlogger = debug, console, A1, Im Log4j.addivity.org. Apache = true # Apply to the console Log4j. appender. Console = org. Apache. log4j. leleappender Log4j. appender. Threshold = debug Log4j. appender. Console. Target = system. Out Log4j. appender. Console. layout = org. Apache. log4j. patternlayout Log4j. appender. Console. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N # Log4j. appender. console. layout. conversionpattern = [start] % d {date} [date] % N % P [Priority] % N % x [NDC] % N % T [thread] n % C [category] % N % m [Message] % N # Apply to files Log4j. appender. File = org. Apache. log4j. fileappender Log4j. appender. file. File = file. Log Log4j. appender. file. append = false Log4j. appender. file. layout = org. Apache. log4j. patternlayout Log4j. appender. file. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N # Used to generate files by day Log4j. appender. A1 = org. Apache. log4j. dailyrollingfileappender Log4j. appender. a1.file = samplemessages. log4j Log4j. appender. a1.datepattern = yyyymmdd-hh '. log4j' Log4j. appender. a1.layout = org. Apache. log4j. xml. xmllayout # Apply to file rollback Log4j. appender. rolling_file = org. Apache. log4j. rollingfileappender Log4j. appender. rolling_file.threshold = Error Log4j. appender. rolling_file.file = rolling. Log Log4j. appender. rolling_file.append = true Log4j. appender. rolling_file.maxfilesize = 10kb Log4j. appender. rolling_file.maxbackupindex = 1 Log4j. appender. rolling_file.layout = org. Apache. log4j. patternlayout Log4j. appender. rolling_file.layout.conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N # For Databases # Description: Database: MySQL # First create a database table (log4j) Description: # Field description # Guid serial number (auto-increment column) # Date time # Current thread # Level current level # Class current Java program/Method # Current message output Log4j. appender. Database = org. Apache. log4j. JDBC. jdbcappender Log4j. appender. database. url = JDBC: mysql: // localhost: 3306/test? Useunicode = true & characterencoding = GBK Log4j. appender. database. Driver = com. MySQL. JDBC. Driver Log4j. appender. database. User = root Log4j. appender. database. Password = Log4j. appender. database. SQL = insert into log4j (date, thread, level, class, message) values ('% d {yyyy-mm-dd hh: mm: SS}', '% t ', '% P',' % l', '% m ') Log4j. appender. database. layout = org. Apache. log4j. patternlayout Log4j. appender. database. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N # Custom appender Log4j. appender. Im = net. cybercorlin. util. Logger. appender. imappender Log4j. appender. Im. Host = mail.cybercorlin.net Log4j. appender. Im. Username = Username Log4j. appender. Im. Password = Password Log4j. appender. Im. Recipient = corlin@cybercorlin.net Log4j. appender. Im. layout = org. Apache. log4j. patternlayout Log4j. appender. Im. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N # Meaning of "% d % T % P % L % m % 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-mm-dd hh: mm: SS}, output is similar to: 17:49:27; # % T name of the thread that generates the log event; # % P the log_level of the log, such as debug, warn, Or info; # % C output category, usually the full name of the class, such as "iNotes. Default "; # % M log content; # % L location of log event output, including category name, thread, and number of lines in the code. For example, write2database. Main (write2database. Java: 33 ); # % N output a carriage return line break, which is "" on Windows and "" On Unix |