ParseServer maxLogFiles not yet effective ?
New Issue Checklist
- [ ] I am not disclosing a vulnerability.
- [ ] I am not just asking a question.
- [ ] I have searched through existing issues.
- [ ] I can reproduce the issue with the latest version of Parse Server.
Issue Description
var api = new ParseServer({
// logLevel:"error",
databaseURI: database.uri,
cloud: server.cloud,
appId: server.appId,
masterKey: server.masterKey,
serverURL: Config.server.serverURL,
directAccess: false,
maxLogFiles: 5
});
maxLogFiles not yet effective ????
I specified the maximum number of log files as 5, but the number of generated files still exceeds 5, I read the configuration of winston, it is necessary to use with maxsize, in the exceeding of maxsize will automatically delete the log files before 5. But I read the source code of winston and parse-server configurations, and this maxLogFiles configuration is not correct to be used in winston in the end.
parse-server source code:
const consoleFormat = options.json ? format.json() : format.simple();
const consoleOptions = Object.assign(
{
colorize: true,
name: 'console',
silent,
format: format.combine(format.splat(), consoleFormat),
},
options
);
transports.push(new winston.transports.Console(consoleOptions)); // maxLogFiles ->maxFiles This configuration winston is not for here.
}
logger.configure({
transports,
});
winston example:
const logger = winston.createLogger();
logger.configure({
level: 'verbose',
transports: [
new winston.transports.File({
filename: path.join(__dirname, 'info.log'),
// level: 'info',
// maxsize: 1024,
maxFiles: 2 // It should be in the` File `configuration, not the` Console `configuration.
})
]
})
Steps to reproduce
Actual Outcome
Expected Outcome
Environment
Server
- Parse Server version:
v6.3.1 - Operating system:
windows
Database
- System (MongoDB or Postgres):
MongoDB - Database version:
5.0
Logs
Thanks for opening this issue!
- 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.
Hello, I see this issue is still open. Can I give it a try?
@vivekjoshi556 Sure, please go ahead
Hello @mtrezza & @zurmokeeper,
I was unable to reproduce the error. The rotation worked fine on my system. On the next day, the files rotated as expected. @zurmokeeper could you maybe provide more information if you are still facing the issue?
And you are right about Winston's documentation that maxSize is a required parameter but we are using winston-daily-rotate-file and there is nothing specified in the documentation about maxSize being required for maxFiles (from what I could understand, let me know if you find something else).
While checking it threw an error when I tried to use a value ending with a 'd' (e.g. '5d') for maxLogFiles (which is an acceptable value according to documentation in parse).
This problem arises because maxLogFiles have
action: parsers.objectParser
in Definitions.js, which causes it to be parsed as an object, and since non-numeric characters in a string makes it an invalid JSON, the parsing fails.
According to documentation for maxLogFiles:
This can be a number of files or number of days. If using days, add 'd' as the suffix.
I don't think 'd' matters here anyway because both imply the same thing. For each day a new file is created, so how many log files should be created at max and how many days of files to keep is essentially the same thing, (so maybe we can update the documentation to remove instructions about this 'd')
Duplidate https://github.com/parse-community/parse-server/issues/6426
I looked into this years ago. The objectParser needs to be changed to numberStringParser.
Closing as duplicate; added bounty to other issue since it's already open for 4 years.