Package ch.k43.util
Klasse KLog
java.lang.Object
ch.k43.util.KLog
Static class for simple logging.
Notes:
- The logging framework is automatically initialized during the first call.
- To enable logging, the file KLog.properties must be present in the current directory.
- The syntax follows the rules set by the java.util.logging framework (Java Logging API).
- This class only supports Java Logger levels FINEST, INFO and SEVERE thru KLog.debug(), KLog.info() and KLog.error().
- The message text is prepended with the called code location (e.g. main[1]:Test:main:15) and delimited by KLog.DELIMITER.
Examples: KLog.info("Program started"); KLog.debug("Any debugging message); Output: 2024-06-23T09:11:02.628 D main[1]:ch.k43.util.KLog:open:466 ===== Application started 2024-06-23T09:11:02.612 ===== 2024-06-23T09:11:02.629 D main[1]:ch.k43.util.KLog:open:468 Java Utility Package (Freeware) ch.k43.util Version 2024.06.22 2024-06-23T09:11:02.652 D main[1]:ch.k43.util.KLog:open:473 Host ab-macbook-pro (10.0.0.105) 2024-06-23T09:11:02.653 D main[1]:ch.k43.util.KLog:open:474 OS platform Mac OS X (14.5) 2024-06-23T09:11:02.653 D main[1]:ch.k43.util.KLog:open:475 Java version 17 (OpenJDK 64-Bit Server VM - Eclipse Adoptium) 2024-06-23T09:11:02.655 D main[1]:ch.k43.util.KLog:open:479 Java heap maximum 16.00 GB, current 1.00 GB, used 4.83 MB, free 1019.17 MB 2024-06-23T09:11:02.655 D main[1]:ch.k43.util.KLog:open:483 Java locale de/CH, time UTC +02:00 2024-06-23T09:11:02.655 D main[1]:ch.k43.util.KLog:open:486 Java classpath ../bin/:../lib/k43.util.jar 2024-06-23T09:11:02.656 I main[1]:Test:main:21 Program started 2024-06-23T09:11:02.656 D main[1]:Test:main:22 Any debugging message
-
Feldübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic void
Log error message if expression is true and throws an unchecked RuntimeException.static void
Log error message and throws an unchecked RuntimeException.static void
argException
(boolean argExpression, String argMessage) Log error message if expression evaluates true and throw an unchecked exception IllegalArgumentException.static void
close()
Close the logging.static void
Write log message of level FINEST.static void
Log error message if expression is true.static void
Log formatted exception with stack trace.static void
Log error message.static void
Log message and exception with stack trace.static Level
getLevel()
Get logger level.static void
Write log message of level INFO.static boolean
isActive()
Check if logging is active.static boolean
Check if logger is at level FINEST.static boolean
Check if logger is at level SEVEREstatic boolean
Check if logger is at level INFO.static boolean
Check if logger is at level OFF.static void
Reset logger level to the configured level in KLog.propertiesstatic void
Set logger levelstatic void
Set logger to debug level (FINEST)static void
Set logger to error level (SEVERE)static void
Set logger to info level (INFO)static void
Set logger off (OFF)toString()
String representation of object.
-
Felddetails
-
PROPERTIES_FILE
KLog properties file name- Siehe auch:
-
-
Methodendetails
-
abort
Log error message if expression is true and throws an unchecked RuntimeException.- Parameter:
argExpression
- Any expressionargMessage
- Message to be logged
-
abort
Log error message and throws an unchecked RuntimeException.- Parameter:
argMessage
- Message to be logged
-
argException
Log error message if expression evaluates true and throw an unchecked exception IllegalArgumentException.- Parameter:
argExpression
- Any expressionargMessage
- Message to be logged and used as exception- Löst aus:
IllegalArgumentException
- Explicit exception- Seit:
- 2024.05.17
-
close
public static void close()Close the logging. -
debug
Write log message of level FINEST.- Parameter:
argMessage
- Message to be written
-
error
Log error message if expression is true.- Parameter:
argExpression
- True/False Any expressionargMessage
- Message to be logged
-
error
Log formatted exception with stack trace.- Parameter:
argException
- Exception to be formatted
-
error
Log error message.- Parameter:
argMessage
- Message to be written
-
error
Log message and exception with stack trace.- Parameter:
argMessage
- Message to be writtenargException
- Optional exception to be formatted
-
getLevel
Get logger level.- Gibt zurück:
- Logging level
- Seit:
- 2024.06.16
-
info
Write log message of level INFO.- Parameter:
argMessage
- Message to be written
-
isActive
public static boolean isActive()Check if logging is active.- Gibt zurück:
- True if logging is initialized and active, false otherwise
-
isLevelDebug
public static boolean isLevelDebug()Check if logger is at level FINEST.- Gibt zurück:
- True if level matches, false otherwise
-
isLevelError
public static boolean isLevelError()Check if logger is at level SEVERE- Gibt zurück:
- True if level matches, false otherwise
-
isLevelInfo
public static boolean isLevelInfo()Check if logger is at level INFO.- Gibt zurück:
- True if level matches, false otherwise
-
isLevelOff
public static boolean isLevelOff()Check if logger is at level OFF.- Gibt zurück:
- True if level matches, false otherwise
-
resetLevel
public static void resetLevel()Reset logger level to the configured level in KLog.properties- Seit:
- 2024.05.25
-
setLevel
Set logger level- Parameter:
argLevel
- Logging level to set- Seit:
- 2024.06.16
-
setLevelDebug
public static void setLevelDebug()Set logger to debug level (FINEST)- Seit:
- 2024.05.25
-
setLevelError
public static void setLevelError()Set logger to error level (SEVERE)- Seit:
- 2024.05.25
-
setLevelInfo
public static void setLevelInfo()Set logger to info level (INFO)- Seit:
- 2024.05.25
-
setLevelOff
public static void setLevelOff()Set logger off (OFF)- Seit:
- 2024.05.25
-
toString
String representation of object.
-