/* * ### * Phresco Commons * * Copyright (C) 1999 - 2012 Photon Infotech Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ### */ package com.photon.phresco.logger; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; public class LoggerTest { // Always use the classname, this way you can refactor private final static Logger LOGGER = Logger.getLogger(LoggerTest.class .getName()); public void writeLog() { // Set the LogLevel to Severe, only severe Messages will be written LOGGER.setLevel(Level.SEVERE); LOGGER.severe("Info Log"); LOGGER.warning("Info Log"); LOGGER.info("Info Log"); LOGGER.finest("Really not important"); // Set the LogLevel to Info, severe, warning and info will be written // Finest is still not written LOGGER.setLevel(Level.INFO); LOGGER.severe("Info Log"); LOGGER.warning("Info Log"); LOGGER.info("Info Log"); LOGGER.finest("Really not important"); } public static void main(String[] args) { LoggerTest logger = new LoggerTest(); try { PhrescoLogger.setup(); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("Problems with creating the log files"); } logger.writeLog(); } }