The Wayback Machine - https://web.archive.org/web/20200624154254/https://github.com/parse-community/parse-server/issues/6307
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

Cannot Disable Logging - directory is always created #6307

Open
REPTILEHAUS opened this issue Dec 29, 2019 · 13 comments
Open

Cannot Disable Logging - directory is always created #6307

REPTILEHAUS opened this issue Dec 29, 2019 · 13 comments

Comments

@REPTILEHAUS
Copy link

@REPTILEHAUS REPTILEHAUS commented Dec 29, 2019

Im trying to integrate the default winston logger with the Google Cloud stack driver adapter but cant figure out how to integrate it

Do you guys have any pointers on this library ?
https://github.com/googleapis/nodejs-logging-winston

trying this at the moment but its not working

var WinstonLoggerAdapter = require('parse-server/lib/Adapters/Logger/WinstonLoggerAdapter');

const {LoggingWinston} = require('@google-cloud/logging-winston');

const loggingWinston = new LoggingWinston();
....
    loggerAdapter: {
        module: WinstonLoggerAdapter,
        options: {
          level: 'info',
          jsonLogs: true,
          transports: [
            // Add Stackdriver Logging
            loggingWinston,
          ],          
        },          
    },

Similar issues:
#2501
#2550
#1904

@REPTILEHAUS
Copy link
Author

@REPTILEHAUS REPTILEHAUS commented Dec 30, 2019

I have gotten it implemented however the issue remains that the default logging of parse still creates a log dir

var ParseServer = require('parse-server').ParseServer
var logger = require('parse-server').logger

// Imports the Google Cloud client library for Winston
const {LoggingWinston} = require('@google-cloud/logging-winston');

logger.options = {
    logsFolder: null,
    jsonLogs: false,
    verbose: false,
    silent: undefined
}

logger.adapter.addTransport( new LoggingWinston({
    projectId: parseConfig.gcpProjectId,
    credentials: {
        client_email: serviceAccount.client_email,
        private_key: serviceAccount.private_key
    },    
  }));

  
  try {
    logger.error('warp nacelles offline '+ env);
    logger.info('shields at 99%'+ env);      
  } catch (error) {
      console.log(error)
  }

This is causing issues in my GAE environment as writing directories is not allowed, I have also specified in logsFolder: null, in my parse init

@REPTILEHAUS
Copy link
Author

@REPTILEHAUS REPTILEHAUS commented Dec 30, 2019

Other related issues and approaches I have tried

#2855
#2518
#6205
#391

@REPTILEHAUS REPTILEHAUS changed the title Integrate Stackdriver logging for Winston Cannot Disable Logging - directory is always created Dec 30, 2019
@REPTILEHAUS
Copy link
Author

@REPTILEHAUS REPTILEHAUS commented Dec 30, 2019

Strange behaviour, even when specifying an alternative logs directory name (other than null) parse still creates a logs folder as well as the other custom folder

@REPTILEHAUS
Copy link
Author

@REPTILEHAUS REPTILEHAUS commented Dec 30, 2019

After some source code review Ive found a work around by setting process.env.PARSE_SERVER_LOGS_FOLDER=null

Seems ./src/Options/index.ts maybe should have the type logsFolder: string | null ? Im not sure about the internals of parse or what to tweak or id submit a PR but I think it can be corrected in this block in ./src/defaults.js

const { ParseServerOptions } = require('./Options/Definitions');
const logsFolder = (() => {
  let folder = './logs/';
  if (typeof process !== 'undefined' && process.env.TESTING === '1') {
    folder = './test_logs/';
  }
  if (process.env.PARSE_SERVER_LOGS_FOLDER) {
    folder = nullParser(process.env.PARSE_SERVER_LOGS_FOLDER);
  }
  return folder;
})(); 
@santiagosemhan
Copy link

@santiagosemhan santiagosemhan commented Feb 8, 2020

+1
I'm setting logsFolder to null but the Log folder and empty files each day are still created.

I'm using the following configuration:

const api = new ParseServer({
  databaseURI: mongoDSN, 
  cloud: './cloud/main.js', 
  allowClientClassCreation: false,
  appId,
  masterKey, 
  logsFolder: null,
  verbose: false,
  silent: false,
  ...

Parse Server version: 3.10.0

@davimacedo
Copy link
Member

@davimacedo davimacedo commented Feb 11, 2020

Have you tried with process.env.PARSE_SERVER_LOGS_FOLDER=null like @REPTILEHAUS suggested?

@santiagosemhan
Copy link

@santiagosemhan santiagosemhan commented Feb 11, 2020

Hi @davimacedo ! If I set process.env.PARSE_SERVER_LOGS_FOLDER=null logs folder It's not being created but I think that conf object passed to ParseServer instance should be taken into account in order to config log folder too.

Thanks

@davimacedo
Copy link
Member

@davimacedo davimacedo commented Feb 12, 2020

Got it. This is something that can be really improved. Do you want to tackle this one?

@santiagosemhan
Copy link

@santiagosemhan santiagosemhan commented Feb 12, 2020

I spent a lot of time trying to figure out where the problem was but honestly I couldn't find it. If you can give me a clue maybe I could tackle this!

@davimacedo
Copy link
Member

@davimacedo davimacedo commented Feb 12, 2020

If you set logsFolder to any other folder than not the default, does it work? I guess this option is only working through env vars.

@santiagosemhan
Copy link

@santiagosemhan santiagosemhan commented Feb 13, 2020

@dplewis
Copy link
Member

@dplewis dplewis commented Feb 13, 2020

Although the server doesn't create the folder. Winston creates it internally I believe

@santiagosemhan
Copy link

@santiagosemhan santiagosemhan commented Feb 14, 2020

I thought the same thing but the question is Why if you set PARSE_SERVER_LOGS_FOLDER env var to null the folder is not created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.