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

ParseServer maxLogFiles not yet effective ? #8827

Closed
4 tasks
zurmokeeper opened this issue Nov 29, 2023 · 6 comments
Closed
4 tasks

ParseServer maxLogFiles not yet effective ? #8827

zurmokeeper opened this issue Nov 29, 2023 · 6 comments
Labels
state:duplicate Duplicate of already reported issue type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@zurmokeeper
Copy link

zurmokeeper commented Nov 29, 2023

New Issue Checklist

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

Copy link

parse-github-assistant bot commented Nov 29, 2023

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.

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Nov 29, 2023
@vivekjoshi556
Copy link
Contributor

Hello,
I see this issue is still open. Can I give it a try?

@mtrezza
Copy link
Member

mtrezza commented Jun 29, 2024

@vivekjoshi556 Sure, please go ahead

@vivekjoshi556
Copy link
Contributor

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')

@dplewis
Copy link
Member

dplewis commented Jul 7, 2024

Duplidate #6426

I looked into this years ago. The objectParser needs to be changed to numberStringParser.

@mtrezza
Copy link
Member

mtrezza commented Jul 7, 2024

Closing as duplicate; added bounty to other issue since it's already open for 4 years.

@mtrezza mtrezza added the state:duplicate Duplicate of already reported issue label Jul 7, 2024
@mtrezza mtrezza closed this as completed Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:duplicate Duplicate of already reported issue type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

4 participants