winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
899 stars 156 forks source link

Error : Digest method not supported while using winston.transports.DailyRotate #340

Closed patilms16 closed 2 years ago

patilms16 commented 2 years ago

Environment :

OS : SUSE Linux Enterprise Server 15 SP2 Node: 14.16.0 Express: 4.17.1, winston: 3.2.1, winston-daily-rotate-file: 4.4.2

I am using following code :

 var transport = new (winston.transports.DailyRotateFile)({
        filename: 'log/server-%DATE%.log',
        datePattern: 'YYYY-MM-DD-HH',
        maxSize: '100m', //100MB
        zippedArchive: true,
        maxFiles: '10',
        frequency: '24h'
    });

and getting error from crypto submodule of nodejs as "Digest method not supported"

Below is actual line which was throwing error from File "FileStreamRotator.js" under node_modules : crypto.createHash('md5').update(logfile + "LOG_FILE" + time).digest("hex")

Can someone please help to identify the issue here and probable solution?

stack-overflow : https://stackoverflow.com/questions/71552510/error-digest-method-not-supported-while-using-winston-transports-dailyrotate

wbt commented 2 years ago

From createHash docs:

On recent releases of OpenSSL, openssl list -digest-algorithms (openssl list-message-digest-algorithms for older versions of OpenSSL) will display the available digest algorithms.

Can you please run that command on your platform and see if md5 is in the list?

patilms16 commented 2 years ago

md5 is not in the list on SLES platform where I am getting error. However I have checked the algorithm list on the platform (HELIOS 7.7 ) on which method is working fine without any error ( Interestingly md5 is not shown in the list on this platform as well. Please check openssl version and algorithm list for both platforms in below screenshot ( Please note : for Helios platform it is not throwing any error but for SLES platform it does )

image

wbt commented 2 years ago

This looks like a system configuration issue rather than necessarily a bug in Winston. There may be some setting on your system that disabled md5 hashing as it's a pretty weak hash. I'm generally in favor of moving past md5 because it's relatively easy to find hash collisions, but would want analysis on the potential for breaking existing workflows which might assume the current algorithm. In any event, the code you are identifying as problematic isn't in this package (Winston) but rather a dependency, so you might find more knowledgeable input about that in the repo where it's built.

Please note that when posting related questions in multiple places, it is best practice to include cross-links so that those coming after you who might encounter a similar issue can connect through to one where there might've been some progress; I would have expected to see cross links between this and your Stack Overflow question as well as with any new question you might open in file-stream-rotator. Splitting the questions without cross-links and filing on the wrong repo makes open-source work harder than it otherwise should be; please be more considerate of this next time.

patilms16 commented 2 years ago

Thanks a lot @wbt for providing the information. I have updated the cross-links and will make sure to follow this in future!!

Also posted the question in FileStreamRotator repo to get more information: https://github.com/rogerc/file-stream-rotator/issues/90

Question posted in stack-overflow : https://stackoverflow.com/questions/71552510/error-digest-method-not-supported-while-using-winston-transports-dailyrotate

patilms16 commented 2 years ago

@wbt In order to resolve this issue, need an update in daily-rotate-file.js to include option audit_hash_type https://github.com/winstonjs/winston-daily-rotate-file/blob/a4401b7277353e3375669dae35c0da866cb34e4a/daily-rotate-file.js#L94

Please check : https://github.com/rogerc/file-stream-rotator/issues/90

wbt commented 2 years ago

Open to PRs.

patilms16 commented 2 years ago

Created pull request : https://github.com/winstonjs/winston-daily-rotate-file/pull/344 Please review and let me know in case any issues.

patilms16 commented 2 years ago

@wbt Could you please verify and merge this request? We have 1 critical issue need to be fixed immediately.

ajayparsana commented 2 years ago

Thanks @patilms16 for the fix. We recently upgraded our system and facing the similar issue.

@mattberther @indexzero Can you please help with Merging request 344. This will unblock us and allow us to continue using winston daily rotate.

Appreciate your help.

ajayparsana commented 2 years ago

@wbt Thanks for the merge. @mattberther Can you please publish this to npm

mattberther commented 2 years ago

Pushed as winston-daily-rotate-file@4.7.1.