Skip to content

Too many files #17

Open
Open

Description

@GasparPizarro

Relevant Gradle config:

implementation 'com.github.bright:slf4android:0.1.5'

I am trying to log to a file, and in my activity I have this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FileLogHandlerConfiguration fileHandler = LoggerConfiguration.fileLogHandler(this);
    fileHandler.setFullFilePathPattern(new File(getApplicationInfo().dataDir, "activity.g.%u" +".log").getAbsolutePath());
    LoggerConfiguration.configuration().addHandlerToRootLogger(fileHandler);
}

And each time I enter the activity (without exiting the app, just going to another activity in it) it creates a new file. After entering two time to the activity I have

activity.0.0.log
activity.0.1.log

Is this expected behavior? Can I configure it to have only one (rotated) file?

Activity

  1. dri94 commented on Oct 9, 2018

    @dri94

    This is because you are initialize it every single time in your activity. Create a global instance of this variable to avoid this. Best put in your application class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions