Class MavenBaseLogger
- All Implemented Interfaces:
- Serializable,- org.slf4j.Logger
- Direct Known Subclasses:
- MavenSimpleLogger
 Simple implementation of Logger that sends all enabled log messages,
 for all defined loggers, to the console (System.err). The following
 system properties are supported to configure the behavior of this logger:
 
- maven.logger.logFile- The output target which can be the path to a file, or the special values "System.out" and "System.err". Default is "System.err".
- maven.logger.cacheOutputStream- If the output target is set to "System.out" or "System.err" (see preceding entry), by default, logs will be output to the latest value referenced by- System.out/errvariables. By setting this parameter to true, the output stream will be cached, i.e. assigned once at initialization time and re-used independently of the current value referenced by- System.out/err.
- maven.logger.defaultLogLevel- Default log level for all instances of SimpleLogger. Must be one of ("trace", "debug", "info", "warn", "error" or "off"). If not specified, defaults to "info".
- maven.logger.log.a.b.c- Logging detail level for a SimpleLogger instance named "a.b.c". Right-side value must be one of "trace", "debug", "info", "warn", "error" or "off". When a SimpleLogger named "a.b.c" is initialized, its level is assigned from this property. If unspecified, the level of nearest parent logger will be used, and if none is set, then the value specified by- maven.logger.defaultLogLevelwill be used.
- maven.logger.showDateTime- Set to- trueif you want the current date and time to be included in output messages. Default is- false
- maven.logger.dateTimeFormat- The date and time format to be used in the output messages. The pattern describing the date and time format is defined by- SimpleDateFormat. If the format is not specified or is invalid, the number of milliseconds since start up will be output.
- maven.logger.showThreadName-Set to- trueif you want to output the current thread name. Defaults to- true.
- (since version 1.7.33 and 2.0.0-alpha6) maven.logger.showThreadId- If you would like to output the current thread id, then set totrue. Defaults tofalse.
- maven.logger.showLogName- Set to- trueif you want the Logger instance name to be included in output messages. Defaults to- true.
- maven.logger.showShortLogName- Set to- trueif you want the last component of the name to be included in output messages. Defaults to- false.
- maven.logger.levelInBrackets- Should the level string be output in brackets? Defaults to- false.
- maven.logger.warnLevelString- The string value output for the warn level. Defaults to- WARN.
 In addition to looking for system properties with the names specified above,
 this implementation also checks for a class loader resource named
 "simplelogger.properties", and includes any matching definitions
 from this resource (if it exists).
 
With no configuration, the default output includes the relative time in milliseconds, thread name, the level, logger name, and the message followed by the line separator for the host. In log4j terms it amounts to the "%r [%t] %level %logger - %m%n" pattern.
Sample output follows.
176 [main] INFO examples.Sort - Populating an array of 2 elements in reverse order. 225 [main] INFO examples.SortAlgo - Entered the sort method. 304 [main] INFO examples.SortAlgo - Dump of integer array: 317 [main] INFO examples.SortAlgo - Element [0] = 0 331 [main] INFO examples.SortAlgo - Element [1] = 1 343 [main] INFO examples.Sort - The next log statement should be an error message. 346 [main] ERROR examples.SortAlgo - Tried to dump an uninitialized array. at org.log4j.examples.SortAlgo.dump(SortAlgo.java:58) at org.log4j.examples.Sort.main(Sort.java:64) 467 [main] INFO examples.Sort - Exiting main method.
This implementation is heavily inspired by Apache Commons Logging's SimpleLog.
- Author:
- Ceki Gülcü, Scott Sanders, Rod Waldhoff, Robert Burrell Donkin, Cédrik LIME
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected intThe current log levelstatic final StringLegacy SLF4J prefix maintained for backwards compatibilityprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intFields inherited from class org.slf4j.helpers.AbstractLoggernameFields inherited from interface org.slf4j.LoggerROOT_LOGGER_NAME
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedMavenBaseLogger(String name) Protected access allows onlyMavenLoggerFactoryand also derived classes to instantiate MavenLoggerFactory instances.
- 
Method SummaryModifier and TypeMethodDescriptionprotected Stringprotected Stringprotected voidhandleNormalizedLoggingCall(org.slf4j.event.Level level, org.slf4j.Marker marker, String messagePattern, Object[] arguments, Throwable throwable) SimpleLogger's implementation ofAbstractLogger#handleNormalizedLoggingCall}booleanAredebugmessages currently enabled?booleanAreerrormessages currently enabled?booleanAreinfomessages currently enabled?protected booleanisLevelEnabled(int logLevel) Is the given log level currently enabled?booleanAretracemessages currently enabled?booleanArewarnmessages currently enabled?voidlog(org.slf4j.event.LoggingEvent event) protected StringrenderLevel(int levelInt) protected voidwrite(StringBuilder buf, Throwable t) To avoid intermingling of log messages and associated stack traces, the two operations are done in a synchronized block.protected voidwriteThrowable(Throwable t, PrintStream targetStream) Methods inherited from class org.slf4j.helpers.LegacyAbstractLoggerisDebugEnabled, isErrorEnabled, isInfoEnabled, isTraceEnabled, isWarnEnabledMethods inherited from class org.slf4j.helpers.AbstractLoggerdebug, debug, debug, debug, debug, debug, debug, debug, debug, debug, error, error, error, error, error, error, error, error, error, error, getName, info, info, info, info, info, info, info, info, info, info, readResolve, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, warn, warn, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.slf4j.LoggeratDebug, atError, atInfo, atLevel, atTrace, atWarn, isEnabledForLevel, makeLoggingEventBuilder
- 
Field Details- 
LOG_LEVEL_TRACEprotected static final int LOG_LEVEL_TRACE- See Also:
 
