One thing to remember if you layout your logging structure with log4s:
-> use one section for each new logger
[zmqlog] createLogger=(zmqlog) [zmqstat] createLogger=(zmqstat)
-> keep in mind, that you can only define ONE appender-definition per appender-key.
Therefore this is allowed:
[zmqlog] createLogger=(zmqlog) dailyRollingFileAppender =(LogFileAppender, zmqlog, .\zmqlog.log, true, All, EsPatternLayout, '%m', false, topOfDay ) mskReverseLineAppender=(revMemAppenderLog,zmqlog,Info,EsPatternLayout,'%m',300,500)
and this is not allowed (because one has used two times the key ‘dailyRollingFileAppender’. Actually only the second definition is executed. The first one is lost.
[zmqlog] createLogger=(zmqlog) dailyRollingFileAppender =(LogFileAppenderA, zmqlog, .\zmqlog.log, true, All, EsPatternLayout, '%m', false, topOfDay ) dailyRollingFileAppender =(LogFileAppenderB, zmqlog, .\zmqlog-backup.log, true, All, EsPatternLayout, '%m', false, topOfDay ) mskReverseLineAppender=(revMemAppenderLog,zmqlog,Info,EsPatternLayout,'%m',300,500)
If you need the later case – then just add another section in your in-file and add the dailyRollingFileAppender in that section or define a new specific appender with your own definitions.
This is possible:
[zmqlog] createLogger=(zmqlog) dailyRollingFileAppender =(LogFileAppenderA, zmqlog, .\zmqlog.log, true, All, EsPatternLayout, '%m', false, topOfDay ) mskReverseLineAppender=(revMemAppenderLog,zmqlog,Info,EsPatternLayout,'%m',300,500) [zmqlog-helper] dailyRollingFileAppender =(LogFileAppenderB, zmqlog, .\zmqlog-backup.log, true, All, EsPatternLayout, '%m', false, topOfDay )
and you initialize the stuff via:
#('zmqlog' 'zmqlog-helper') do: [ :eachSectionHeader | iniContent := Dictionary new. (System iniFileGetContentsArray: eachSectionHeader) associationsDo: [:assoc | iniContent add: (Association key: assoc key value: assoc value)]. EsLogManager singleton mskInitializeFromValues: iniContent. ]
where EsLogManager>>mskInitializeFromValues: is a simple extension to the framework:
mskInitializeFromValues: iniContent self checkForNewLogger: iniContent. self checkForAsyncAppender: iniContent. self checkForTranscriptAppender: iniContent. self checkForConsoleAppender: iniContent. self checkForFileAppender: iniContent. self checkForRollingFileAppender: iniContent. self checkForDailyRollingFileAppender: iniContent. self checkForSocketAppender: iniContent. self checkForFilters: iniContent "check for filters after all the appenders have been created"
Pingback: VASmalltalk – log4s and its design failures | Schrievkrom