FileLog – library MetaTrader 4

FileLog is a simple MQL4 class for flexible logging to files and the terminal console.

Github Repository:

Log File will be saved in:

  • <Data folder>\MQL4\Files\
  • <Data folder>\tester\files\

Usage

CFileLog* logger = new CFileLog("example.log",WARNING,true);

logger.Error(StringFormat("%s %d %s",__FILE__, __LINE__, "Something unexpected happen"));
logger.Info(StringFormat("%s %d %s",__FILE__, __LINE__, "Calculation Done));
logger.debug(StringFormat("%s %d The result of %s is %d",__FILE__, __LINE__,string1, value1));

Don’t forget at the end of your EA/Indicator/Script:

Delete logger;

Log levels:

  • TRACE
  • DEBUG
  • INFO
  • WARNING
  • ERROR
  • CRITICAL

Log functions:

  • Trace()
  • Debug()
  • Info()
  • Warning()
  • Error()
  • Critical()

Example

A working example of the logger in action can be seen in FileLogExample.mq4.

Console:

File:

📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks