Creating Custom Loggers
This section discusses how to create a custom logger using Smalltalk code.
The logger named 'root' always exists and is the default logger. You can create your own logger if necessary.
For example,
"Create a custom logger named Vast.
Create a transcriptAppender and add it to the Vast logger.
Write a warning message to the Vast logger."
 
| transcriptAppender loggerName |
 
loggerName := 'Vast'. “someCaseSensitiveLoggerName”
EsLogManager createLogger: loggerName.
transcriptAppender := EsTranscriptAppender
level: EsLevel Warn
layout: (EsPatternLayout new: '%d %m').
(EsLogManager loggerNamed: loggerName )
addAppender: transcriptAppender.
(EsLogManager loggerNamed: loggerName) warn: 'Hi, Mom'.
The above example will result in a line in the transcript for the 'warning' message. The transcript will look something like this. The first part of the line is the date and time including the milliseconds; the second part is the warning message itself.
2017-06-07 11:57:57,028 Hi Mom
Last modified date: 12/20/2017