Skip to content

Log module

Francesco Saverio Castellano edited this page Mar 18, 2020 · 25 revisions

The Log module is based on the log4cxx library and therefore loggers can be configured in the same way and support the same functionality brought by log4cxx.

Log.init(string configPath)
Initializes the log module using the provided configuration file. This file must be a valid log4cxx\log4j configuration XML.
A default configuration can be found in the conf\ directory of TINN (the default configuration defines a log file under log/tinn.log).
The OS.init function must be called one time only in the main thread and then once initialized the library can be used accross all threads (log4cxx is thread safe).
When initialization fails (configuration file not found or wrong syntax) an exception is thrown.
The following code shows how to initialize the log module using the default configuration file:

Log.init("conf/Log4cxxConfig.xml");

 
Log.info(string text, [string logger])
Write text in the logfile with INFO log level.
If no logger name is provided then the default logger (root logger) is used and according to the default configuration the text will be logged to log/tinn.log.

Log.init("examples/Log4cxxConfig_two_logfiles.xml")

 
  info

Clone this wiki locally