- 
LOG_LEVEL_DEBUGprotected static final int LOG_LEVEL_DEBUG- See Also:
 
- 
LOG_LEVEL_INFOprotected static final int LOG_LEVEL_INFO- See Also:
 
- 
LOG_LEVEL_WARNprotected static final int LOG_LEVEL_WARN- See Also:
 
- 
LOG_LEVEL_ERRORprotected static final int LOG_LEVEL_ERROR- See Also:
 
- 
LOG_LEVEL_OFFprotected static final int LOG_LEVEL_OFF- See Also:
 
- 
currentLogLevelprotected int currentLogLevelThe current log level
- 
LEGACY_PREFIXLegacy SLF4J prefix maintained for backwards compatibility- See Also:
 
 
- 
- 
Constructor Details- 
MavenBaseLoggerProtected access allows onlyMavenLoggerFactoryand also derived classes to instantiate MavenLoggerFactory instances.
 
- 
- 
Method Details- 
writeTo avoid intermingling of log messages and associated stack traces, the two operations are done in a synchronized block.- Parameters:
- buf- The StringBuilder containing the log message to be written
- t- The Throwable object whose stack trace should be written, may be null
 
- 
writeThrowable
- 
computeShortName
- 
isLevelEnabledprotected boolean isLevelEnabled(int logLevel) Is the given log level currently enabled?- Parameters:
- logLevel- is this level enabled?
- Returns:
- whether the logger is enabled for the given level
 
- 
isTraceEnabledpublic boolean isTraceEnabled()Aretracemessages currently enabled?
- 
isDebugEnabledpublic boolean isDebugEnabled()Aredebugmessages currently enabled?
- 
isInfoEnabledpublic boolean isInfoEnabled()Areinfomessages currently enabled?
- 
isWarnEnabledpublic boolean isWarnEnabled()Arewarnmessages currently enabled?
- 
isErrorEnabledpublic boolean isErrorEnabled()Areerrormessages currently enabled?
- 
handleNormalizedLoggingCallprotected void handleNormalizedLoggingCall(org.slf4j.event.Level level, org.slf4j.Marker marker, String messagePattern, Object[] arguments, Throwable throwable) SimpleLogger's implementation ofAbstractLogger#handleNormalizedLoggingCall}- Specified by:
- handleNormalizedLoggingCallin class- org.slf4j.helpers.AbstractLogger
- Parameters:
- level- the SLF4J level for this event
- marker- The marker to be used for this event, may be null.
- messagePattern- The message pattern which will be parsed and formatted
- arguments- the array of arguments to be formatted, may be null
- throwable- The exception whose stack trace should be logged, may be null
 
- 
renderLevel
- 
logpublic void log(org.slf4j.event.LoggingEvent event) 
- 
getFullyQualifiedCallerName- Specified by:
- getFullyQualifiedCallerNamein class- org.slf4j.helpers.AbstractLogger
 
 
-