CleanroomLogger
CleanroomLogger copied to clipboard
Not printing logs to logfile
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?
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?
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.
@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 :)