惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Schneier on Security
Schneier on Security
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
罗磊的独立博客
小众软件
小众软件
H
Help Net Security
Vercel News
Vercel News
M
MIT News - Artificial intelligence
雷峰网
雷峰网
Stack Overflow Blog
Stack Overflow Blog
D
Docker
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Heimdal Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
W
WeLiveSecurity
Google DeepMind News
Google DeepMind News
B
Blog
Forbes - Security
Forbes - Security
T
Troy Hunt's Blog
月光博客
月光博客
The Cloudflare Blog
Last Week in AI
Last Week in AI
J
Java Code Geeks
Jina AI
Jina AI
TaoSecurity Blog
TaoSecurity Blog
Google Online Security Blog
Google Online Security Blog
C
Check Point Blog
PCI Perspectives
PCI Perspectives
SecWiki News
SecWiki News
P
Proofpoint News Feed
Attack and Defense Labs
Attack and Defense Labs
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Last Watchdog
The Last Watchdog
F
Full Disclosure
T
Threatpost
NISL@THU
NISL@THU
量子位
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队

博客园 - waya

解決MySQL中文亂碼 java的圖像縮略方法 攝影用光 Flex調試工具Flextracepanel linux下安裝JDK5 Installing Flex Data Services on JBoss 得到不同時區的當前時間 - waya - 博客园 Flex實現的一些小應用,截幾個界面圖留驗 一個便宜的高负载网站架构 同時啟動多個Tomcat服務器 - waya - 博客园 在同一臺機器上同時啟動多個JBOSS spring2與spring1的單例模式的配置區別 Flex的多行表頭 Trace到文件的設置 開啟整屏窗口並無痕關閉父窗口 隱藏顯示表格行;確認提示窗口;開啟定制窗口 參數URL編碼 時間字符串轉換 URL编码表一览
Log4j日志异步写入數據庫
waya · 2006-12-13 · via 博客园 - waya

把重要的log写入数据库,使其具备查询过滤的能力。同时为了不影响程序的运行速度,一般采用异步写入的形式:

log4j.appender.db=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.db.BufferSize
=20
log4j.appender.db.URL
=jdbc:hsqldb:hsql://localhost:9002/bookstore
log4j.appender.db.driver=org.hsqldb.jdbcDriver
log4j.appender.db.user
=sa
log4j.appender.db.password
=
log4j.appender.db.sql
=INSERT INTO LOG4J_LOG (LOGINID,PRIORITY,LOGDATE,CLASS,METHOD,MSG)
VALUES(
'%X{userId}','%p','%d{yyyy-MM-dd HH:mm:ss}','%C','%M','%m')


在数据库中建立任意的log, 通过sql属性指定表名和列名, BufferSize=100可以达到异步写入的效果。