type

FileLogger

const class FileLogger : ActorPool

FileLogger appends Str log entries to a file. You can add a FileLogger as a Log handler:

sysLogger := FileLogger
{
  dir = scriptDir
  filename = "sys-{YYMM}.log"
}
Log.addHandler |rec| { sysLogger.writeLogRec(rec) }

See filename for specifying a datetime pattern for your log files.

constructors

make

Constructor must set dir and filename

fields

dir

Directory used to store log file(s).

filename

Log filename pattern.

onOpen

Callback called each time the file logger opens an existing or new log file.

methods

writeLogRec

Append string log message to file.

writeStr

Append string log message to file.

Slot Details

dir

const File dir

Directory used to store log file(s).

filename

const Str filename

Log filename pattern. The name may contain a pattern between {} using the pattern format of DateTime.toLocale. For example to maintain a log file per month, use a filename such as "mylog-{YYYY-MM}.log".

make

new make(|This|? f := null)

Constructor must set dir and filename

onOpen

const |OutStream|? onOpen

Callback called each time the file logger opens an existing or new log file. Callback should write any header information to the given output stream. The callback will occur on the logger's actor, so take care not incur additional actor messaging.

writeLogRec

Void writeLogRec(LogRec rec)

Append string log message to file.

writeStr

Void writeStr(Str msg)

Append string log message to file.