001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.log;
016    
017    import java.io.InputStream;
018    
019    import java.util.logging.LogManager;
020    import java.util.logging.Logger;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class Jdk14LogFactoryImpl implements LogFactory {
026    
027            public Jdk14LogFactoryImpl() {
028                    if (System.getProperty("java.util.logging.config.file") != null) {
029                            return;
030                    }
031    
032                    try {
033                            Class<?> clazz = getClass();
034    
035                            InputStream inputStream = clazz.getResourceAsStream(
036                                    "/logging.properties");
037    
038                            if (inputStream != null) {
039                                    LogManager logManager = LogManager.getLogManager();
040    
041                                    logManager.readConfiguration(inputStream);
042                            }
043                    }
044                    catch (Exception e) {
045                            e.printStackTrace();
046                    }
047            }
048    
049            @Override
050            public Log getLog(Class<?> c) {
051                    return getLog(c.getName());
052            }
053    
054            @Override
055            public Log getLog(String name) {
056                    return new Jdk14LogImpl(Logger.getLogger(name));
057            }
058    
059            @Override
060            public void setLevel(String name, String priority, boolean custom) {
061            }
062    
063    }