[ad_1]
Can you please help me how to write & save logs into winston file transports using docker image container. Using docker able to create logs file and even console logs printing in host server, But the logs are not saved into log files, always the log files are empty.
WORKDIR /home/app
RUN mkdir -p /path/to/logs && \
touch /path/to/logs/error.log && \
touch //path/to/logs/combined.log && \
chmod 777 /path/to/logs/*
logdir = path.join(__dirname, '../../logs/');
if (!fs.existsSync(this.logdir)) {
fs.mkdirSync(this.logdir, { recursive: true });
}
const errorFile = path.join(this.logdir, 'error.log');
const combinedFile = path.join(this.logdir, 'combined.log');
this.winstonLogger = createLogger({
level: 'info',
format: format.combine(
format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss',
}),
format.errors({ stack: true }),
format.splat(),
format.json(),
),
defaultMeta: { service: context },
transports: [
new transports.File({
filename: errorFile,
level: 'error',
}),
new transports.File({ filename: combinedFile, maxFiles: 2, maxsize: 102400 }),
],
})
still winston file transport not able to save logs into files.
In local environment without docker image it’s working as expected.
So can you please suggest how to write & save logs into winston file transports using docker image.
[ad_2]