Class LoggingHandlerEnvironmentFacet
java.lang.Object
org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet
org.codehaus.mojo.jaxb2.shared.environment.logging.LoggingHandlerEnvironmentFacet
- All Implemented Interfaces:
EnvironmentFacet
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]
Standard logger names/categories for the java.util.Logger.private String
private String[]
private String
private MavenLogHandler
private Level
private boolean
private Logger
Fields inherited from class org.codehaus.mojo.jaxb2.shared.environment.AbstractLogAwareFacet
log
-
Constructor Summary
ConstructorsConstructorDescriptionLoggingHandlerEnvironmentFacet
(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. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(org.apache.maven.plugin.logging.Log mavenLog, Class<? extends AbstractJaxbMojo> caller, String encoding) Factory method creating a new LoggingHandlerEnvironmentFacet wrapping the supplied properties.void
restore()
Restores the original root Logger state, including Level and Handlers.void
setup()
Sets up this Environment, inferring temporary changes to environment variables or conditions.
-
Field Details
-
DEFAULT_LOGGER_NAMES
Standard logger names/categories for the java.util.Logger. -
restored
private boolean restored -
rootLogger
-
originalRootLoggerLevel
-
originalHandlers
-
mavenLogHandler
-
logPrefix
-
encoding
-
loggerNamePrefixes
-
-
Constructor Details
-
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 Details
-
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 therestore()
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
-