Log4r-XMPP¶ ↑
Description¶ ↑
Log4r-XMPP adds a XMPP/Jabber outputter to Log4r.
Installation¶ ↑
$ gem install log4r-xmpp
Requirements¶ ↑
The following gems are required to use Log4r-XMPP:
-
log4r
-
xmpp4r (home.gna.org/xmpp4r)
Caveats¶ ↑
-
Do NOT include Log4r into your namespace! XMPP4r uses the generic Logger library and would become present in your namespace.
Using Log4r-XMPP¶ ↑
Requiring ‘log4r-xmpp’ will add an XMPPOutputter to Log4r. It is as simple as using any other Log4r::Outputter and can use most formatters in addition to the default.
Options:¶ ↑
:buffsize => The number of logging events to buffer before sending (default 1) :username => Sending user's XMPP/Jabber account username :password => Sending user's XMPP/Jabber account password :resource => Optional sending user's XMPP/Jabber resource (default 'Log4r') :recipients => An array of accounts to send Log4r log statements to
Example:¶ ↑
require 'log4r-xmpp' options = { :buffsize => 10, :username => 'log4r@example.com', :password => 'secret', :resource => 'Log4r', :recipients => ['recipient1@example.com', 'recipient2@example.com'] } outputter = Log4r::XMPPOutputter.new('xmpp', options) mylog = Log4r::Logger.new 'mylog' mylog.outputters = outputter mylog.debug "This is a test message sent at level DEBUG"
Using Log4r-XMPP with Log4r::YamlConfigurator¶ ↑
Requiring ‘log4r-xmpp/yamlconfigurator’ will patch Log4r::YamlConfigurator to accept an array list of recipients. Substitutions are still taken into consideration.
Example YAML:¶ ↑
--- # *** YAML2LOG4R *** log4r_config: # define all loggers ... loggers: - name : mylog level : DEBUG trace : 'false' outputters: - xmpp # define all outputters (incl. formatters) outputters: - type : XMPPOutputter name : 'xmpp' buffsize : '10' username : 'log4r@localhost' password : 'secret' resource : "#{RESOURCE}" recipients : ["user1@#{DOMAIN}", "user2@#{DOMAIN}"] formatter : date_pattern: '%y%m%d %H:%M:%S' pattern : '%d %l: %m' type : PatternFormatter
Example Loading:¶ ↑
require 'log4r-xmpp' require 'log4r-xmpp/yamlconfigurator' path = File.dirname(__FILE__) Log4r::YamlConfigurator['RESOURCE'] = 'Log4r-XMPP' Log4r::YamlConfigurator['DOMAIN'] = 'localhost' Log4r::YamlConfigurator.load_yaml_file("#{path}/log4r-xmpp.yaml") mylog = Log4r::Logger['mylog'] mylog.debug "This is a test message sent at level DEBUG"
Troubleshooting¶ ↑
XMPP4r’s logger facility logs to an internal logger named ‘xmpp4r’. Attach an outputter to view additional warning information.