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

Not printing logs to logfile #73

Open
gdimaggio opened this issue Mar 14, 2017 · 3 comments
Open

Not printing logs to logfile #73

gdimaggio opened this issue Mar 14, 2017 · 3 comments

Comments

@gdimaggio
Copy link

Probably I'm missing something obvious but I can't get Cleanroom to log any of my messages to the logfile. I set up a RotatingLogFileConfiguration and call enable in my AppDelegate, as show by the code below:

var configurations: [BasicLogConfiguration] = [basicLogConfig]
if let directoryPath = self.logFileDirectoryPath() {
   let logConfiguration = RotatingLogFileConfiguration(minimumSeverity: .debug,
                                                        daysToKeep: 15,
                                                        directoryPath: directoryPath.path,
                                                        formatters: [formatter])
    do {
       logConfiguration.createLogDirectory()
       configurations.append(logConfiguration)
    } catch { }
}
Log.enable(configuration: configurations)

The file is correctly created in the directory passed by logFileDirectoryPath(), but the file is always empty no matter what...any thoughts?

@gdimaggio gdimaggio changed the title Not print to log file Not printing logs to logfile Mar 14, 2017
@emaloney
Copy link
Owner

Hello,

There could be multiple possibilities. Would you mind trying the just-issued 5.0.3 release first? It addresses a separate issue with logs not being flushed frequently enough when not running in synchronous mode. This is one possible cause of the behavior you're seeing.

Another thing to try it setting a couple breakpoints to make sure they're being hit. Setting one at RotatingLogFileRecorder.swift:136 will let you know if the rotating log recorder is being called.

Setting one at FileLogRecorder.swift:84 will let you know if the underlying log recorder used by the rotating recorder is being called.

Lastly, what do your Log statements look like? It is possible you're not recording anything at the .debug severity or higher?

@jogi
Copy link

jogi commented Mar 16, 2017

I had a similar issue and it turned out that I was calling Log.enable() twice. Once by calling Log.enable(minimumSeverity: .debug) and once by calling Log.enable(configuration: [LogConfiguration]). I didn't realize that when enabling using configurations, you need to pass the severity directly in the LogConfiguration object.

@dustinrwh
Copy link

@gdimaggio What directory path are writing to?

This probably isn't the issue since the file is actually being created in the directory, but the more information the better :)

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

No branches or pull requests

4 participants