| 1 | package org.apache.commons.jcs3.log; |
| 2 | |
| 3 | import java.util.logging.Logger; |
| 4 | |
| 5 | /* |
| 6 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 7 | * contributor license agreements. See the NOTICE file distributed with |
| 8 | * this work for additional information regarding copyright ownership. |
| 9 | * The ASF licenses this file to You under the Apache license, Version 2.0 |
| 10 | * (the "License"); you may not use this file except in compliance with |
| 11 | * the License. You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the license for the specific language governing permissions and |
| 19 | * limitations under the license. |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * This is a SPI factory implementation for java.util.logging |
| 24 | */ |
| 25 | public class JulLogFactory implements LogFactory |
| 26 | { |
| 27 | /** |
| 28 | * Return the name of the Log subsystem managed by this factory |
| 29 | * |
| 30 | * @return the name of the log subsystem |
| 31 | */ |
| 32 | @Override |
| 33 | public String getName() |
| 34 | { |
| 35 | return "jul"; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Shutdown the logging system if the logging system supports it. |
| 40 | */ |
| 41 | @Override |
| 42 | public void shutdown() |
| 43 | { |
| 44 | // do nothing |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns a Log using the fully qualified name of the Class as the Log |
| 49 | * name. |
| 50 | * |
| 51 | * @param clazz |
| 52 | * The Class whose name should be used as the Log name. |
| 53 | * |
| 54 | * @return The Log. |
| 55 | */ |
| 56 | @Override |
| 57 | public Log getLog(final Class<?> clazz) |
| 58 | { |
| 59 | final Logger logger = Logger.getLogger(clazz.getName()); |
| 60 | return new JulLogAdapter(logger); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns a Log with the specified name. |
| 65 | * |
| 66 | * @param name |
| 67 | * The logger name. |
| 68 | * @return The Log. |
| 69 | */ |
| 70 | @Override |
| 71 | public Log getLog(final String name) |
| 72 | { |
| 73 | final Logger logger = Logger.getLogger(name); |
| 74 | return new JulLogAdapter(logger); |
| 75 | } |
| 76 | } |