VASmalltalk – Application specific loggers and appenders

There may be situations, where you wish to extend the log4s framework within VASmalltalk

– either by introduing new loggers (because a newly loaded application just logs to a very special logger and NOT “root”, therefore the logger should only be created when this new application gets loaded)

– or you want to add new appenders to already known loggers.

Adding these informations to the [log4s] section is not a solution, because this build the infrastructure too early and perhaps does not know about new types of appenders (see my earlier posting) or it creates a logger nobody needs, because the only application using it is not loaded at all in the IDE or IC environment.

The only way is to add new entries (with the same names as you would do it in the log4s section) in your applications ini-sections and to a partial initialization like the EsLogManager did itself.

In the following I assume, that my new application is named “MSKLog4sExample” (therefore the section name within the ini-file) and in this example I create a new logger and a new appender.

[MSKLog4sExample]
createLogger=(zmqbase)
dailyRollingFileAppender =(ESystemSubFileAppender, zmqbase, .\esystemsub.log, true, All, EsPatternLayout, '%m', false, topOfDay )

The main idea is now, that you execute a slightly changed method like EsLogManager>>readIniFile – but of course with the entries of your section.

Perhaps it would be nice, if Instantiations would refactor this logic to give the user the possibility to do what I described here.

And of course one should have support to remove loggers and appenders (based on ini-entries), if you unload a special application defining these entries. Actually the logic is the reverse work of the #readIniFile method mentioned above.

All possible, but it means lots of (boring) typing ….

Advertisement
This entry was posted in Smalltalk and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.