Created
August 25, 2017 17:48
-
-
Save InsanusMokrassar/226053559ce0271e939784359c136961 to your computer and use it in GitHub Desktop.
Kotlin logger template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Global logger | |
handlers=java.util.logging.FileHandler,java.util.logging.ConsoleHandler | |
.level=ALL | |
# File handler | |
java.util.logging.FileHandler.level=ALL | |
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter | |
java.util.logging.FileHandler.limit=1000000 | |
java.util.logging.FileHandler.count=10 | |
java.util.logging.FileHandler.pattern=log.%u.%g.txt | |
# Console handler | |
java.util.logging.ConsoleHandler.level=ALL | |
java.util.logging.ConsoleHandler.pattern=log.log | |
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Need "LOGGER_CONFIG_PATH" environment variable which set the place where was put .properties file with config of logger | |
*/ | |
fun loadLoggerConfig() { | |
FileInputStream(System.getenv("LOGGER_CONFIG_PATH")).use { | |
LogManager.getLogManager().readConfiguration(it) | |
} | |
} | |
/** | |
* Need file with logger config | |
*/ | |
fun loadLoggerConfig(file: FileInputStream) { | |
LogManager.getLogManager().readConfiguration(file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment