. .

st4u

ST 4U 213: Useful log4s APIs

March 30, 2012 12:23:07.457

Today's Smalltalk 4 You wraps up our look at log4s with an examination of some of the more useful API methods we've brushed over. 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:

log4s.

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 some of the useful API methods for log4s that we've brushed over in the last few screencasts. To get started, we'll add a Transcript appender to the root logger (which was set up in the ini file):


"logging apis"
logger := EsLogManager getLogger: 'root'.

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


One of the things you can do is ask a logger for all of the appenders it has:


"get all appenders"
logger allAppenders.

Which gives us this, if we inspect that line of code:

all appenders

You can also get a specific appender by name:


"get the transcript appender"
logger getAppender: 'Transcript'


If we inspect that, we'll see the following:

appender

Next we'll remove the Transcript appender. Note that we need to send the appender, not the name, as the argument. The VA 8.5 document is not clear about that:


"remove the Transcript appender"
logger removeAppender: transcriptAppender.

Now inspect the all appenders API again, and you should see:

appender

Note that we're back where we started just the appender specified in the ini file. Finally, you can remove all appenders:


"remove all"
logger removeAllAppenders.

And inspecting the all appenders api yields:

appender

And that about wraps it up for log4s. You should definitely peruse the documentation for more information

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

Enclosures:
[st4u213-iPhone.m4v ( Size: 3360554 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 212: Customizing log4s output

March 28, 2012 10:40:29.755

Today's Smalltalk 4 You looks at how you can customize the output of log4s data via the built in pattern specifiers - and the support code that you can implement to make use of it. 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:

Logging.

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 take look at customizing your logging (in log4s) via the pattern strings used when setting up a logger. First off, you should look at the documentation, where you'll find this page, explaining the various options:

logging

What we'll do today is set up some object specific logging based on the API supported by our objects. We'll create two simple classes which respond to the same method - #addOne, adding one to a counter. One will implement #printOn: (customizing #printString), the other will implement #printLog4s. To get that all to show up, we'll use the %object specifier in the log setup:


level := EsLogManager getLevel: 'All'.
pattern := EsPatternLayout new: '%date{ISO8601}: [%level]  [%object] %message:'.
transcriptAppender := EsTranscriptAppender level: level layout:  pattern.
logger addAppender: transcriptAppender.

If your object implements #printLog4s, that will get used instead of #printString. Here's what the code for Adder1 and Adder2 (the two classes) looks like:


Adder1:

printOn: stream
	super printOn: stream.
	stream nextPutAll: ' <', count printString, '>'

Adder2:

printLog4s
	^'LOGGING:  <', count printString, '>'

Now we'll execute the following:


"with logging on, go ahead and watch two different results"
adder1 := Adder1 new.
adder2 := Adder2 new.

adder1 addOne.
adder2 addOne.


And this is what we see in the Transcript:


2012-03-28 09:59:22,031: [WARN]  [an Adder1 <1>] Added one:
2012-03-28 09:59:28,937: [WARN]  [LOGGING:  <1>] Added one:


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

Enclosures:
[st4u212-iPhone.m4v ( Size: 4439160 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 211: Inspectors and Workspaces in VW

March 26, 2012 9:59:36.193

Today's Smalltalk 4 You looks at the ability to use drag/drop between inspectors and workspaces in VisualWorks (or ObjectStudio). 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:

Workspace

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:

Technorati Tags: , ,

Enclosures:
[st4u211-iPhone.m4v ( Size: 2290873 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 210: Filtering Logs by Level

March 23, 2012 9:33:19.442

Today's Smalltalk 4 You looks at filtering logging events in log4s using logging levels. 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:

Logging.

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 take a closer look at logging levels in log4s. To quote the documentation in VA Smalltalk:

The concept of levels is central to log4s. A loggingEvent will be logged by an Appender if the level of the loggingEvent is greater than or equal to the level of the Appender. Both LoggingEvents and Appenders have levels. Log4s has seven predefined levels which are implemented as EsLevel class variables.

There are 7 levels to logging - in order from the lowest (everything gets logged) to the highest (nothing gets logged), they are: All, Debug, Info, Warn, Error, Fatal, Off. So if you set the level for an appender to "Error", and then send a "Warn" level message, it will not appear in that appender's stream. For example - recall that we've set up the root logger with a file appender:


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


That will log everything to a file. Let's set up a new appender to the Transcript, but set it up at the "Error" level - meaning, it will ignore all logging events under that:


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

Now we have two appenders for the default logger - the file appender will get every logging event, while the Transcript will only see things at level "Error" and above. To demonstrate, let's send a warning event:


EsLogManager warn: 'This is a warning!'.


The File log has that, while the Transcript is blank:

Logging

Now let's send an error level event, and look again:


EsLogManager error: 'This is an Error!'.

Logging

Notice that this time, the event hit both logs - the file appender gets everything, while the Transcript appender got the higher level event only. Next time, we'll get into filtering and the print format.

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

Enclosures:
[st4u210-iPhone.m4v ( Size: 5721668 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 209: Creating a new Logger with log4s

March 21, 2012 7:53:08.913

Today's Smalltalk 4 You delves deeper into log4s, looking at how to create a new logger in code (as opposed to in the ini file). 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:

log4s.

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 create a new logger in VA Smalltalk, programmatically. Recall that the way we set up the standard (root) logger to write to a file was via the ini file for the VA image:


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


What we need to do today is create a brand new logger:


"create a new logger using the Transcript"
myLogger := EsLogManager createLogger: 'myLogger'.
level := EsLogManager getLevel: 'All'.
pattern := EsPatternLayout new: 'ڴe{ISO8601}: [%level] %message'.
transcriptAppender := EsTranscriptAppender level: level layout: pattern.
myLogger addAppender: transcriptAppender.

That creates a brand new logger using the name 'myLogger' - to use it, we now need to specify that specifically (without being specific, we get the root logger):


"use the root logger"
EsLogManager warn: 'This is a warning!'.

"use the new logger"
(EsLogManager getLogger: 'myLogger') warn: 'This is another warning!'.


The first warning goes to the file logger set up on root; the second one goes to the Transcript using the new logger.

We'll delve more into the settings and filtering options for log4s 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: , , ,

Enclosures:
[st4u209-iPhone.m4v ( Size: 4192505 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 208: Pastell - XPath Type Capabilities in Pharo

March 19, 2012 8:21:40.446

Today's Smalltalk 4 You looks at using Pastell (for XML) in Pharo Smalltalk. 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:

XML

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:

Technorati Tags: , , ,

Enclosures:
[st4u208-iPhone.m4v ( Size: 2318891 )]

posted by James Robertson

 Share Tweet This

st4u

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:

Logging.

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:


[log4s]
debugEnabled=true
quietMode=false
globalLevel=All
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:

Logging

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

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

posted by James Robertson

 Share Tweet This

st4u

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:

log4s.

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:


[log4s]
debugEnabled=true
quietMode=false
globalLevel=All
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?

Logging

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

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

posted by James Robertson

 Share Tweet This

st4u

ST 4U 205: A Pharo Launcher

March 12, 2012 11:26:33.454

Today's Smalltalk 4 You looks at the Pharo Launcher in Pharo - it works somewhat like the project launcher for VisualWorks, but it's specific to the Mac (and OS X Lion at that). You can find it in the app store. 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:

Pharo Launcher

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:

Technorati Tags: , ,

Enclosures:
[st4u205-iPhone.m4v ( Size: 4446651 )]

posted by James Robertson

 Share Tweet This

st4u

ST 4U 204: Changing the Fonts in VA Smalltalk

March 9, 2012 10:34:52.267

Today's Smalltalk 4 You looks at changing the font used across the tools in VA Smalltalk. 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:

Fonts.

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 changing the default font used across all VA Smalltalk tools. To start, notice the little Aa icon at the far right of the toolbar:

Fonts

Open that, and you'll get a chooser tool for fonts. Select something you would prefer - here we are picking the Impact font. Not because it's a great choice for this, but because the change will be obvious:

Fonts

After you accept the change, all the tools update. Open a few:

New Font

All of your tools now use this font.

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

Enclosures:
[st4u204-iPhone.m4v ( Size: 2166358 )]

posted by James Robertson

 Share Tweet This

Previous Next (554 total)