Log4mql (MT4) - MetaTrader 4 library | MT4 EA download - MetaTrader 4 resources
The message pattern will be used to format each log message. Such conversion modes can be any combination of plain text and conversion specifiers. As with log4j, a specifier is identified by its leading '%' character, which may be followed by arguments enclosed in braces '{...}', see the table below.
Example:
Any %date (and %local) fields can be annotated with date/time specification parameters.
Example: %Date{d.MMM hour:minute:sstt} output 5.5 month 1:01:00AM
The %level field can be annotated with level specification parameters. It is a comma separated list of key=value pairs according to the table below.
Example: %level{length=3, WARN=WRN, ERROR=error, FATAL=fatal} produces names: TRA, DEB, INF, WRN, error, fatal
Any schema conversion specifier can be formatted to adjust its field width and alignment. The same modifiers known from log4j apply.
Depending on the selected configuration, log files may be closed, renamed, and reopened at certain points in time, which is called file rolling. The name of the rolling (previous) log file will be derived from the configured file rolling mode, and the name of the new log file will again be derived from the log file name specifier.
File name specifier :
For specification of log file names and rolling modes, the following conversion specifiers are supported.
The counter can be controlled by its volume specification. It is a comma-separated list of key=value pairs that specify minimum, maximum, and incremental behavior.
Number files by rolling counter :
Like the log4j default rolling strategy, three file numbering schemes are supported. To illustrate how this works, assume that the min attribute is set to 1, the max attribute is set to 3, the file name is "%prgname.log", and the file name pattern is "%prgname-%i.log".
Counter behavior is "max", default:
Counter behavior set to "min": (eg %i{file index=minutes} )
If the counter behavior is set to "nomax", there will be no limit on increasing the counter on rollover and the files will be created in ascending order (ea-1.log, ea-2.log, etc.).
Additional notes :
Attachment download
📎 log4mqllib.mqh (18.24 KB)
📎 log4mql_sample.mq4 (3.33 KB)
📎 log4mql_sample_2.mq4 (5.39 KB)
Source: MQL5 #31425
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •