Embedded Apache Tomcat servlet container with Jakarta Servlet API, HTTP connectors, and lifecycle management for Java web applications
Tomcat's Java Util Logging Implementation providing per-classloader log isolation, configurable handlers and formatters, bridge to java.util.logging API, and support for file rotation and console output. Enables independent logging configuration for each web application.
Commons-logging compatible logging interface.
public interface Log {
// Log level checks
boolean isDebugEnabled();
boolean isErrorEnabled();
boolean isFatalEnabled();
boolean isInfoEnabled();
boolean isTraceEnabled();
boolean isWarnEnabled();
// Trace
void trace(Object message);
void trace(Object message, Throwable t);
// Debug
void debug(Object message);
void debug(Object message, Throwable t);
// Info
void info(Object message);
void info(Object message, Throwable t);
// Warn
void warn(Object message);
void warn(Object message, Throwable t);
// Error
void error(Object message);
void error(Object message, Throwable t);
// Fatal
void fatal(Object message);
void fatal(Object message, Throwable t);
}Factory for obtaining Log instances.
public class LogFactory {
// Static methods - obtain log instances
public static Log getLog(Class<?> clazz);
public static Log getLog(String name);
// Static methods - factory management
public static LogFactory getFactory() throws LogConfigurationException;
public static void release(ClassLoader classLoader);
// Instance methods - obtain log instances
public Log getInstance(String name) throws LogConfigurationException;
public Log getInstance(Class<?> clazz) throws LogConfigurationException;
}LogManager implementation providing per-classloader log isolation for web applications.
public class ClassLoaderLogManager extends LogManager {
public ClassLoaderLogManager();
// Override LogManager methods for per-classloader isolation
public Logger getLogger(String name);
public Enumeration<String> getLoggerNames();
public boolean addLogger(Logger logger);
// Property reading from per-classloader sources
public String getProperty(String name);
public void readConfiguration() throws IOException;
public void readConfiguration(InputStream ins) throws IOException;
// Classloader management
public synchronized void setUseShutdownHook(boolean useShutdownHook);
public boolean isUseShutdownHook();
}Log handler that writes log messages to a file with rotation support.
public class FileHandler extends Handler {
// Constructors
public FileHandler();
public FileHandler(String directory, String prefix, String suffix);
public FileHandler(String directory, String prefix, String suffix, Integer maxDays);
public FileHandler(String directory, String prefix, String suffix, Integer maxDays, Boolean rotatable, Integer bufferSize);
// Handler methods
public void publish(LogRecord record);
public void close();
public void flush();
// Configuration
public void setDirectory(String directory);
public String getDirectory();
public void setPrefix(String prefix);
public String getPrefix();
public void setSuffix(String suffix);
public String getSuffix();
public void setRotatable(boolean rotatable);
public boolean isRotatable();
public void setBuffered(boolean buffered);
// Rotation
protected void open();
protected void rotate();
}Asynchronous file handler that writes log messages in a separate thread for improved performance.
public class AsyncFileHandler extends FileHandler {
public AsyncFileHandler();
public AsyncFileHandler(String directory, String prefix, String suffix);
public AsyncFileHandler(String directory, String prefix, String suffix, Integer maxDays);
// Asynchronous publishing
public void publish(LogRecord record);
public void close();
}Formatter that outputs log records as a single line.
public class OneLineFormatter extends Formatter {
public OneLineFormatter();
public String format(LogRecord record);
// Configuration
public void setTimeFormat(String format);
public String getTimeFormat();
}Formatter that outputs only the log message without any additional formatting.
public class VerbatimFormatter extends Formatter {
public VerbatimFormatter();
public String format(LogRecord record);
}Formatter that outputs log records in JSON format for structured logging.
public class JsonFormatter extends Formatter {
public JsonFormatter();
public String format(LogRecord record);
}Formatter compatible with JDK logger output format.
public class JdkLoggerFormatter extends Formatter {
public JdkLoggerFormatter();
public String format(LogRecord record);
}Exception thrown when log configuration fails.
public class LogConfigurationException extends RuntimeException {
public LogConfigurationException();
public LogConfigurationException(String message);
public LogConfigurationException(Throwable cause);
public LogConfigurationException(String message, Throwable cause);
}Thread-safe date format cache for improved logging performance.
public class DateFormatCache {
public DateFormatCache(int size, String format, DateFormatCache parent);
public String getFormat(long time);
public String getTimeFormat();
}import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
public class LoggingExample {
private static final Log log = LogFactory.getLog(LoggingExample.class);
public void doSomething() {
log.info("Starting operation");
try {
// Perform operation
if (log.isDebugEnabled()) {
log.debug("Operation details...");
}
log.info("Operation completed successfully");
} catch (Exception e) {
log.error("Operation failed", e);
}
}
}Install with Tessl CLI
npx tessl i tessl/maven-org-apache-tomcat-embed--tomcat-embed-core