On 10/01/2022 13:20, Makarov Alexey wrote:
Thank you, but this properties is not work or something wrong. I get "${classloader.webappName}", "${classloader.hostName}", or "${classloader.serviceName}" in catalina.out when I try to use this properties. But if I try to use "${catalina.base}" all fine (property is translate to "/opt/tomcat", my install directory).

public class MyCustomLogFormatter extends Formatter {
      @Override
      public String format(LogRecord record) {
         String webappName = LogManager.getLogManager()
          .getProperty(OneLineFormatter.class.getName() + ".webappName"); // ".hostName", ".serviceName", ".catalinaBase"

        return String.format("%s/n", webappName); // only application name for testing
      }
}

in $CATALINA_BASE/conf/logging.properties:

my.log.formatter.MyCustomLogFormatter.webappName = ${classloader.webappName}
my.log.formatter.MyCustomLogFormatter.hostName = ${classloader.hostName}
my.log.formatter.MyCustomLogFormatter.serviceName = ${catalina.serviceName}
my.log.formatter.MyCustomLogFormatter.catalinaBase = ${catalina.base}



The short answer is yes. Sorry for not mentioning that before.

The longer answer is that the main thing that JULI does is to extent java.util.logging to make it class loader aware. In j.u.l logging loggers are uniquely identified by name. In JULI, they are uniquely identified by name and class loader. This is so you can have loggers with the same name in different web applications without them interfering. You can also have per class loader configuration.

The three additional properties I listed above are provided by the web application class loader so they only work in per web application logging.properties.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to