Class: Log4Ruby::FileAppender
- Inherits:
-
StreamAppender
- Object
- Appender
- StreamAppender
- Log4Ruby::FileAppender
- Defined in:
- lib/log4ruby/appenders/file_appender.rb
Overview
Customizable file appender to log to a file.
Constant Summary collapse
- DATE_ROLLERS =
{:hourly => DateRollers::HOURLY, :daily => DateRollers::DAILY, :weekly => DateRollers::WEEKLY, :monthly => DateRollers::MONTHLY, :yearly => DateRollers::YEARLY}
Instance Attribute Summary
Attributes inherited from Appender
Class Method Summary collapse
-
.emit(string, log) ⇒ Object
Create the emit method that will roll using the file size as the trigger.
Instance Method Summary collapse
-
#initialize(level, options = {}) ⇒ FileAppender
constructor
New stream appender.
Methods inherited from StreamAppender
Methods inherited from Appender
#close, #closed?, #process_log
Constructor Details
#initialize(level, options = {}) ⇒ FileAppender
New stream appender.
Configuration parameters specific to rollers. dont_roll:
:truncate - if true (the default), contents of the file are deleted before logging begins.
roll_using_size:
:max_size - the maximum allowed size for a log file (in bytes - default is 102400 bytes).
roll_using_date:
:frequency - the frequency with which to roll files (:hourly, :daily, :weekly, :monthly, :yearly).
Default is :daily.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/log4ruby/appenders/file_appender.rb', line 56 def initialize(level, = {}) set_option(, :stream, nil, true) super(level, ) @directory = get_option(, :directory, false, "./") @prefix = get_option(, :prefix, true) @suffix = get_option(, :suffix, false, "log") @max_files = get_option(, :max_files, false, 5) @type = get_option(, :roll_type, false, :dont_roll) type_method = "initialize_#@type" raise ArgumentError.new("Unrecognized type '#@type'!") unless respond_to?(type_method, true) send(type_method, ) end |
Class Method Details
.emit(string, log) ⇒ Object
Create the emit method that will roll using the file size as the trigger.
110 111 112 113 |
# File 'lib/log4ruby/appenders/file_appender.rb', line 110 def self.emit(string, log) roll_using_date super end |