📖Logging
Last updated
Last updated
Uses the standard Java Logging framework java.util.logging (not Apache Log4j). It is part of Java SE and therefore, no additional library is needed.
Capable of writing more than 10'000 lines/sec on a MacBook Pro using the FileHandler and KLogLineFormatter.
Reduces logging complexity to debug, error and info messages
All methods are static (no instantiation needed)
Handler and formatter classes are provided to format data as tabular text, CSV, XML, JSON and YAML or to send data to any JDBC compliant database or all errors to any SMTP server
Add precise timestamp and exact code location to the formatted log output
To enable logging, the configuration file KLog.properties must be in the current directory
The configured logging level may be changed during execution with setLevelxxx() and reset again to the configured value with resetLevel()
The Java Utility Package ch.k43.util is using the KLog functions internally to help you during problem determination. Just set the log level to FINEST to enable the debugging mode in the KLog.properties file. This will get you detailed information during the execution of your code.
The logging properties file enables and configures the logging framework used by all KLog methods. Simply download, edit and place the file in the current directory of your Java application.
The following logging handlers classes are provided:
KLogJDBCHandler: Send output to any JDBC compliant database
KLogSMTPHandler: Send errors (FATAL log level) to any SMTP server
The log information (timestamp, logging level, code location and message) can be formatted with the following formatter classes:
KLogCSVFormatter: Format data as a one-line CSV string
KLogJSONFormatter: Format data as a multi-line JSON string
KLogLineFormatter: Format data as a one-line tabular string
KLogXMLFormatter: Format data as a multi-line XML string
KLogYAMLFormatter: Format data as a multi-line YAML string