How to log into a specific file


#1

Hello everyone.

Today I use the function _log.debug (or error or info…) to track some information, into the evm.log. Is it possible to get a logs into another file, or for example to pass the filename as argument of a new function ?


#2

@gtanzillo can you review this question from @Merrick28 and forward to a SME if necessary.


#3

@Merrick28 We define all of our existing loggers here.

You could do something similar to define a new logger anywhere in your test code using something similar to (assuming rails is loaded):

VMDBLogger.new(Rails.root.join("log/name_of_new_log.")

Note: VMDBLogger is the ruby stdlib logger class plus some formatting of log lines.
If you just wanted a new logger for testing, you could do something like:

require 'logger'
$my_new_logger = Logger.new(STDOUT)

You could worry about using our formatter or naming the log file later.

Note, _log is a convenience method for the evm.log ($log) to automatically format the log messages with the class and method name. It can be found here.

Good luck!
Joe