Java Tutorial/Log/Config Properties

Материал из Java эксперт
Перейти к: навигация, поиск

config.properties

   <source lang="java">
  1. define the logger level

your.logging.level=INFO</source>





Configuring Logger Default Values with a Properties File

   <source lang="java">
  1. The following creates two handlers

handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler

  1. Set the default logging level for the root logger

.level = ALL

  1. Set the default logging level for new ConsoleHandler instances

java.util.logging.ConsoleHandler.level = INFO

  1. Set the default logging level for new FileHandler instances

java.util.logging.FileHandler.level = ALL

  1. Set the default formatter for new ConsoleHandler instances

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

  1. Set the default logging level for the logger named com.mycompany

com.mycompany.level = ALL The custom logging properties file is loaded by specifying a system property on the command line: java -Djava.util.logging.config.file=mylogging.properties <class></source>





#define the properties for the SocketHandler

   <source lang="java">

java.util.logging.SocketHandler.level=INFO java.util.logging.SocketHandler.host=localhost java.util.logging.SocketHandler.port=2020</source>