Comprehensive log4j Configuration

Source: Internet
Author: User

Source: http://ajava.org/blog-3431-411.html

Log4j. 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. conversi Onpattern = [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 logfa Ctor 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 // file location. You can also use the variable $ {Java. home}, rolling. loglog4j. appender. rolling_file.append = true // true: Add false: overwrite log4j. appender. rolling_file.maxfilesize = 10kb // maximum file size log4j. appender. rolling_file.maxbackupindex = 1 // Number of backups 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. log4 J. 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 = test@sina.com.cnlog4j.appender.MAIL.SMTPHost = smtp.sina.com. cnlog4j. appender. mail. subject = log4j message log4j. appender. mail. to = test@sina.com.cnlog4j.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. jdbcapp Ender 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. con Versionpattern = [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 = test@test.comlog4j.appender.im.layout = org. apache. log4j. patternlayout log4j. appender. im. layout. conversionpattern = [framework] % d-% C-%-4r [% T] %-5 p % C % x-% m % NIF ($! = Jquery) {$ = jquery. noconflict ();} var islogined = false; var cb_blogid = 94614; var cb_entryid = 2362117; var cb_blogapp = "zfc2201"; var cb_bloguserguid = "e39a08d5-3cc2-e011-8673-842b2b196315 "; vaR cb_entrycreateddate = '2017/21 23:14:00 ';
Detailed description of each configuration: http://www.cnblogs.com/rushoooooo/archive/2011/08/29/2157361.html

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.