Class: Log4r::Log4jXmlFormatter
- Inherits:
-
BasicFormatter
- Object
- Formatter
- SimpleFormatter
- BasicFormatter
- Log4r::Log4jXmlFormatter
- Defined in:
- lib/log4r/formatter/log4jxmlformatter.rb
Instance Method Summary collapse
Methods inherited from BasicFormatter
Methods inherited from Formatter
Constructor Details
This class inherits a constructor from Log4r::BasicFormatter
Instance Method Details
#format(logevent) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/log4r/formatter/log4jxmlformatter.rb', line 16 def format(logevent) logger = logevent.fullname.gsub('::', '.') = (Time.now.to_f * 1000).to_i level = LNAMES[logevent.level] = format_object(logevent.data) exception = if logevent.data.kind_of? Exception file, line, method = parse_caller(logevent.tracer[0]) if logevent.tracer builder = Builder::XmlMarkup.new xml = builder.log4j :event, :logger => logger, :timestamp => , :level => level, :thread => '' do |e| e.log4j :NDC, NDC.get e.log4j :message, e.log4j :throwable, exception if exception e.log4j :locationInfo, :class => '', :method => method, :file => file, :line => line e.log4j :properties do |p| MDC.get_context.each do |key, value| p.log4j :data, :name => key, :value => value end end end xml end |