001package org.apache.commons.jcs3.log;
002
003import java.util.logging.Logger;
004
005/*
006 * Licensed to the Apache Software Foundation (ASF) under one or more
007 * contributor license agreements. See the NOTICE file distributed with
008 * this work for additional information regarding copyright ownership.
009 * The ASF licenses this file to You under the Apache license, Version 2.0
010 * (the "License"); you may not use this file except in compliance with
011 * the License. You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the license for the specific language governing permissions and
019 * limitations under the license.
020 */
021
022/**
023 * This is a SPI factory implementation for java.util.logging
024 */
025public class JulLogFactory implements LogFactory
026{
027    /**
028     * Return the name of the Log subsystem managed by this factory
029     *
030     * @return the name of the log subsystem
031     */
032    @Override
033    public String getName()
034    {
035        return "jul";
036    }
037
038    /**
039     * Shutdown the logging system if the logging system supports it.
040     */
041    @Override
042    public void shutdown()
043    {
044        // do nothing
045    }
046
047    /**
048     * Returns a Log using the fully qualified name of the Class as the Log
049     * name.
050     *
051     * @param clazz
052     *            The Class whose name should be used as the Log name.
053     *
054     * @return The Log.
055     */
056    @Override
057    public Log getLog(final Class<?> clazz)
058    {
059        final Logger logger = Logger.getLogger(clazz.getName());
060        return new JulLogAdapter(logger);
061    }
062
063    /**
064     * Returns a Log with the specified name.
065     *
066     * @param name
067     *            The logger name.
068     * @return The Log.
069     */
070    @Override
071    public Log getLog(final String name)
072    {
073        final Logger logger = Logger.getLogger(name);
074        return new JulLogAdapter(logger);
075    }
076}