Log4Twitterとは?
Log4Twitter は Log4j, Logback に組み込んで使う Appender プラグインで、名前の通りメッセージを twitter に書き出すことができます。
Log4Twitter を使うと Log4j, Logback を使ったアプリケーションに手を加えることなく twitter と連携させることができます。
システム要件
OS: Java をサポートする Windows または Unix 系 OS
JVM: JDK1.4.2 以降
ログフレームワーク: Log4j1.2.x 以降 または Logback 0.9.6 以降
使い方
- クラスパスの設定
- Logger の設定
- オプション設定
log4twitter-1.0.jar をアプリケーションのクラスパスに通します。
利用しているログフレームワークと同じ階層のクラスローダで読み込まれるようにしてください。
ログフレームワークの設定ファイルを書き換えて、Log4Twitter を有効にします。
Log4Twitter の Appender クラスは "log4twitter.FRAMEWORK.TwitterAppender" です。
・Logback 用の最小限の設定
<configuration> <appender name="twitter" class="log4twitter.logback.TwitterAppender"> <id>YOUR_TWITTER_ID</id> <password>YOUR_TWITTER_PASSWORD</password> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>%msg%n</pattern> </layout> </appender> <root> <level value="debug" /> <appender-ref ref="twitter" /> </root> </configuration>・Log4j 用の最小限の設定
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <appender name="twitter" class="log4twitter.log4j.TwitterAppender" > <param name="id" value="YOUR_TWITTER_ID"/> <param name="password" value="YOUR_TWITTER_PASSWORD"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%m%n"/> </layout> </appender> <root> <level value="DEBUG"/> <appender-ref ref="twitter"/> </root> </log4j:configuration>これで準備は完了です。通常通りアプリケーションを稼働させてください。
オプション名 | デフォルト値 | 必須 | 説明 |
---|---|---|---|
id | N/A | yes | twitterのid |
password | N/A | yes | twitterのパスワード |
async | true | no | true だとメッセージを非同期で書き出す(推奨) |
include | N/A | no | 書き出し対象の正規表現ポジティブフィルタ。この正規表現にマッチしないログは Twitter に送られません。 |
exclude | N/A | no | 書き出し非対象の正規表現ネガティブフィルタ。この正規表現にマッチするログは Twitter に送られません。 |
retryCount | 0 | no | リトライ回数 |
retryIntervalSecs | 10 | no | リトライ間隔(秒) |
subscribers | N/A | no | ダイレクトメッセージ受信者(カンマ区切り) |
メーリングリスト
Twitter4J に関する質問、バグレポート、リクエストなどありましたら以下のメーリングリストにお気軽にどうぞ。
![]() |
Log4Twitter Jに参加 |
このグループにアクセス |
Jira へ
ライセンス
Log4Twitter は BSD ライセンスに基づいてリリースされています。Log4Twitter にバンドルされている Apache Commons Codec は Apache Software License に基づいています。
Log4Twitter にバンドルされている Apache Log4j は Apache Software License に基づいています。
Log4Twitter にバンドルされている Logback は GNU Lesser General Public License に基づいています。
Copyright (c) 2007, Yusuke Yamamoto All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Yusuke Yamamoto nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
価格
Log4Twitter はどなたでも商標、非商用にかかわらず無償でご利用いただけます。もし Log4Twitter があなたの生活を豊かにしてくれると感じたならば、以下の PayPal バッジから寄付していただくことも可能です。
変更履歴
- バージョン 1.0.1 リトライオプション(回数、間隔)を追加
- バージョン 1.0.0 初期バージョンリリース
ダイレクトメッセージで送るオプションを追加
Todo
- Log4Twiter4Log4net
- URL を短縮するオプションを追加する
- もうすこしキレイなロゴ