Class LoggingHandlerEnvironmentFacet

  • All Implemented Interfaces:
    EnvironmentFacet

    public class LoggingHandlerEnvironmentFacet
    extends AbstractLogAwareFacet
    EnvironmentFacet for replacing Handlers from Java Util Logging with a Maven Log. This is required as an environment facet for capturing log statements from tools that use the Java Util Logging system internally - such as the JDK SchemaGen tool.
    Since:
    2.1
    Author:
    Lennart Jörelid, jGuru Europe AB
    • Field Detail

      • DEFAULT_LOGGER_NAMES

        public static final String[] DEFAULT_LOGGER_NAMES
        Standard logger names/categories for the java.util.Logger.
    • Constructor Detail

      • LoggingHandlerEnvironmentFacet

        public LoggingHandlerEnvironmentFacet​(String logPrefix,
                                              org.apache.maven.plugin.logging.Log mavenLog,
                                              String encoding,
                                              String[] loggerNamePrefixes)
        Creates a new JavaLoggingEnvironment, using the supplied variables to set up a MavenLogHandler. The MavenLogHandler is then assigned to the root logger.
        Parameters:
        logPrefix - The prefix to use for the logger, indicating which tool is used by the log. Example: "XJC" or "SchemaGen".
        mavenLog - The active Maven Log.
        encoding - The configured encoding.
        loggerNamePrefixes - The prefixes of the Logger names to be permitted logging.
    • Method Detail

      • setup

        public void setup()
        Sets up this Environment, inferring temporary changes to environment variables or conditions. The changes must be reversible, and should be restored to their original values in the restore() method.

        Redirects JUL logging statements to the Maven Log.

      • restore

        public void restore()
        Restores the original root Logger state, including Level and Handlers.
      • create

        public static LoggingHandlerEnvironmentFacet create​(org.apache.maven.plugin.logging.Log mavenLog,
                                                            Class<? extends AbstractJaxbMojo> caller,
                                                            String encoding)
        Factory method creating a new LoggingHandlerEnvironmentFacet wrapping the supplied properties.
        Parameters:
        mavenLog - The active Maven Log.
        caller - The AbstractJaxbMojo subclass which invoked this LoggingHandlerEnvironmentFacet factory method.
        encoding - The encoding used by the Maven Mojo subclass.
        Returns:
        A fully set up LoggingHandlerEnvironmentFacet