Git Product home page Git Product logo

Comments (2)

tony19 avatar tony19 commented on August 16, 2024

The example below works correctly (using your config) with logback-android-1.0.1-1 from a 4.0.3 emulator in OSX Lion. Please provide a complete code sample that reproduces the problem and indicate your platform details. Thanks.

Sample code

package com.example;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import android.app.Activity;
import android.os.Bundle;

public class HelloLogbackActivity extends Activity {
    private static final Logger flogger = LoggerFactory.getLogger("flog");
    private static final Logger clogger = LoggerFactory.getLogger(Clog.class);

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        flogger.debug("from flogger");
        clogger.debug("from clogger");
    }
}

class Clog {
    // stub
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".HelloLogbackActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <logback>
        <configuration>
            <appender name="LOGCAT" class="ch.qos.logback.classic.android.LogcatAppender">
               <checkLoggable>false</checkLoggable>
               <tagEncoder>
                  <pattern>acme.%logger{15}</pattern>
               </tagEncoder>
               <encoder>
                  <pattern>[%method] %msg%n</pattern>
               </encoder>
             </appender>

            <root level="TRACE" >
                <appender-ref ref="LOGCAT" />
            </root>
        </configuration>
    </logback>
</manifest>

logcat output

D/acme.flog(  541): [onCreate] from flogger
D/acme.c.example.Clog(  541): [onCreate] from clogger

from logback-android.

lock avatar lock commented on August 16, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from logback-android.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.