001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }