. .


ST 4U 207: Using log4s in VA Smalltalk

March 16, 2012 9:41:29.250

Today's Smalltalk 4 You continues our examination fo log4s, setting up a new logging channel (called an appender in the framework). If you have trouble viewing it here in the browser, you can also navigate directly to YouTube. To watch now, click on the image below:


If you have trouble viewing that directly, you can click here to download the video directly. If you need the video in a Windows Media format, then download that here.

You can also watch it on YouTube:

Today we'll add a new logging stream (called an appender in the framework) using log4s. The same information gets logged to all streams for a given logger; we'll look at how to add new loggers in another screencast. First, recall how we specified the root level logger in the VA ini file:

dailyRollingFileAppender =(fileAppender, root, vaLog.log, false, Info, EsPatternLayout,
 'ڴe{ISO8601}: [%level] %message', true, topOfDay )

Now, if we send a logging event, as we do below, it drops out to our specified log file:

"simple log event"
EsLogManager warn: 'This is a warning, beware!'

What if we wanted another stream, on the Transcript? We could specify that in the ini file, or in code - as follows:

"Add a transcript appender programmatically"
level := EsLogManager getLevel: 'All'.
pattern := EsPatternLayout new: 'ڴe{ISO8601}: [%level] %message'.
transcriptAppender := EsTranscriptAppender level: level layout:  pattern.
logger addAppender: transcriptAppender.

Now, if we send that logging event again, it'll not only go to the file, but also to the Transcript:


We'll get into setting up new loggers in a future screencast

Need more help? There's a screencast for other topics like this which you may want to watch. Questions? Try the "Chat with James" Google gadget over in the sidebar.

Technorati Tags: , ,

[st4u207-iPhone.m4v ( Size: 3645789 )]

posted by James Robertson

 Share Tweet This