Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many files #17

Open
GasparPizarro opened this issue Aug 16, 2018 · 1 comment
Open

Too many files #17

GasparPizarro opened this issue Aug 16, 2018 · 1 comment

Comments

@GasparPizarro
Copy link

GasparPizarro commented Aug 16, 2018

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?

@dri94
Copy link

dri94 commented Oct 9, 2018

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants