Script Library: 1222 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 
View scriptLicenseDownload documentation as: HTML or editable
Download scriptHistoryOther scripts by: fvzv

Documentation for: log4reb.r


How to configure logging.
------------------------


Log4reb uses a configuration file where you define the loggers, the 
appenders and the layouts. In this file, you also link one or more 
appenders to a logger. Each appender has its own layout.

REBOL [
	Title: "Properties for log4reb"
	Date: 19-Sep-2004
	Name: 'log4reb-properties
	Version: 2.0.0
	File: %log4reb.properties
	History: [
		[22-Nov-2003 "Created this file" "Francois"]
		[1-Dec-2003 "First Public Release" "Francois"]
  [19-Sep-2004 "New property file for log4reb version 2.x.x" "Francois"]
	]
]

use [ loggers appenders layouts] [
	
	; <logger name> <constructor arguments>
	loggers: make block! [
		logger1 [threshold: 'all appenders: [console-app file-app1]]
		logger2 [threshold: 'debug appenders: [file-app2 file-app3]]
		logger3 [threshold: 'info appenders: [file-app3]]
		logger4 [threshold: 'warn appenders: [file-app4 file-app5]]
		logger5 [threshold: 'error appenders: [file-app5 file-app6]]
  logger6 [threshold: 'fatal appenders: [console-app file-app1 file-app5]]
  logger7 [threshold: 'off appenders: [file-app6 file-app2 file-app4]]
	]
	
 ; <appender name> <appender type> <constructor arguments>
	appenders: make block! [
		console-app	console-appender! 	[layout: 'short]
		file-app1 	file-appender! 		[layout: 'long out: %file1.log]
		file-app2 	file-appender! 		[layout: 'long out: %file2.log]
		file-app3 	file-appender! 		[layout: 'long out: %file3.log]
		file-app4 	file-appender! 		[layout: 'long out: %file3.log]
		file-app5 	file-appender! 		[layout: 'long out: %file2.log]
		file-app6 	file-appender! 		[layout: 'long out: %file1.log]
	]
	
 ; <layout name> <layout type> <constructor arguments>
	layouts: make block! [
  short 	pattern-layout! 	[pattern: "[%c] Signe Pourcent:%% - %m."]

  long 	pattern-layout!  	[pattern: "[%c] The exact time: %d\\dd-MMM-yyyy 
  @  HH:MM:ss,SSS\\ - %p - %m."]
	]
	init-log4reb loggers appenders layouts
]