From RPTools Wiki
Jump to navigationJump to search

log.setLevel() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.5.2
Set the logging level for the specified logger.
The log file will be found in your user directory under .maptool-rptools/logs.


log.setLevel(logger, loglevel)


  • logger - String containing a logger name.
  • loglevel - String containing a log level: DEBUG,INFO,WARN,ERROR,FATAL

The default level for all loggers is ERROR which means that only messages at ERROR or FATAL log level will be output. The levels noted above are in verbosity order from most(DEBUG) to least(FATAL).


Set the logging level for the MapToolLineParser to WARN.
[r: log.setLevel("net.rptools.maptool.client.MapToolLineParser","WARN")]



Get a list of loggers and then, using input(), select a logging level for it.

[h: loggers = json.sort(log.getLoggers(),"a","name")]
[h: loggerList = ""]
[h, FOREACH(logger, loggers), CODE: {
    [h: loggerList = listAppend(loggerList,json.get(logger,"name"))]
    "junkVar|Select a Logger and Level||LABEL|SPAN=TRUE",
[r: "Setting <i><b>" + lname + "</b></i> to <b>" + level + "</b>."]
[h: log.setLevel(lname,level)]


See Also