1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.logging;
18
19import java.util.logging.Level;
20import java.util.logging.Logger;
21
22/**
23 * Implements the java.util.logging configuration for Android. Activates a log
24 * handler that writes to the Android log.
25 */
26public class AndroidConfig {
27
28    /**
29     * This looks a bit weird, but it's the way the logging config works: A
30     * named class is instantiated, the constructor is assumed to tweak the
31     * configuration, the instance itself is of no interest.
32     */
33    public AndroidConfig() {
34        super();
35
36        try {
37            Logger rootLogger = Logger.getLogger("");
38            rootLogger.addHandler(new AndroidHandler());
39            rootLogger.setLevel(Level.INFO);
40
41            // Turn down logging in Apache libraries.
42            Logger.getLogger("org.apache").setLevel(Level.WARNING);
43        } catch (Exception ex) {
44            ex.printStackTrace();
45        }
46    }
47}
48