目次

Version 2, last updated by jeppenejsum at Nov 02 00:28 UTC

The logchanger widget allows you to change the log levels dynamically at runtime. This is very useful if you need to diagnose issues in production (provided the application is using Logging to log information).

Configuration

In Boot, add the following

    import _root_.net.liftweb.widgets.logchanger._
    LogLevelChanger.init

Instantiation a widget for the correct logging backend

The LogLevelChanger trait needs to be mixed in with a trait that matches the logging system in use. Currently log4j (default in the Lift archetypes) and logback is supported.

    object logLevel extends LogLevelChanger with Log4jLoggingBackend

The logLevel object provides a menu member that must be added to the sitemap. When the application has booted, you can access the functionality by navigating to the URL /loglevel/change. This should show a page that looks something like this:

Additional customization

You can change the path by overriding the path member. It is probably also a bad idea to let everyone change the logging settings, so you can add additional LocParams by overriding menuLocParams.

object LoglevelChanger extends LoglevelChanger with LogbackContext {
      override def menuLocParams: List[Loc.AnyLocParam] = if (Props.productionMode) List(User.testSuperUser) else Nil
}