Comments in conf causes Unknown directive error
Opened this issue · 2 comments
dhoer commented
Logrotatewin v0.0.0.17 sucks up the next uncommented line as part of the comment and throws Unknown directive error at the end, e.g.,
# my comment
c:\test.log {
...
}
Would result in the following output:
...
logrotate: read line # my comment c:\test.log {
logrotate: Skipping comment
...
logrotate: Unknown directive }
Let me know if you would like this written up as another issue.
pkumarex commented
Can anyone please tell where the configuration file should be placed for logrotate ?
shoddyguard commented
Just hit this myself on the version that's coming from chocolatey.
I've found that if you end the comment with {}
it seems to stop being gobbling up the rest of the text.
Example
Broken:
# Test
compress
C:\test.log {
rotate 5
daily
}
PS C:\Program Files (x86)\Ken Salter\LogRotate> .\logrotate.exe logrotate.conf -v -d
logrotate: logrotate 0.0.0.17 - Copyright (C) 2012-2016 Ken Salter
logrotate: Verbose option set to true
logrotate: Debug option set to true
logrotate: Verbose option set to true
logrotate: Parsing configuration file logrotate.conf
logrotate: read line # Test compress C:\test.log {
logrotate: Skipping comment
logrotate: read line rotate 5
logrotate: Setting rotate to 5
logrotate: read line daily
logrotate: Setting daily to True
logrotate: read line }
logrotate: Unknown directive }
logrotate: read line
Working:
# Test {}
compress
C:\test.log {
rotate 5
daily
}
logrotate: logrotate 0.0.0.17 - Copyright (C) 2012-2016 Ken Salter
logrotate: Verbose option set to true
logrotate: Debug option set to true
logrotate: Verbose option set to true
logrotate: Parsing configuration file logrotate.conf
logrotate: read line # Test {}
logrotate: Skipping comment
logrotate: read line
logrotate: read line
logrotate: read line compress
logrotate: Setting compress to True
logrotate: read line C:\test.log {
logrotate: Processing new section
logrotate: read line rotate 5
logrotate: Setting rotate to 5
logrotate: read line daily
logrotate: Setting daily to True
logrotate: read line }
logrotate: read line
logrotate: Processing C:\test.log
logrotate: Rotating file C:\test.log
logrotate: Rotate will be simulated because Debug is true
logrotate: Renaming C:\test.log to C:\\test.log.1
logrotate: Compressing rotated log file C:\\test.log.1
Hope this helps someone else in the future too!