Github user rgoers commented on a diff in the pull request: https://github.com/apache/logging-log4j2/pull/213#discussion_r212672750 --- Diff: log4j-jul/src/main/java/org/apache/logging/log4j/jul/Log4jBridgeHandler.java --- @@ -0,0 +1,198 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ +package org.apache.logging.log4j.jul; + +// note: NO import of Logger, LogManager etc. to prevent conflicts JUL/log4j +import java.util.logging.LogRecord; + +import org.apache.logging.log4j.spi.ExtendedLogger; +import org.apache.logging.log4j.status.StatusLogger; + + +/** + * Bridge from JUL to log4j2.<br> + * This is an alternative to log4j.jul.LogManager (running as complete JUL replacement), + * especially useful for webapps running on a container for which the LogManager cannot or + * should not be used.<br><br> + * + * Installation/usage:<ul> + * <li> declaratively inside JUL's logging.properties:<br> + * <code>handlers = org.apache.logging.log4j.jul.Log4jBridgeHandler</code><br> + * (note: in a webapp running on Tomcat, you may create a <code>WEB-INF/classes/logging.properties</code> + * file to configure JUL for this webapp only) + * <li> programmatically by calling install() method, + * e.g. inside ServletContextListener static-class-init. or contextInitialized() + * </ul> + * Configuration (in JUL's <code>logging.properties</code>):<ul> + * <li> Log4jBridgeHandler.suffixToAppend<br> + * String, suffix to append to JUL logger names, to easily recognize bridged log messages. + * A dot "." is automatically prepended, so configuration for the basis logger is used + * Example: suffixToAppend = _JUL + * <li> Log4jBridgeHandler.propagateLevels � (this is TODO!) boolean, "true" to automatically propagate log4j log levels to JUL. + * <li> Log4jBridgeHandler.sysoutDebug � boolean, perform some (developer) debug output to sysout + * </ul> + * + * Restrictions:<ul> + * <li> Manually given source/location info in JUL (e.g. entering(), exiting(), throwing(), logp(), logrb() ) + * will NOT be considered, i.e. gets lost in log4j logging. + * <li> Log levels of JUL have to be manually adjusted according to log4j log levels (until "propagateLevels" is implemented). + * I.e. logging.properties and log4j2.xml have some redundancies. + * <li> Only JUL log events that are allowed according to the JUL log level get to this handler and thus to log4j. + * If you set <code>.level = SEVERE</code> only error logs will be seen by this handler and thus log4j + * - even if the corresponding log4j log level is ALL.<br> + * On the other side, you should NOT set <code>.level = FINER or FINEST</code> if the log4j level is higher. + * In this case a lot of JUL log events would be generated, sent via this bridge to log4j and thrown away by the latter. + * </ul> + * + * @author Thies Wellpott (twapa...@online.de) + * @author authors of original org.slf4j.bridge.SLF4JBridgeHandler (ideas and some basis from there) --- End diff -- Author tags should be removed. Log4j doesn't use them.
---