slf4android icon indicating copy to clipboard operation
slf4android copied to clipboard

Too many files

Open GasparPizarro opened this issue 7 years ago • 1 comments

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?

GasparPizarro avatar Aug 16 '18 14:08 GasparPizarro

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.

dri94 avatar Oct 09 '18 18:10 dri94