Class LoggerConfiguration

java.lang.Object
com.axelor.common.logging.LoggerConfiguration

public class LoggerConfiguration extends Object
The logger configuration builder using logback-classic.

It can be configured with following properties:

  • logging.config - the path to custom logback config file
  • logging.path - the directory where log files are saved
  • logging.pattern.file - the logging pattern for file appender
  • logging.pattern.console - the logging pattern for console appender
  • logging.level.root - the logging level of root logger
  • logging.level.com.axelor - the logging level of given logger

If logging.config is given, all other properties will be ignored.
If logging.path is not given, file appender will be disabled
If logging.pattern.file is set to OFF, file appender will be disabled
If logging.pattern.console is set to OFF, console appender will be disabled
If logback.xml is found in classpath and skipDefaultConfig is false, no custom configuration is done.

The logging pattern can use %clr() to highlight based on log level, or %clr(){color} with faint, red, green, yellow, blue, magenta, cyan as color to style the log message on console output.

The logging pattern can use %tenant to output the current tenant identifier, or %tenant{-} to output - when no tenant is set on the thread. When multi-tenancy is enabled, the ${LOG_TENANT_PATTERN} variable is set to [%tenant{-}] , which is included in the default patterns before the thread name. The raw tenant identifier is also available with %X{tenant}.

  • Field Details

    • TENANT_MDC_KEY

      public static final String TENANT_MDC_KEY
      The MDC key holding the current tenant identifier.
      See Also:
  • Constructor Details

    • LoggerConfiguration

      public LoggerConfiguration(Properties config)
  • Method Details

    • skipDefaultConfig

      public void skipDefaultConfig(boolean skipDefaultConfig)
    • multiTenancy

      public void multiTenancy(boolean multiTenancy)
      Whether multi-tenancy is enabled. If so, the default patterns include the tenant.
      Parameters:
      multiTenancy - true if multi-tenancy is enabled
    • install

      public void install()
    • uninstall

      public void uninstall()
    • conversionRule

      public void conversionRule(String word, Class<? extends ch.qos.logback.core.pattern.Converter<?>> converter)