What appears in a log entry
This section discusses programmatic control over how certain values appear in a log entry. For more general discussion about what appears in a log entry, see "Specifying the Log Entry".
timeZoneOverride
This section discusses how to programmatically control how a time value appears in a log entry. Without this override, times are expressed in the local OS time.
For example,
"execute this code in a workspace.
 
Create a transcript appender.
Override the way the timezones are displayed.
Add the appender to the root logger.
Test the logging."
 
| appender |
 
EsLogManager reset. "Clean up logging setup for the example."
appender := EsTranscriptAppender
level: EsLevel Warn
layout: (EsPatternLayout new: '%d %m').
appender setTimeZone: 'Asia/Karachi'.
EsLogManager rootLogger addAppender: appender deepCopy.
 
EsLogManager logWarn: ' Hi Mom'.
EsLogManager shutDown. "Discard any log4s state."
 
In the above example, timestamps for logging events sent to the transcript appender will be converted from the local OS time to the Asia/Karachi times zone. If the time in New York is 12:56:23, the Karachi time is 21:56:23.
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-07-19 21:56:23,275 Hi Mom
 
Last modified date: 12/20/2017