为什么Log.v没有在Logcat中生成输出?

时间:2017-04-25 19:51:09

标签: android

为什么Log.v没有在Logcat中生成输出? 我是Android新手。我的应用程序有四个活动。在这里,我粘贴了NumbersActivity的代码,我使用Log.v在Logcat中生成输出。 这是我的代码:

package com.example.android.miwok;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

public class NumbersActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_numbers);
    String[] words=new String[10];
    words[0]="One";
    words[1]="Two";
    words[2]="Three";
    words[3]="Four";
    words[4]="Five";
    words[5]="Six";
    words[6]="Seven";
    words[7]="Eight";
    words[8]="Nine";
    words[9]="Ten";
    Log.v("NumbersActivity", "Word at index 0 is: " +words[0]);
    Log.v("NumbersActivity", "Word at index 1 is: " +words[1]);
 }
}

这是Logcat中生成的输出:

    04-26 01:12:15.229 24976-24976/? I/art: Not late-enabling -
Xcheck:jni (already on)
04-26 01:12:15.231 24976-24976/? W/art: Unexpected CPU variant for X86 
using defaults: x86
04-26 01:12:16.083 24976-24976/com.example.android.miwok W/System: 
ClassLoader referenced unknown path: 
/data/app/com.example.android.miwok-1/lib/x86
04-26 01:12:16.356 24976-24976/com.example.android.miwok I/InstantRun: 
starting instant run server: is main process
04-26 01:12:16.510 24976-24976/com.example.android.miwok W/art: Before 
Android 4.1, method android.graphics.PorterDuffColorFilter 
android.support.graphics.drawable.VectorDrawableCompat.
updateTintFilter(android.graphics.PorterDuffColorFilter, 
android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) 
would have incorrectly overridden the package-private method in 
android.graphics.drawable.Drawable
04-26 01:12:17.163 24976-25009/com.example.android.miwok 
I/OpenGLRenderer: Initialized EGL, version 1.4
04-26 01:12:17.163 24976-25009/com.example.android.miwok 
D/OpenGLRenderer: Swap behavior 1
04-26 01:12:17.164 24976-25009/com.example.android.miwok 
W/OpenGLRenderer: Failed to choose config with 
EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
04-26 01:12:17.164 24976-25009/com.example.android.miwok 
D/OpenGLRenderer: Swap behavior 0
04-26 01:12:17.261 24976-24976/com.example.android.miwok W/art: Before 
Android 4.1, method int 
android.support.v7.widget.ListViewCompat.
lookForSelectablePosition(int, boolean) would have incorrectly 
overridden the package-private method in android.widget.ListView

的AndroidManifest.xml

    <?xml version="1.0" encoding="utf-8"?><!--
 Copyright (C) 2016 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 implied.
 See the License for the specific language governing permissions and
 limitations under the License.
   -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.android.miwok">

  <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" 
   />
        </intent-filter>
    </activity>
    <activity android:name=".FamilyActivity"
        android:label="@string/category_family"/>
    <activity android:name=".NumbersActivity"
        android:label="@string/category_numbers"/>
    <activity android:name=".ColorsActivity"
        android:label="@string/category_colors"/>
    <activity android:name=".PhrasesActivity"
        android:label="@string/category_phrases"></activity>
  </application>

  </manifest>

1 个答案:

答案 0 :(得分:0)

默认情况下,不会记录VERBOSE

  

android.util.Log#isLoggable(String tag, int level)

     

检查指定标记的日志是否可以在指定级别进行记录。任何标记的默认级别都设置为INFO。这意味着将记录任何级别以上且包括INFO。在对日志记录方法进行任何调用之前,应检查是否应记录您的标记。您可以通过设置系统属性来更改默认级别:&#39; setprop log.tag。&lt; YOUR_LOG_TAG&gt; &LT; LEVEL&GT;&#39;级别为VERBOSE,DEBUG,INFO,WARN,ERROR,ASSERT或SUPPRESS。 SUPPRESS将关闭标签的所有日志记录。您还可以创建一个local.prop文件,其中包含以下内容:&#39; log.tag。&lt; YOUR_LOG_TAG&gt; =&lt; LEVEL&gt;&#39;并将其放在/data/local.prop。

除了使用setprop(在设备重新启动之前对新进程有效)和local.prop(在启动时读取),您还可以使用System.setProperty(仅适用于你的过程)。