Logger in canton console
App Development3 posts213 views2 likesLast activity May 2022
KC
kctamOP
May 2022Hi team,
I see some examples in the canton doc that logger is used. When I use this I see it’s not found.
cmd4.sc:1: not found: type ConsoleEnvironment
def pruneAllNodes(pruneUpToIncluding: CantonTimestamp)(implicit env: ConsoleEnvironment): Unit = {
^
cmd4.sc:16: not found: value logger
logger.warn(
^
cmd4.sc:26: not found: value logger
case None => logger.info(s"Nothing to prune up to ${pruneUpToIncluding}")
^
Compilation Failed
Please advise where I can use logger.
Thanks in advance.
kc
MA
Mate_Varga
May 2022Hi KC
You should be able to use a logger in any canton console environment, but it is not available by default.
First import these to be able to grab a logger for your script:
import com.digitalasset.canton.logging.NamedLoggerFactory
import com.typesafe.scalalogging.Logger
Then produce the logger:
val loggerFactory = consoleEnvironment.environment.loggerFactory
val logger = Logger(loggerFactory.getLogger(this.getClass))
ConsoleEnvironment is also available after you import it:
import com.digitalasset.canton.console.{ConsoleEnvironment}
Hope this helps,
Mate
KC
kctam
May 2022
import com.digitalasset.canton.console.{ConsoleEnvironment}
Hi Mate,
Thanks for your reply. As I see a lot of examples where logger is used, see if the doc can mention this somewhere.
cheers,
kc