Log4j configuration file-log4j. Properties

Source: Internet
Author: User

Log4j. rootlogger = debug, console, database, file
Log4j.addivity.org. Apache = true

# Apply to the console
Log4j. appender. Console = org. Apache. log4j. leleappender
Log4j. appender. Console. Threshold = info
Log4j. appender. Console. Target = system. Out
Log4j. appender. Console. Encoding = GBK
Log4j. appender. Console. layout = org. Apache. log4j. patternlayout
Log4j. appender. Console. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N

# For Databases
Log4j. appender. Database = org. Apache. log4j. JDBC. jdbcappender
Log4j. appender. database. url = JDBC: oracle: thin: @ 192.168.0.103: 1521: orcl
Log4j. appender. database. Driver = oracle. JDBC. Driver. oracledriver
Log4j. appender. database. User = Nation
Log4j. appender. database. Password = 1
Log4j. appender. Console. Threshold = warn
Log4j. appender. database. SQL = insertinto log4j (stamp, thread, infolevel, class, messages) values ('% d {yyyy-mm-dd hh: mm: SS}', '% t ', '% P',' % l', '% m ')

# Insert into log4j (Message) values ('[framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % n ')

# In the message field of the log4j table in the database, the content % d (date) % C: log information location (Class Name) % P: log information level % m: generated log information % N: line feed of output log information

Log4j. appender. database. layout = org. Apache. log4j. patternlayout
Log4j. appender. database. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N

# Create a log every day
Log4j. appender. A1 = org. Apache. log4j. dailyrollingfileappender
Log4j. appender. a1.file = C:/log4j/log
Log4j. appender. a1.encoding = GBK
Log4j. appender. a1.threshold = debug
Log4j. appender. a1.datepattern = '. 'yyyy-mm-dd
Log4j. appender. a1.layout = org. Apache. log4j. patternlayout
Log4j. appender. a1.layout. conversionpattern = % d {absolute} % 5 P % c {1 }:% L: % m % N

# Apply to files
Log4j. appender. File = org. Apache. log4j. fileappender
Log4j. appender. file. File = C:/log4j/file. Log
Log4j. appender. file. append = false
Log4j. appender. file. Encoding = GBK
Log4j. appender. file. layout = org. Apache. log4j. patternlayout
Log4j. appender. file. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N

# 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. lele_file.encoding = GBK
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

# 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 = yyflyons@163.com
Log4j. appender. Im. layout = org. Apache. log4j. patternlayout
Log4j. appender. Im. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N

# Apply to socket
Log4j. appender. Socket = org. Apache. log4j. rollingfileappender
Log4j. appender. Socket. remotehost = localhost
Log4j. appender. Socket. Port = 5001
Log4j. appender. Socket. locationinfo = true
# Set up for log facter 5
Log4j. appender. Socket. layout = org. Apache. log4j. patternlayout
Log4j. appender. socet. layout. conversionpattern = [start] % d {date} [date] % N % P [Priority] % N % x [NDC] % N % T [thread] % N % C [Category] % N % m [Message] % N
# Log Factor 5 appender
Log4j. appender. lf5_appender = org. Apache. log4j. lf5.lf5appender
Log4j. appender. lf5_appender.maxnumberofrecords = 2000

# Send Logs to emails
Log4j. appender. Mail = org.apache.log4j.net. smtpappender
Log4j. appender. Mail. Threshold = fatal
Log4j. appender. Mail. buffersize = 10
Log4j. appender. Mail. From = yyflyons@163.com
Log4j. appender. Mail. smtphost = www.wusetu.com
Log4j. appender. Mail. Subject = log4j message
Log4j. appender. Mail. To = yyflyons@126.com
Log4j. appender. Mail. layout = org. Apache. log4j. patternlayout
Log4j. appender. Mail. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N

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.