Write log4j logs to the database

Source: Internet
Author: User

Log4j. rootlogger = JDBC, stdout, file

Write logs to the database

Log4j. appender. JDBC. layout = org. Apache. log4j. patternlayout
Log4j.logger.org. springframework = Error
Log4j. appender. JDBC = org. Apache. log4j. JDBC. jdbcappender
Log4j. appender. JDBC. Driver = net. SourceForge. jtds. JDBC. Driver
Log4j. appender. JDBC. url = JDBC \: jtds \: sqlserver \:// 127.0.0.1 \: 1433; databasename \ = dqaudit
Log4j. appender. JDBC. User = sa
Log4j. appender. JDBC. Password = 123

Log4j. appender. JDBC. SQL = insert into log (username, lg_date, lg_thread, lg_level, lg_class, lg_message) values ('% x {username}', '% d {yyyy-mm-dd hh: MM: SS} ',' % t', '% P',' % l', '% m ')

Log4j. appender. stdout = org. Apache. log4j. leleappender
Log4j. appender. stdout. Target = system. Err
Log4j. appender. stdout. layout = org. Apache. log4j. patternlayout
Log4j. appender. stdout. layout. conversionpattern = [% d {yyyy-mm-dd hh/: mm/: SS}] %-5 p % C (line/: % L) % x-% m % N

# output to the file input to the file
log4j. appender. file = org. apache. log4j. fileappender
log4j. appender. file. file = .. /logs/dqaudit. log
log4j. appender. file. layout = org. apache. log4j. patternlayout
log4j. appender. file. layout. conversionpattern = % N %-d {yyyy-mm-dd hh \: mm \: SS} % N [% P]-[thread \: % T]-[% C. % m ()] \: % m % n

Related Article

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.