Package org.springframework.core.log
Class LogMessage
java.lang.Object
org.springframework.core.log.LogMessage
- All Implemented Interfaces:
- CharSequence
A simple log message type for use with Commons Logging, allowing for convenient
 lazy resolution of a given 
Supplier instance (typically bound to a lambda
 expression) or a printf-style format string (String.format(java.lang.String, java.lang.Object...)) in its
 toString().- Since:
- 5.2
- Author:
- Juergen Hoeller, Sebastien Deleuze
- See Also:
- 
- of(Supplier)
- format(String, Object)
- format(String, Object...)
- Log.fatal(Object)
- Log.error(Object)
- Log.warn(Object)
- Log.info(Object)
- Log.debug(Object)
- Log.trace(Object)
 
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptioncharcharAt(int index) static LogMessageBuild a lazily formatted message from the given format string and argument.static LogMessageBuild a lazily formatted message from the given format string and varargs.static LogMessageBuild a lazily formatted message from the given format string and arguments.static LogMessageBuild a lazily formatted message from the given format string and arguments.static LogMessageformat(String format, @Nullable Object arg1, @Nullable Object arg2, @Nullable Object arg3, @Nullable Object arg4) Build a lazily formatted message from the given format string and arguments.intlength()static LogMessageof(Supplier<? extends CharSequence> supplier) Build a lazily resolving message from the given supplier.subSequence(int start, int end) toString()This will be called by the logging provider, potentially once per log target (therefore locally caching the result here).Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequencechars, codePoints, isEmpty
- 
Constructor Details- 
LogMessagepublic LogMessage()
 
- 
- 
Method Details- 
lengthpublic int length()- Specified by:
- lengthin interface- CharSequence
 
- 
charAtpublic char charAt(int index) - Specified by:
- charAtin interface- CharSequence
 
- 
subSequence- Specified by:
- subSequencein interface- CharSequence
 
- 
toStringThis will be called by the logging provider, potentially once per log target (therefore locally caching the result here).- Specified by:
- toStringin interface- CharSequence
- Overrides:
- toStringin class- Object
 
- 
ofBuild a lazily resolving message from the given supplier.- Parameters:
- supplier- the supplier (typically bound to a lambda expression)
- See Also:
 
- 
formatBuild a lazily formatted message from the given format string and argument.- Parameters:
- format- the format string (following- String.format(java.lang.String, java.lang.Object...)rules)
- arg1- the argument (can be- null)
- See Also:
 
- 
formatBuild a lazily formatted message from the given format string and arguments.- Parameters:
- format- the format string (following- String.format(java.lang.String, java.lang.Object...)rules)
- arg1- the first argument (can be- null)
- arg2- the second argument (can be- null)
- See Also:
 
- 
formatpublic static LogMessage format(String format, @Nullable Object arg1, @Nullable Object arg2, @Nullable Object arg3) Build a lazily formatted message from the given format string and arguments.- Parameters:
- format- the format string (following- String.format(java.lang.String, java.lang.Object...)rules)
- arg1- the first argument (can be- null)
- arg2- the second argument (can be- null)
- arg3- the third argument (can be- null)
- See Also:
 
- 
formatpublic static LogMessage format(String format, @Nullable Object arg1, @Nullable Object arg2, @Nullable Object arg3, @Nullable Object arg4) Build a lazily formatted message from the given format string and arguments.- Parameters:
- format- the format string (following- String.format(java.lang.String, java.lang.Object...)rules)
- arg1- the first argument (can be- null)
- arg2- the second argument (can be- null)
- arg3- the third argument (can be- null)
- arg4- the fourth argument (can be- null)
- See Also:
 
- 
formatBuild a lazily formatted message from the given format string and varargs.This varargs format()variant may be costly. You should therefore use the individual argument variants whenever possible;format(String, Object),format(String, Object, Object), etc.- Parameters:
- format- the format string (following- String.format(java.lang.String, java.lang.Object...)rules)
- args- the varargs array (can be- nulland can contain- nullelements)
- See Also:
 
 
-