Configuration of. log4j (full set of functions such as output to console, file, rollback file, send log mail, output to database log table, and custom tag)

Source: Internet
Author: User

The simple configuration of log4j makes log4j more and more applications: the log4j configuration file provides a full set of functions such as output to the console, files, rollback files, sending log emails, output to database log tables, and custom tags. Log4j is enough if you choose one or two of them. rootlogger = debug, console, A1, Im log4j.addivity.org. apache = true # apply to log4j on the console. 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 the file 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 # use this layout for logfactor 5 Analysis # 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 # 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 log4j. appender. mail = org.apache.log4j.net. smtpappender log4j. appender. mail. threshold = fatal log4j. appender. mail. buffersize = 10 log4j. appender. mail. from = web@www.wuset.com log4j. appender. mail. smtphost = www.wusetu.com log4j. appender. mail. subject = log4j message log4j. appender. mail. to = web@www.wusetu.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 # used for database log4j. appender. database = org. apache. log4j. JDBC. jdbcappender log4j. appender. database. url = JDBC: mysql: // localhost: 3306/test log4j. appender. database. driver = com. mySQL. JDBC. driver log4j. appender. database. user = root log4j. appender. database. password = log4j. appender. database. SQL = insert into log4j (Message) values ('[framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % n') log4j. appender. database. layout = org. apache. log4j. patternlayout log4j. appender. database. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % N 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 # customize the 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

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.