Is there a way to instantiate the Parse Logger outside of the context of the Parse Server?

Hi all,

I have an Express route parallel to Parse Server in my backend and I would like to retrieve the Parse Logger so that I can use it in my Express route. So is there a way to recover this Logger and use it in my route ?

Thank you.

Something like this should do what you need:

import logger from 'parse-server/lib/logger';
logger.warn('some warning');

Thank you ! That works like a charm !

Howerver i’m a little ashamed … :relaxed: I thought it was more complicated than that… Thanks again !

No problem at all :slight_smile:

@davimacedo What would be the updated instructions to obtain a built in and initialised parse logger for recent parse server releases? The example above does not seem to work when importing from ESM module. And updated code does not seem to log anything anywhere.

import logger from 'parse-server/lib/logger';
logger.warn('some warning');

Produces the error:

An uncaught exception occurred: logger.info is not a function
Stack Trace: TypeError: logger.info is not a function

The new syntax that seems to compile fine is:

import pkg from 'parse-server/lib/logger.js';
const { logger } = pkg;
logger.info("xxx");

But no matter when in the lifecycle of the app I do it, logger does not produce anything anywhere.

Help needed, thanks,
Martin