Let's talk about runtime/logging library

by Jocelyn-Fiat (modified: 2014 Apr 01)

This week, I will mention quickly the Eiffel Logging library, it is mainly contributed by "ITPassion Ltd." (http://www.itpassion.com), and is now maintained by Eiffel Software.

This library addresses the need to write messages to a log file, or other kind of log supports. But each platforms has its own way to gather these messages (log files, syslog daemon, event log, ...)

The Eiffel Logging Library aims to resolve these differences by providing one interface to access them, while making sure the right platform methods are used under the hood. So that the same code runs on multiple platforms. In addition, it is possible to extend logging interface to store log message into database, or whatever mean seems fit to the developer of the application universe.

The library source code is located at

  • from EiffelStudio installation: $ISE_LIBRARY/
  • from subversion repository: https://svn.eiffel.com/eiffelstudio/trunk/Src/library/runtime/logging

It is under the licence: "Eiffel Forum v2".

The associated examples


  • from EiffelStudio: $ISE_LIBRARY/examples/runtime/logging/eventlog
  • from subversion: https://svn.eiffel.com/eiffelstudio/trunk/Src/examples/runtime/logging


  • eventlog and syslog are the same example (one for Windows eventlog, and the other for syslog daemon; but both have the same source code with different comment).
  • filelog: use the default FILE_LOG_WRITER
  • multiclass: using different logger in different class (for instance one log into stderr, and another into system.log), or the same log from different classes (thanks to once)
  • multilog: logger can write message to different output (for instance, stderr AND system.log)
  • multiplatform: demonstrate that log are written in eventlog on Windows, and syslog daemon in linux for instance)
  • multithreading: how to use logger in a concurrent system (Eiffel Thread)
  • suspend: it is possible to suspend one or all logs, and resume one or all logs.

Learn by code

system logging

test local log: LOG_LOGGING_FACILITY do create log.make log.enable_default_system_log log.write_information ("The application is starting up ...") end

file logging

test local log: LOG_LOGGING_FACILITY app_log_file_name: PATH app_file_log_writer: LOG_WRITER_FILE do create log.make log.enable_default_file_log -- by default the log file is "system.log" log.write_information ("The application is starting up ...") create app_log_file_name.make_from_string ("application.log") create app_file_log_writer app_file_log_writer.set_path (app_log_file_name) log.register_log_writer (app_file_log_writer) if app_file_log_writer.has_errors then log.enable_default_stderr_log log.write_emergency ("Cannot open log file '" + app_log_file_name.utf_8_name + "'%N") else log.write_information ("The application now uses this log file as well...%N") end end


Under "doc" subfolder :

  • Readme.1st : overview of the library structure
  • Arch_Design_and_Impl.pdf : The Architecture and Implementation documentation, in PDF format.

UPDATED 2014-march: the logging library now support unicode, please update your code to use routines based on PATH, and remove the usage of FILE_NAME.