. .


ST 4U 206: Introducing Log4s

March 14, 2012 11:01:42.253

Today's Smalltalk 4 You looks at log4s (a logging framework) in VA Smalltalk. Today we just scratch the surface; there will be more screencasts on this topic. 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 look at the logging framework that ships with VA Smalltalk - log4s (A Smalltalk port of the well known log4J package). It's already in your image, so there's no need to load it from ENVY. There are a couple of different ways to get started, but today we'll look at setting it up via the ini file. Every VA image has a corresponding (same base name) ini file - you'll want to append a new "stanza" to it. Here we are setting up a basic file logger, using the default root level logger. You can have multiple logging streams (each filtered separately) on a single logger; today we'll just look at a simple file logger. Here's the way we define that in the ini file:

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

What that sets up is a file logger off the root (technically, a new appender - each logger can have any number of appenders associated with it). When you log something, it will appear in that log file (we specified vaLog.log above). The pattern specified how the log entry appears; the VA documentation goes through in great detail how you can customize that. To log a warning, you can do something like this:

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

One caveat - the doc talks about class LogManager, while it's actually EsLogManager. The output for what we did above?


We'll get into filtering, programmatic setup and more in the future screencasts

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: , , ,

[st4u206-iPhone.m4v ( Size: 4534045 )]

posted by James Robertson

 Share Tweet This